Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable all legacy source map tests for the embedded host #1776

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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