Skip to content

Commit 75ce758

Browse files
author
Michael Vurchio
committed
Add test for [path]
1 parent de54643 commit 75ce758

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

test/compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = async ({ source, localIdentName }) => {
99
localIdentName,
1010
})
1111
],
12-
{ filename : 'App.svelte' }
12+
{ filename : 'src/App.svelte' }
1313
);
1414

1515
return code;

test/path.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const compiler = require('./compiler.js');
2+
3+
const source = '<style>.red { color: red; }</style>\n<span class="$style.red">Red</span>';
4+
const sourceReactiveClass = '<style>.red { color: red; }</style>\n<span class:$.red={true}>Red</span>';
5+
6+
test('Replace path on regular class', async () => {
7+
const output = await compiler({
8+
source,
9+
localIdentName: '[path][name]__[local]',
10+
});
11+
12+
expect(output).toBe('<style>:global(.src_App__red) { color: red; }</style>\n<span class="src_App__red">Red</span>');
13+
});
14+
15+
test('Replace path on reactive class', async () => {
16+
const output = await compiler({
17+
source: sourceReactiveClass,
18+
localIdentName: '[path][name]__[local]',
19+
});
20+
21+
expect(output).toBe('<style>:global(.src_App__red) { color: red; }</style>\n<span class:src_App__red={true}>Red</span>');
22+
});

0 commit comments

Comments
 (0)