Skip to content

Commit 936aa53

Browse files
committed
chore: add trailing slash case 2
1 parent 82cbbe0 commit 936aa53

File tree

6 files changed

+37
-2
lines changed

6 files changed

+37
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,9 @@ 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");"`;
257+
exports[`js handler trailing slash case 1 1`] = `"document.querySelector("#app").classList.add("tw-a tw-b");"`;
258+
259+
exports[`js handler trailing slash case 2 1`] = `"document.querySelector("#app").classList.add("tw-a tw-b tw-a s tw-a");"`;
258260
259261
exports[`js handler z-10 not transform 1`] = `
260262
"{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
document.querySelector('##app').classList.add('bg-red-500/50 bg-red-500')
1+
document.querySelector('#app').classList.add('bg-red-500/50 bg-red-500')
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 bg-red-500/50 bg-red-500 s bg-red-500')

packages/core/test/js.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,17 @@ describe('js handler', () => {
174174
}).code
175175
expect(code).toMatchSnapshot()
176176
})
177+
178+
it('trailing slash case 2', () => {
179+
const testCase = getTestCase('trailing-slash-2.js')
180+
const runtimeSet = new Set<string>()
181+
runtimeSet.add('bg-red-500/50')
182+
runtimeSet.add('bg-red-500')
183+
184+
const code = jsHandler(testCase, {
185+
classGenerator,
186+
runtimeSet
187+
}).code
188+
expect(code).toMatchSnapshot()
189+
})
177190
})

packages/shared/test/__snapshots__/reg.test.ts.snap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ exports[`regex trailing slash should exact match case 1 1`] = `
1919
]
2020
`;
2121

22+
exports[`regex trailing slash should exact match case 2 1`] = `
23+
[
24+
[
25+
"bg-red-500",
26+
],
27+
[
28+
"bg-red-500",
29+
],
30+
]
31+
`;
32+
2233
exports[`regex z-10 regex 1`] = `
2334
[
2435
[

packages/shared/test/reg.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ describe('regex', () => {
2626
expect(arr.length).toBe(1)
2727
expect(arr).toMatchSnapshot()
2828
})
29+
30+
it('trailing slash should exact match case 2', () => {
31+
const testCase = 's bg-red-500 bg-red-500/50 bg-red-500'
32+
const regex = makeRegex('bg-red-500')
33+
const arr = [...testCase.matchAll(regex)]
34+
expect(arr.length).toBe(2)
35+
expect(arr).toMatchSnapshot()
36+
})
2937
})

0 commit comments

Comments
 (0)