Skip to content

Commit f0e90a9

Browse files
committed
feat: add vitest
1 parent df4de96 commit f0e90a9

File tree

6 files changed

+1535
-4
lines changed

6 files changed

+1535
-4
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"node": "^18.12.0 || ^20.9.0 || >=22.0"
2828
},
2929
"scripts": {
30+
"test": "vitest",
3031
"lint": "eslint .",
3132
"build:css": "tailwindcss -i fixtures/styles/tailwind.css -o fixtures/styles/output.css -w",
3233
"build": "pnpm -r build",
@@ -48,6 +49,7 @@
4849
"simple-git-hooks": "^2.11.1",
4950
"tailwindcss": "^3.4.7",
5051
"typescript": "~5.3.3",
51-
"unbuild": "^2.0.0"
52+
"unbuild": "^2.0.0",
53+
"vitest": "^2.0.5"
5254
}
5355
}
Lines changed: 321 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`color-preset > should get all configs 1`] = `
4+
{
5+
"content": [],
6+
"theme": {
7+
"extend": {
8+
"backgroundImage": {
9+
"van-gradient-orange": "linear-gradient(to right, #ffd01e, #ff8917)",
10+
"van-gradient-red": "linear-gradient(to right, #ff6034, #ee0a24)",
11+
},
12+
"colors": {
13+
"el-danger": {
14+
"3": "#f89898",
15+
"5": "#fab6b6",
16+
"7": "#fcd3d3",
17+
"8": "#fde2e2",
18+
"9": "#fef0f0",
19+
"DEFAULT": "#f56c6c",
20+
"dark": "#c45656",
21+
},
22+
"el-error": {
23+
"3": "#f89898",
24+
"5": "#fab6b6",
25+
"7": "#fcd3d3",
26+
"8": "#fde2e2",
27+
"9": "#fef0f0",
28+
"DEFAULT": "#f56c6c",
29+
"dark": "#c45656",
30+
},
31+
"el-info": {
32+
"3": "#b1b3b8",
33+
"5": "#c8c9cc",
34+
"7": "#dedfe0",
35+
"8": "#e9e9eb",
36+
"9": "#f4f4f5",
37+
"DEFAULT": "#909399",
38+
"dark": "#73767a",
39+
},
40+
"el-primary": {
41+
"3": "#79bbff",
42+
"5": "#a0cfff",
43+
"7": "#c6e2ff",
44+
"8": "#d9ecff",
45+
"9": "#ecf5ff",
46+
"DEFAULT": "#409eff",
47+
"dark": "#337ecc",
48+
},
49+
"el-success": {
50+
"3": "#95d475",
51+
"5": "#b3e19d",
52+
"7": "#d1edc4",
53+
"8": "#e1f3d8",
54+
"9": "#f0f9eb",
55+
"DEFAULT": "#67c23a",
56+
"dark": "#529b2e",
57+
},
58+
"el-warning": {
59+
"3": "#eebe77",
60+
"5": "#f3d19e",
61+
"7": "#f8e3c5",
62+
"8": "#faecd8",
63+
"9": "#fdf6ec",
64+
"DEFAULT": "#e6a23c",
65+
"dark": "#b88230",
66+
},
67+
"n-error": "#d03050",
68+
"n-gray": "#333639",
69+
"n-info": "#2080f0",
70+
"n-primary": "#18a058",
71+
"n-success": "#18a058",
72+
"n-warning": "#f0a020",
73+
"van-danger": "#ee0a24",
74+
"van-gray": {
75+
"1": "#f7f8fa",
76+
"2": "#f2f3f5",
77+
"3": "#ebedf0",
78+
"4": "#dcdee0",
79+
"5": "#c8c9cc",
80+
"6": "#969799",
81+
"7": "#646566",
82+
"8": "#323233",
83+
},
84+
"van-primary": "#1989fa",
85+
"van-success": "#07c160",
86+
"van-warning": {
87+
"DEFAULT": "#ff976a",
88+
"dark": "#ed6a0c",
89+
"light": "#fffbe8",
90+
},
91+
},
92+
},
93+
},
94+
}
95+
`;
96+
97+
exports[`color-preset > should get all configs 2`] = `
98+
{
99+
"content": [],
100+
"theme": {
101+
"extend": {
102+
"backgroundImage": {
103+
"van-gradient-orange": "linear-gradient(to right, #ffd01e, #ff8917)",
104+
"van-gradient-red": "linear-gradient(to right, #ff6034, #ee0a24)",
105+
},
106+
"colors": {
107+
"el-danger": {
108+
"3": "#f89898",
109+
"5": "#fab6b6",
110+
"7": "#fcd3d3",
111+
"8": "#fde2e2",
112+
"9": "#fef0f0",
113+
"DEFAULT": "#f56c6c",
114+
"dark": "#c45656",
115+
},
116+
"el-error": {
117+
"3": "#f89898",
118+
"5": "#fab6b6",
119+
"7": "#fcd3d3",
120+
"8": "#fde2e2",
121+
"9": "#fef0f0",
122+
"DEFAULT": "#f56c6c",
123+
"dark": "#c45656",
124+
},
125+
"el-info": {
126+
"3": "#b1b3b8",
127+
"5": "#c8c9cc",
128+
"7": "#dedfe0",
129+
"8": "#e9e9eb",
130+
"9": "#f4f4f5",
131+
"DEFAULT": "#909399",
132+
"dark": "#73767a",
133+
},
134+
"el-primary": {
135+
"3": "#79bbff",
136+
"5": "#a0cfff",
137+
"7": "#c6e2ff",
138+
"8": "#d9ecff",
139+
"9": "#ecf5ff",
140+
"DEFAULT": "#409eff",
141+
"dark": "#337ecc",
142+
},
143+
"el-success": {
144+
"3": "#95d475",
145+
"5": "#b3e19d",
146+
"7": "#d1edc4",
147+
"8": "#e1f3d8",
148+
"9": "#f0f9eb",
149+
"DEFAULT": "#67c23a",
150+
"dark": "#529b2e",
151+
},
152+
"el-warning": {
153+
"3": "#eebe77",
154+
"5": "#f3d19e",
155+
"7": "#f8e3c5",
156+
"8": "#faecd8",
157+
"9": "#fdf6ec",
158+
"DEFAULT": "#e6a23c",
159+
"dark": "#b88230",
160+
},
161+
"n-error": "#d03050",
162+
"n-gray": "#333639",
163+
"n-info": "#2080f0",
164+
"n-primary": "#18a058",
165+
"n-success": "#18a058",
166+
"n-warning": "#f0a020",
167+
"van-danger": "#ee0a24",
168+
"van-gray": {
169+
"1": "#f7f8fa",
170+
"2": "#f2f3f5",
171+
"3": "#ebedf0",
172+
"4": "#dcdee0",
173+
"5": "#c8c9cc",
174+
"6": "#969799",
175+
"7": "#646566",
176+
"8": "#323233",
177+
},
178+
"van-primary": "#1989fa",
179+
"van-success": "#07c160",
180+
"van-warning": {
181+
"DEFAULT": "#ff976a",
182+
"dark": "#ed6a0c",
183+
"light": "#fffbe8",
184+
},
185+
},
186+
},
187+
},
188+
}
189+
`;
190+
191+
exports[`color-preset > should get no config 1`] = `
192+
{
193+
"content": [],
194+
"theme": {
195+
"extend": {
196+
"backgroundImage": {},
197+
"colors": {},
198+
},
199+
},
200+
}
201+
`;
202+
203+
exports[`color-preset > should only get element config 1`] = `
204+
{
205+
"content": [],
206+
"theme": {
207+
"extend": {
208+
"backgroundImage": {},
209+
"colors": {
210+
"el-danger": {
211+
"3": "#f89898",
212+
"5": "#fab6b6",
213+
"7": "#fcd3d3",
214+
"8": "#fde2e2",
215+
"9": "#fef0f0",
216+
"DEFAULT": "#f56c6c",
217+
"dark": "#c45656",
218+
},
219+
"el-error": {
220+
"3": "#f89898",
221+
"5": "#fab6b6",
222+
"7": "#fcd3d3",
223+
"8": "#fde2e2",
224+
"9": "#fef0f0",
225+
"DEFAULT": "#f56c6c",
226+
"dark": "#c45656",
227+
},
228+
"el-info": {
229+
"3": "#b1b3b8",
230+
"5": "#c8c9cc",
231+
"7": "#dedfe0",
232+
"8": "#e9e9eb",
233+
"9": "#f4f4f5",
234+
"DEFAULT": "#909399",
235+
"dark": "#73767a",
236+
},
237+
"el-primary": {
238+
"3": "#79bbff",
239+
"5": "#a0cfff",
240+
"7": "#c6e2ff",
241+
"8": "#d9ecff",
242+
"9": "#ecf5ff",
243+
"DEFAULT": "#409eff",
244+
"dark": "#337ecc",
245+
},
246+
"el-success": {
247+
"3": "#95d475",
248+
"5": "#b3e19d",
249+
"7": "#d1edc4",
250+
"8": "#e1f3d8",
251+
"9": "#f0f9eb",
252+
"DEFAULT": "#67c23a",
253+
"dark": "#529b2e",
254+
},
255+
"el-warning": {
256+
"3": "#eebe77",
257+
"5": "#f3d19e",
258+
"7": "#f8e3c5",
259+
"8": "#faecd8",
260+
"9": "#fdf6ec",
261+
"DEFAULT": "#e6a23c",
262+
"dark": "#b88230",
263+
},
264+
},
265+
},
266+
},
267+
}
268+
`;
269+
270+
exports[`color-preset > should only get naive config 1`] = `
271+
{
272+
"content": [],
273+
"theme": {
274+
"extend": {
275+
"backgroundImage": {},
276+
"colors": {
277+
"n-error": "#d03050",
278+
"n-gray": "#333639",
279+
"n-info": "#2080f0",
280+
"n-primary": "#18a058",
281+
"n-success": "#18a058",
282+
"n-warning": "#f0a020",
283+
},
284+
},
285+
},
286+
}
287+
`;
288+
289+
exports[`color-preset > should only get vant config 1`] = `
290+
{
291+
"content": [],
292+
"theme": {
293+
"extend": {
294+
"backgroundImage": {
295+
"van-gradient-orange": "linear-gradient(to right, #ffd01e, #ff8917)",
296+
"van-gradient-red": "linear-gradient(to right, #ff6034, #ee0a24)",
297+
},
298+
"colors": {
299+
"van-danger": "#ee0a24",
300+
"van-gray": {
301+
"1": "#f7f8fa",
302+
"2": "#f2f3f5",
303+
"3": "#ebedf0",
304+
"4": "#dcdee0",
305+
"5": "#c8c9cc",
306+
"6": "#969799",
307+
"7": "#646566",
308+
"8": "#323233",
309+
},
310+
"van-primary": "#1989fa",
311+
"van-success": "#07c160",
312+
"van-warning": {
313+
"DEFAULT": "#ff976a",
314+
"dark": "#ed6a0c",
315+
"light": "#fffbe8",
316+
},
317+
},
318+
},
319+
},
320+
}
321+
`;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { describe, expect, it, test } from 'vitest'
2+
import colorPreset from '../src/index'
3+
4+
describe('color-preset', () => {
5+
it('should get no config', () => {
6+
expect(colorPreset(false)).toMatchSnapshot()
7+
})
8+
9+
it('should get all configs', () => {
10+
expect(colorPreset(true)).toMatchSnapshot()
11+
})
12+
13+
it('should only get element config', () => {
14+
expect(colorPreset({ element: true })).toMatchSnapshot()
15+
})
16+
17+
it('should only get naive config', () => {
18+
expect(colorPreset({ naive: true })).toMatchSnapshot()
19+
})
20+
21+
it('should only get vant config', () => {
22+
expect(colorPreset({ vant: true })).toMatchSnapshot()
23+
})
24+
25+
it('should get all configs', () => {
26+
expect(colorPreset({
27+
element: true,
28+
naive: true,
29+
vant: true,
30+
})).toMatchSnapshot()
31+
})
32+
})

0 commit comments

Comments
 (0)