Skip to content

Commit 58a19c5

Browse files
authored
test: add test for use with Sass partials (#258)
1 parent 079fa27 commit 58a19c5

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

src/helpers/__tests__/__snapshots__/getDtsSnapshot.test.ts.snap

+12
Original file line numberDiff line numberDiff line change
@@ -1361,3 +1361,15 @@ export let myAnimation: string | undefined;
13611361
export let myFolderIndex: string | undefined;
13621362
"
13631363
`;
1364+
1365+
exports[`helpers / cssSnapshots with sass @use and a partial should find external file from loadPaths 1`] = `
1366+
{
1367+
"class-with-partial": "class-with-partial",
1368+
}
1369+
`;
1370+
1371+
exports[`helpers / cssSnapshots with sass @use and a partial should find external file from loadPaths 2`] = `
1372+
".class-with-partial {
1373+
background-color: rebeccapurple;
1374+
}"
1375+
`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$primary-color: rebeccapurple;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@use 'partial';
2+
3+
.class-with-partial {
4+
background-color: partial.$primary-color;
5+
}

src/helpers/__tests__/getDtsSnapshot.test.ts

+20
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,26 @@ describe('helpers / cssSnapshots', () => {
152152
});
153153
});
154154

155+
describe('with sass @use and a partial', () => {
156+
const fileName = join(__dirname, 'fixtures', 'partial.module.scss');
157+
const css = readFileSync(fileName, 'utf8');
158+
159+
it('should find external file from loadPaths', () => {
160+
const cssExports = getCssExports({
161+
css,
162+
fileName,
163+
logger,
164+
options,
165+
processor,
166+
compilerOptions,
167+
directory: __dirname,
168+
});
169+
170+
expect(cssExports.classes).toMatchSnapshot();
171+
expect(cssExports.css).toMatchSnapshot();
172+
});
173+
});
174+
155175
describe('with loadPaths in sass options', () => {
156176
const fileName = join(__dirname, 'fixtures', 'include-path.module.scss');
157177
const css = readFileSync(fileName, 'utf8');

0 commit comments

Comments
 (0)