Skip to content

Commit

Permalink
Add a test for an importer without a base URL
Browse files Browse the repository at this point in the history
Closes #1970
  • Loading branch information
nex3 committed Apr 9, 2024
1 parent 3aae845 commit 30410dd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions js-api-spec/importer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,24 @@ describe("compileString()'s importer option", () => {
expect(result.css).toBe('a {\n result: "foo/baz/qux/bang";\n}');
});

it('loads relative imports without an entrypoint URL', () => {
const result = compileString('@import "orange";', {
importer: {
canonicalize: (url: string) => {
expect(url).toBe('orange');
return new URL('u:orange');
},
load: (url: typeof URL) => {
const color = url.pathname;
return {contents: `.${color} {color: ${color}}`, syntax: 'scss'};
},
},
url: undefined,
});

expect(result.css).toBe('.orange {\n color: orange;\n}');
});

it('takes precedence over the importer list for relative URLs', () => {
const result = compileString('@import "other";', {
importers: [
Expand Down

0 comments on commit 30410dd

Please sign in to comment.