Skip to content

Commit

Permalink
Enable all legacy source map tests for the embedded host (#1776)
Browse files Browse the repository at this point in the history
This also adds one additional regression test for an issue identified
in webpack-contrib/sass-loader#774 (comment).
  • Loading branch information
nex3 authored Feb 17, 2022
1 parent 9b6ede5 commit ae51f2b
Showing 1 changed file with 44 additions and 24 deletions.
68 changes: 44 additions & 24 deletions js-api-spec/legacy/source-map.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as p from 'path';
import * as sass from 'sass';

import {sandbox} from '../sandbox';
import {skipForImpl} from '../utils';
import '../utils';

describe('a basic invocation', () => {
let css: string;
Expand Down Expand Up @@ -106,20 +106,42 @@ describe('the sources list', () => {
]);
}));

skipForImpl('sass-embedded', () => {
it('contains a URL handled by an importer', () => {
it('contains a URL handled by an importer', () => {
const map = renderSourceMap({
data: `
@import "other";
a {b: c}
`,
sourceMap: true,
importer: () => ({contents: 'x {y: z}'}),
outFile: 'out.css',
});
expect(map).toContainEntry(['sources', ['other', 'stdin']]);
});

// Regression test for the embedded host.
it('contains a relative file URL even if an importer exists', () =>
sandbox(dir => {
dir.write({
'test.scss': `
@import "other";
a {b: c}
`,
'subdir/_other.scss': 'x {y: z}',
});

const map = renderSourceMap({
data: `
@import "other";
a {b: c}
`,
file: dir('test.scss'),
sourceMap: true,
importer: () => ({contents: 'x {y: z}'}),
outFile: 'out.css',
includePaths: [dir('subdir')],
outFile: dir('out.css'),
importer: () => null,
});
expect(map).toContainEntry(['sources', ['other', 'stdin']]);
});
});
expect(map).toContainEntry([
'sources',
['subdir/_other.scss', 'test.scss'],
]);
}));
});

describe("doesn't emit the source map", () => {
Expand Down Expand Up @@ -181,21 +203,19 @@ describe('with a string sourceMap and no outFile', () => {
renderSourceMap({data: 'a {b: c}', sourceMap: 'out.css.map'})
).toContainEntry(['file', 'stdin.css']));

skipForImpl('sass-embedded', () => {
// Regression test for sass/dart-sass#922
it('contains a URL handled by an importer when sourceMap is absolute', () =>
expect(
renderSourceMap({
data: `
// Regression test for sass/dart-sass#922
it('contains a URL handled by an importer when sourceMap is absolute', () =>
expect(
renderSourceMap({
data: `
@import "other";
a {b: c}
`,
importer: () => ({contents: 'x {y: z}'}),
sourceMap: p.resolve('out.css.map'),
outFile: 'out.css',
})
).toContainEntry(['sources', ['other', 'stdin']]));
});
importer: () => ({contents: 'x {y: z}'}),
sourceMap: p.resolve('out.css.map'),
outFile: 'out.css',
})
).toContainEntry(['sources', ['other', 'stdin']]));
});

it("with omitSourceMapUrl, doesn't include a source map comment", () => {
Expand Down

0 comments on commit ae51f2b

Please sign in to comment.