Skip to content

Commit 82cbbe0

Browse files
committed
test: add reverse trailing slash case
1 parent 17c5046 commit 82cbbe0

File tree

6 files changed

+73
-0
lines changed

6 files changed

+73
-0
lines changed

packages/core/test/__snapshots__/html.test.ts.snap

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,28 @@ exports[`html handler > common usage 1`] = `
1313
</h1>
1414
1515
16+
</body></html>"
17+
`;
18+
19+
exports[`html handler > trailing slash case 0 1`] = `
20+
"<!DOCTYPE html><html lang=\\"en\\"><head>
21+
<meta charset=\\"UTF-8\\">
22+
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"IE=edge\\">
23+
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\">
24+
<title>Document</title>
25+
</head>
26+
27+
<body>
28+
<div>
29+
<div class=\\"tw-a\\">
30+
Block with bg-red-500/50 class
31+
</div>
32+
<div class=\\"tw-b\\">
33+
Block with bg-red-500 class
34+
</div>
35+
</div>
36+
37+
1638
</body></html>"
1739
`;
1840

packages/core/test/__snapshots__/js.test.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ exports[`js handler nextjs server side mangle 1`] = `
254254
255255
exports[`js handler trailing slash case 0 1`] = `"document.getElementById("#app").classList.add("tw-a tw-b");"`;
256256
257+
exports[`js handler trailing slash case 1 1`] = `"document.querySelector('##app').classList.add("tw-a tw-b");"`;
258+
257259
exports[`js handler z-10 not transform 1`] = `
258260
"{
259261
className: "tw-a tw-b tw-c tw-d tw-e tw-f tw-g tw-h";
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<title>Document</title>
9+
</head>
10+
11+
<body>
12+
<div>
13+
<div class="bg-red-500/50">
14+
Block with bg-red-500/50 class
15+
</div>
16+
<div class="bg-red-500">
17+
Block with bg-red-500 class
18+
</div>
19+
</div>
20+
</body>
21+
22+
</html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
document.querySelector('##app').classList.add('bg-red-500/50 bg-red-500')

packages/core/test/html.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,17 @@ describe('html handler', () => {
3232
})
3333
expect(res).toMatchSnapshot()
3434
})
35+
36+
it('trailing slash case 0', () => {
37+
const runtimeSet = new Set<string>()
38+
39+
for (const x of splitCode('bg-red-500 bg-red-500/50')) {
40+
runtimeSet.add(x)
41+
}
42+
const res = htmlHandler(getTestCase('trailing-slash-0.html'), {
43+
classGenerator,
44+
runtimeSet
45+
})
46+
expect(res).toMatchSnapshot()
47+
})
3548
})

packages/core/test/js.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,17 @@ describe('js handler', () => {
161161
}).code
162162
expect(code).toMatchSnapshot()
163163
})
164+
165+
it('trailing slash case 1', () => {
166+
const testCase = getTestCase('trailing-slash-1.js')
167+
const runtimeSet = new Set<string>()
168+
runtimeSet.add('bg-red-500/50')
169+
runtimeSet.add('bg-red-500')
170+
171+
const code = jsHandler(testCase, {
172+
classGenerator,
173+
runtimeSet
174+
}).code
175+
expect(code).toMatchSnapshot()
176+
})
164177
})

0 commit comments

Comments
 (0)