Skip to content

Commit db46d68

Browse files
committed
feat: Add partial Svelte test and related snapshot
This commit introduces a new test for partial Svelte files. It also includes the corresponding snapshot for the test. Additionally, new CSS files have been added to the test project to support the test.
1 parent 8ed4274 commit db46d68

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

__snapshots__/mod_test.ts.snap

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,37 @@ div {
2222
</style>
2323
\`
2424
`;
25+
26+
snapshot[`example svelte partial 1`] = `
27+
\`<script>
28+
let name = 'world';
29+
</script>
30+
31+
<div class="m2">This is a paragraph</div>
32+
<p id="message">This is a paragraph</p>
33+
34+
<style>
35+
36+
div {
37+
color: red;
38+
background: blue;
39+
}
40+
41+
42+
43+
p {
44+
color: blue;
45+
}
46+
47+
.m2 {
48+
background: yellow;
49+
}
50+
51+
52+
53+
#message {
54+
text-decoration: underline;
55+
}
56+
</style>
57+
\`
58+
`;

mod_test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,20 @@ Deno.test(
2020
await assertSnapshot(t, code);
2121
},
2222
);
23+
Deno.test(
24+
"example svelte partial",
25+
async function (t) {
26+
const filename = join(
27+
import.meta.dirname as string,
28+
"./test_project/Partial.svelte",
29+
);
30+
const source = Deno.readTextFileSync(filename);
31+
const { code } = await preprocess(
32+
source,
33+
[importCSSPreprocess()],
34+
{ filename },
35+
);
36+
37+
await assertSnapshot(t, code);
38+
},
39+
);

test_project/Partial.svelte

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<script>
2+
let name = 'world';
3+
</script>
4+
5+
<div class="m2">This is a paragraph</div>
6+
<p id="message">This is a paragraph</p>
7+
8+
<style>
9+
@import './main.css#div' scoped;
10+
@import './partial.css?p&.m2' scoped;
11+
12+
#message {
13+
text-decoration: underline;
14+
}
15+
</style>

test_project/partial.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
p {
2+
color: blue;
3+
}
4+
5+
h1 {
6+
color: green;
7+
}
8+
9+
.m2 {
10+
background: yellow;
11+
}

0 commit comments

Comments
 (0)