@@ -4,8 +4,11 @@ import { getCss, getTestCase } from './utils'
4
4
// import { getClassCacheSet } from 'tailwindcss-patch'
5
5
6
6
describe ( 'js handler' , ( ) => {
7
+ let classGenerator : ClassGenerator
8
+ beforeEach ( ( ) => {
9
+ classGenerator = new ClassGenerator ( )
10
+ } )
7
11
it ( 'common StringLiteral' , ( ) => {
8
- const classGenerator = new ClassGenerator ( )
9
12
const runtimeSet = new Set < string > ( )
10
13
runtimeSet . add ( 'dark:bg-zinc-800/30' )
11
14
runtimeSet . add ( 'lg:dark:bg-zinc-800/30' )
@@ -19,7 +22,6 @@ describe('js handler', () => {
19
22
} )
20
23
21
24
it ( 'common TemplateElement' , ( ) => {
22
- const classGenerator = new ClassGenerator ( )
23
25
const runtimeSet = new Set < string > ( )
24
26
runtimeSet . add ( 'dark:bg-zinc-800/30' )
25
27
runtimeSet . add ( 'lg:dark:bg-zinc-800/30' )
@@ -32,24 +34,22 @@ describe('js handler', () => {
32
34
expect ( code ) . toMatchSnapshot ( )
33
35
} )
34
36
35
- it ( 'text-[red]' , ( ) => {
36
- const classGenerator = new ClassGenerator ( )
37
- const runtimeSet = new Set < string > ( )
37
+ // it('text-[red]', () => {
38
+ // const runtimeSet = new Set<string>()
38
39
39
- // eslint-disable-next-line no-template-curly-in-string
40
- const testCase = ''
41
- testCase . split ( ' ' ) . forEach ( ( x ) => {
42
- runtimeSet . add ( x )
43
- } )
44
- const code = jsHandler ( testCase , {
45
- classGenerator,
46
- runtimeSet
47
- } ) . code
48
- expect ( code ) . toMatchSnapshot ( )
49
- } )
40
+ // // eslint-disable-next-line no-template-curly-in-string
41
+ // const testCase = ''
42
+ // testCase.split(' ').forEach((x) => {
43
+ // runtimeSet.add(x)
44
+ // })
45
+ // const code = jsHandler(testCase, {
46
+ // classGenerator,
47
+ // runtimeSet
48
+ // }).code
49
+ // expect(code).toMatchSnapshot()
50
+ // })
50
51
51
52
it ( 'z-10 not transform' , ( ) => {
52
- const classGenerator = new ClassGenerator ( )
53
53
const runtimeSet = new Set < string > ( )
54
54
'z-10 w-full max-w-5xl items-center justify-between font-mono text-sm lg:flex' . split ( ' ' ) . forEach ( ( cls ) => {
55
55
runtimeSet . add ( cls )
@@ -64,7 +64,6 @@ describe('js handler', () => {
64
64
} )
65
65
66
66
it ( 'nextjs server side mangle' , ( ) => {
67
- const classGenerator = new ClassGenerator ( )
68
67
const testCase = getTestCase ( 'next-server-page.js' )
69
68
getCss ( testCase )
70
69
const runtimeSet = new Set ( require ( './fixtures/tw-class-set.json' ) as string [ ] ) // getClassCacheSet()
@@ -76,4 +75,14 @@ describe('js handler', () => {
76
75
} ) . code
77
76
expect ( code ) . toMatchSnapshot ( )
78
77
} )
78
+
79
+ it ( 'eval script case' , ( ) => {
80
+ const testCase = getTestCase ( 'webpack-dev-content.js' )
81
+ const runtimeSet = new Set ( require ( './fixtures/tw-class-set.json' ) as string [ ] )
82
+ const code = jsHandler ( testCase , {
83
+ classGenerator,
84
+ runtimeSet
85
+ } ) . code
86
+ expect ( code ) . toMatchSnapshot ( )
87
+ } )
79
88
} )
0 commit comments