Skip to content

Commit

Permalink
Add a test for an importer without a base URL (#1972)
Browse files Browse the repository at this point in the history
Closes #1970
  • Loading branch information
nex3 authored Apr 11, 2024
1 parent 9bfd250 commit dccf461
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions js-api-spec/importer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,23 @@ 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'};
},
},
});

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 dccf461

Please sign in to comment.