/
space.test.js
96 lines (93 loc) · 3.65 KB
/
space.test.js
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import invokePlugin from '../util/invokePlugin'
import plugin from '../../src/plugins/space'
test('generating space utilities', () => {
const config = {
theme: {
space: {
0: '0',
1: '1px',
2: '2px',
4: '4px',
'-2': '-2px',
'-1': '-1px',
},
},
variants: {
space: ['responsive'],
},
}
const { utilities } = invokePlugin(plugin(), config)
expect(utilities).toEqual([
[
{
'.space-y-0 > :not([hidden]) ~ :not([hidden])': {
'--space-y-reverse': '0',
'margin-top': 'calc(0px * calc(1 - var(--space-y-reverse)))',
'margin-bottom': 'calc(0px * var(--space-y-reverse))',
},
'.space-x-0 > :not([hidden]) ~ :not([hidden])': {
'--space-x-reverse': '0',
'margin-inline-end': 'calc(0px * var(--space-x-reverse))',
'margin-inline-start': 'calc(0px * calc(1 - var(--space-x-reverse)))',
},
'.space-y-1 > :not([hidden]) ~ :not([hidden])': {
'--space-y-reverse': '0',
'margin-top': 'calc(1px * calc(1 - var(--space-y-reverse)))',
'margin-bottom': 'calc(1px * var(--space-y-reverse))',
},
'.space-x-1 > :not([hidden]) ~ :not([hidden])': {
'--space-x-reverse': '0',
'margin-inline-end': 'calc(1px * var(--space-x-reverse))',
'margin-inline-start': 'calc(1px * calc(1 - var(--space-x-reverse)))',
},
'.space-y-2 > :not([hidden]) ~ :not([hidden])': {
'--space-y-reverse': '0',
'margin-top': 'calc(2px * calc(1 - var(--space-y-reverse)))',
'margin-bottom': 'calc(2px * var(--space-y-reverse))',
},
'.space-x-2 > :not([hidden]) ~ :not([hidden])': {
'--space-x-reverse': '0',
'margin-inline-end': 'calc(2px * var(--space-x-reverse))',
'margin-inline-start': 'calc(2px * calc(1 - var(--space-x-reverse)))',
},
'.space-y-4 > :not([hidden]) ~ :not([hidden])': {
'--space-y-reverse': '0',
'margin-top': 'calc(4px * calc(1 - var(--space-y-reverse)))',
'margin-bottom': 'calc(4px * var(--space-y-reverse))',
},
'.space-x-4 > :not([hidden]) ~ :not([hidden])': {
'--space-x-reverse': '0',
'margin-inline-end': 'calc(4px * var(--space-x-reverse))',
'margin-inline-start': 'calc(4px * calc(1 - var(--space-x-reverse)))',
},
'.-space-y-2 > :not([hidden]) ~ :not([hidden])': {
'--space-y-reverse': '0',
'margin-top': 'calc(-2px * calc(1 - var(--space-y-reverse)))',
'margin-bottom': 'calc(-2px * var(--space-y-reverse))',
},
'.-space-x-2 > :not([hidden]) ~ :not([hidden])': {
'--space-x-reverse': '0',
'margin-inline-end': 'calc(-2px * var(--space-x-reverse))',
'margin-inline-start': 'calc(-2px * calc(1 - var(--space-x-reverse)))',
},
'.-space-y-1 > :not([hidden]) ~ :not([hidden])': {
'--space-y-reverse': '0',
'margin-top': 'calc(-1px * calc(1 - var(--space-y-reverse)))',
'margin-bottom': 'calc(-1px * var(--space-y-reverse))',
},
'.-space-x-1 > :not([hidden]) ~ :not([hidden])': {
'--space-x-reverse': '0',
'margin-inline-end': 'calc(-1px * var(--space-x-reverse))',
'margin-inline-start': 'calc(-1px * calc(1 - var(--space-x-reverse)))',
},
'.space-y-reverse > :not([hidden]) ~ :not([hidden])': {
'--space-y-reverse': '1',
},
'.space-x-reverse > :not([hidden]) ~ :not([hidden])': {
'--space-x-reverse': '1',
},
},
['responsive'],
],
])
})