-
-
Notifications
You must be signed in to change notification settings - Fork 180
/
resolve.test.ts
74 lines (68 loc) · 3.08 KB
/
resolve.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { Processor } from '../../src/lib';
import { resolve } from 'path';
const processor = new Processor(require(resolve('./test/assets/windi.plugin.config.js')));
describe('Resolve Tests', () => {
it('resolve variants', () => {
const processor = new Processor();
const screenVariants = [
'sm', '<sm', '@sm', '-sm', '+sm',
'md', '<md', '@md', '-md', '+md',
'lg', '<lg', '@lg', '-lg', '+lg',
'xl', '<xl', '@xl', '-xl', '+xl',
'2xl', '<2xl', '@2xl', '-2xl', '+2xl',
];
const stateVariants = [
'hover', 'focus', 'active',
'visited', 'link', 'target',
'focus-visible', 'focus-within', 'checked',
'not-checked', 'default', 'disabled',
'enabled', 'indeterminate', 'invalid',
'valid', 'optional', 'required',
'placeholder-shown', 'read-only', 'read-write',
'not-disabled', 'first-of-type', 'not-first-of-type',
'last-of-type', 'not-last-of-type', 'first',
'last', 'not-first', 'not-last',
'only-child', 'not-only-child', 'only-of-type',
'not-only-of-type', 'even', 'odd',
'even-of-type', 'odd-of-type', 'root',
'empty', 'before', 'after',
'first-letter', 'first-line', 'file-selector-button',
'file', 'selection', 'marker', 'svg',
'all', 'children', 'siblings',
'sibling', 'ltr', 'rtl',
'group-hover', 'group-focus', 'group-active',
'group-visited', 'motion-safe', 'motion-reduce',
];
const themeVariants = ['@dark', '@light', '.dark', '.light', 'dark', 'light'];
const orientationVariants = ['portrait', 'landscape'];
expect(Object.keys(processor.resolveVariants())).toEqual([...screenVariants, ...themeVariants, ...stateVariants, ...orientationVariants]);
expect(Object.keys(processor.resolveVariants('orientation'))).toEqual(orientationVariants);
expect(Object.keys(processor.resolveVariants('screen'))).toEqual(screenVariants);
expect(Object.keys(processor.resolveVariants('theme'))).toEqual(themeVariants);
expect(Object.keys(processor.resolveVariants('state'))).toEqual(stateVariants);
});
it('resolve static utilities', () => {
expect(Object.keys(processor.resolveStaticUtilities(false)).length).toEqual(351);
expect(Object.keys(processor.resolveStaticUtilities(true)).length).toEqual(360);
expect(Object.keys(processor.resolveStaticUtilities(true)).length).toEqual(360);
});
it('resolve dynamic utilities', () => {
expect(Object.keys(processor.resolveDynamicUtilities(false))).toMatchSnapshot('without-plugins');
expect(Object.keys(processor.resolveDynamicUtilities(true))).toMatchSnapshot('with-plugins');
});
it('get corePlugins', () => {
const processor = new Processor();
expect(processor.config('corePlugins')).toMatchSnapshot('list');
const processor2 = new Processor({
corePlugins: ['container', 'cursor'],
});
expect(processor2.config('corePlugins')).toMatchSnapshot('list2');
const processor3 = new Processor({
corePlugins: {
container: false,
cursor: false,
},
});
expect(processor3.config('corePlugins')).toMatchSnapshot('list3');
});
});