|
1 | 1 | import { __unstable__loadDesignSystem } from '@tailwindcss/node'
|
2 |
| -import { describe, expect, test } from 'vitest' |
| 2 | +import { expect, test } from 'vitest' |
3 | 3 | import { spliceChangesIntoString } from '../../utils/splice-changes-into-string'
|
4 | 4 | import { extractRawCandidates } from './candidates'
|
5 | 5 |
|
@@ -82,116 +82,3 @@ test('replaces the right positions for a candidate', async () => {
|
82 | 82 | "
|
83 | 83 | `)
|
84 | 84 | })
|
85 |
| - |
86 |
| -const candidates = [ |
87 |
| - // Arbitrary candidates |
88 |
| - ['[color:red]', '[color:red]'], |
89 |
| - ['[color:red]/50', '[color:red]/50'], |
90 |
| - ['[color:red]/[0.5]', '[color:red]/[0.5]'], |
91 |
| - ['[color:red]/50!', '[color:red]/50!'], |
92 |
| - ['![color:red]/50', '[color:red]/50!'], |
93 |
| - ['[color:red]/[0.5]!', '[color:red]/[0.5]!'], |
94 |
| - |
95 |
| - // Static candidates |
96 |
| - ['box-border', 'box-border'], |
97 |
| - ['underline!', 'underline!'], |
98 |
| - ['!underline', 'underline!'], |
99 |
| - ['-inset-full', '-inset-full'], |
100 |
| - |
101 |
| - // Functional candidates |
102 |
| - ['bg-red-500', 'bg-red-500'], |
103 |
| - ['bg-red-500/50', 'bg-red-500/50'], |
104 |
| - ['bg-red-500/[0.5]', 'bg-red-500/[0.5]'], |
105 |
| - ['bg-red-500!', 'bg-red-500!'], |
106 |
| - ['!bg-red-500', 'bg-red-500!'], |
107 |
| - ['bg-[#0088cc]/50', 'bg-[#0088cc]/50'], |
108 |
| - ['bg-[#0088cc]/[0.5]', 'bg-[#0088cc]/[0.5]'], |
109 |
| - ['bg-[#0088cc]!', 'bg-[#0088cc]!'], |
110 |
| - ['!bg-[#0088cc]', 'bg-[#0088cc]!'], |
111 |
| - ['bg-[var(--spacing)-1px]', 'bg-[var(--spacing)-1px]'], |
112 |
| - ['bg-[var(--spacing)_-_1px]', 'bg-[var(--spacing)-1px]'], |
113 |
| - ['bg-[var(--_spacing)]', 'bg-(--_spacing)'], |
114 |
| - ['bg-(--_spacing)', 'bg-(--_spacing)'], |
115 |
| - ['bg-[var(--\_spacing)]', 'bg-(--_spacing)'], |
116 |
| - ['bg-(--\_spacing)', 'bg-(--_spacing)'], |
117 |
| - ['bg-[-1px_-1px]', 'bg-[-1px_-1px]'], |
118 |
| - ['p-[round(to-zero,1px)]', 'p-[round(to-zero,1px)]'], |
119 |
| - ['w-1/2', 'w-1/2'], |
120 |
| - ['p-[calc((100vw-theme(maxWidth.2xl))_/_2)]', 'p-[calc((100vw-theme(maxWidth.2xl))/2)]'], |
121 |
| - |
122 |
| - // Keep spaces in strings |
123 |
| - ['content-["hello_world"]', 'content-["hello_world"]'], |
124 |
| - ['content-[____"hello_world"___]', 'content-["hello_world"]'], |
125 |
| - |
126 |
| - // Do not escape underscores for url() and CSS variable in var() |
127 |
| - ['bg-[no-repeat_url(/image_13.png)]', 'bg-[no-repeat_url(/image_13.png)]'], |
128 |
| - [ |
129 |
| - 'bg-[var(--spacing-0_5,_var(--spacing-1_5,_3rem))]', |
130 |
| - 'bg-(--spacing-0_5,var(--spacing-1_5,3rem))', |
131 |
| - ], |
132 |
| -] |
133 |
| - |
134 |
| -const variants = [ |
135 |
| - ['', ''], // no variant |
136 |
| - ['*:', '*:'], |
137 |
| - ['focus:', 'focus:'], |
138 |
| - ['group-focus:', 'group-focus:'], |
139 |
| - |
140 |
| - ['hover:focus:', 'hover:focus:'], |
141 |
| - ['hover:group-focus:', 'hover:group-focus:'], |
142 |
| - ['group-hover:focus:', 'group-hover:focus:'], |
143 |
| - ['group-hover:group-focus:', 'group-hover:group-focus:'], |
144 |
| - |
145 |
| - ['min-[10px]:', 'min-[10px]:'], |
146 |
| - |
147 |
| - // Normalize spaces |
148 |
| - ['min-[calc(1000px_+_12em)]:', 'min-[calc(1000px+12em)]:'], |
149 |
| - ['min-[calc(1000px_+12em)]:', 'min-[calc(1000px+12em)]:'], |
150 |
| - ['min-[calc(1000px+_12em)]:', 'min-[calc(1000px+12em)]:'], |
151 |
| - ['min-[calc(1000px___+___12em)]:', 'min-[calc(1000px+12em)]:'], |
152 |
| - |
153 |
| - ['peer-[&_p]:', 'peer-[&_p]:'], |
154 |
| - ['peer-[&_p]:hover:', 'peer-[&_p]:hover:'], |
155 |
| - ['hover:peer-[&_p]:', 'hover:peer-[&_p]:'], |
156 |
| - ['hover:peer-[&_p]:focus:', 'hover:peer-[&_p]:focus:'], |
157 |
| - ['peer-[&:hover]:peer-[&_p]:', 'peer-[&:hover]:peer-[&_p]:'], |
158 |
| - |
159 |
| - ['[p]:', '[p]:'], |
160 |
| - ['[_p_]:', '[p]:'], |
161 |
| - ['has-[p]:', 'has-[p]:'], |
162 |
| - ['has-[_p_]:', 'has-[p]:'], |
163 |
| - |
164 |
| - // Simplify `&:is(p)` to `p` |
165 |
| - ['[&:is(p)]:', '[p]:'], |
166 |
| - ['[&:is(_p_)]:', '[p]:'], |
167 |
| - ['has-[&:is(p)]:', 'has-[p]:'], |
168 |
| - ['has-[&:is(_p_)]:', 'has-[p]:'], |
169 |
| - |
170 |
| - // Handle special `@` variants. These shouldn't be printed as `@-` |
171 |
| - ['@xl:', '@xl:'], |
172 |
| - ['@[123px]:', '@[123px]:'], |
173 |
| -] |
174 |
| - |
175 |
| -let combinations: [string, string][] = [] |
176 |
| - |
177 |
| -for (let [inputVariant, outputVariant] of variants) { |
178 |
| - for (let [inputCandidate, outputCandidate] of candidates) { |
179 |
| - combinations.push([`${inputVariant}${inputCandidate}`, `${outputVariant}${outputCandidate}`]) |
180 |
| - } |
181 |
| -} |
182 |
| - |
183 |
| -describe('printCandidate()', () => { |
184 |
| - test.each(combinations)('%s -> %s', async (candidate: string, result: string) => { |
185 |
| - let designSystem = await __unstable__loadDesignSystem('@import "tailwindcss";', { |
186 |
| - base: __dirname, |
187 |
| - }) |
188 |
| - |
189 |
| - let candidates = designSystem.parseCandidate(candidate) |
190 |
| - |
191 |
| - // Sometimes we will have a functional and a static candidate for the same |
192 |
| - // raw input string (e.g. `-inset-full`). Dedupe in this case. |
193 |
| - let cleaned = new Set([...candidates].map((c) => designSystem.printCandidate(c))) |
194 |
| - |
195 |
| - expect([...cleaned]).toEqual([result]) |
196 |
| - }) |
197 |
| -}) |
0 commit comments