Skip to content

Commit

Permalink
test: add test for use with Sass partials (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmckeb authored Feb 11, 2024
1 parent 079fa27 commit 58a19c5
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/helpers/__tests__/__snapshots__/getDtsSnapshot.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1361,3 +1361,15 @@ export let myAnimation: string | undefined;
export let myFolderIndex: string | undefined;
"
`;

exports[`helpers / cssSnapshots with sass @use and a partial should find external file from loadPaths 1`] = `
{
"class-with-partial": "class-with-partial",
}
`;

exports[`helpers / cssSnapshots with sass @use and a partial should find external file from loadPaths 2`] = `
".class-with-partial {
background-color: rebeccapurple;
}"
`;
1 change: 1 addition & 0 deletions src/helpers/__tests__/fixtures/_partial.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$primary-color: rebeccapurple;
5 changes: 5 additions & 0 deletions src/helpers/__tests__/fixtures/partial.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@use 'partial';

.class-with-partial {
background-color: partial.$primary-color;
}
20 changes: 20 additions & 0 deletions src/helpers/__tests__/getDtsSnapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,26 @@ describe('helpers / cssSnapshots', () => {
});
});

describe('with sass @use and a partial', () => {
const fileName = join(__dirname, 'fixtures', 'partial.module.scss');
const css = readFileSync(fileName, 'utf8');

it('should find external file from loadPaths', () => {
const cssExports = getCssExports({
css,
fileName,
logger,
options,
processor,
compilerOptions,
directory: __dirname,
});

expect(cssExports.classes).toMatchSnapshot();
expect(cssExports.css).toMatchSnapshot();
});
});

describe('with loadPaths in sass options', () => {
const fileName = join(__dirname, 'fixtures', 'include-path.module.scss');
const css = readFileSync(fileName, 'utf8');
Expand Down

0 comments on commit 58a19c5

Please sign in to comment.