Skip to content

Commit

Permalink
Add tests for MultiSpan in the JS API
Browse files Browse the repository at this point in the history
  • Loading branch information
jathak committed Sep 14, 2022
1 parent 8c68570 commit f569085
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions js-api-spec/compile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ describe('compileString', () => {
compileString('@error "oh no"', {url})
).toThrowSassException({line: 0, url});
}));

it('with multi-span errors', () =>
sandbox(dir => {
const url = dir.url('foo.scss');
expect(() =>
compileString('@use "sass:math"; @use "sass:math"', {url})
).toThrowSassException({line: 0, url});
}));
});

it('throws an error for an unrecognized style', () => {
Expand Down
18 changes: 18 additions & 0 deletions js-api-spec/logger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ it('emits debug to stderr by default', () => {
expect(stdio.err).not.toBeEmpty();
});

describe('deprecation warning', () => {
// Regression test for sass/dart-sass#1790
it('passes the message and span to the logger', done => {
compileString('* > { --foo: bar }', {
logger: {
warn(message, {span}) {
expect(message).toInclude('only valid for nesting');
expect(span?.start.line).toBe(0);
expect(span?.start.column).toBe(0);
expect(span?.end.line).toBe(0);
expect(span?.end.column).toBe(4);
done();
},
},
});
});
});

describe('with @warn', () => {
it('passes the message and stack trace to the logger', done => {
compileString(
Expand Down

0 comments on commit f569085

Please sign in to comment.