-
Notifications
You must be signed in to change notification settings - Fork 4k
/
animation.test.js
131 lines (118 loc) · 3.16 KB
/
animation.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import postcss from 'postcss'
import processPlugins from '../../src/util/processPlugins'
import plugin from '../../src/plugins/animation'
function css(nodes) {
return postcss.root({ nodes }).toString()
}
test('defining animation and keyframes', () => {
const config = {
theme: {
animation: {
none: 'none',
spin: 'spin 1s linear infinite',
ping: 'ping 1s cubic-bezier(0, 0, 0.2, 1) infinite',
},
keyframes: {
spin: { to: { transform: 'rotate(360deg)' } },
ping: { '75%, 100%': { transform: 'scale(2)', opacity: '0' } },
},
},
variants: {
animation: [],
},
}
const { utilities } = processPlugins([plugin()], config)
expect(css(utilities)).toMatchCss(`
@layer utilities {
@variants {
@keyframes spin {
to { transform: rotate(360deg); }
}
@keyframes ping {
75%, 100% { transform: scale(2); opacity: 0; }
}
}
}
@layer utilities {
@variants {
.animate-none { animation: none; }
.animate-spin { animation: spin 1s linear infinite; }
.animate-ping { animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite; }
}
}
`)
})
test('defining animation and keyframes with prefix', () => {
const config = {
prefix: 'tw-',
theme: {
animation: {
none: 'none',
spin: 'spin 1s linear infinite',
ping: 'ping 1s cubic-bezier(0, 0, 0.2, 1) infinite',
},
keyframes: {
spin: { to: { transform: 'rotate(360deg)' } },
ping: { '75%, 100%': { transform: 'scale(2)', opacity: '0' } },
},
},
variants: {
animation: [],
},
}
const { utilities } = processPlugins([plugin()], config)
expect(css(utilities)).toMatchCss(`
@layer utilities {
@variants {
@keyframes tw-spin {
to { transform: rotate(360deg); }
}
@keyframes tw-ping {
75%, 100% { transform: scale(2); opacity: 0; }
}
}
}
@layer utilities {
@variants {
.tw-animate-none { animation: none; }
.tw-animate-spin { animation: tw-spin 1s linear infinite; }
.tw-animate-ping { animation: tw-ping 1s cubic-bezier(0, 0, 0.2, 1) infinite; }
}
}
`)
})
test('defining animation and keyframes with prefix (skip undefined animations)', () => {
const config = {
prefix: 'tw-',
theme: {
animation: {
none: 'none',
spin: 'spin 1s linear infinite',
ping: 'ping 1s cubic-bezier(0, 0, 0.2, 1) infinite',
},
keyframes: {
spin: { to: { transform: 'rotate(360deg)' } },
},
},
variants: {
animation: [],
},
}
const { utilities } = processPlugins([plugin()], config)
expect(css(utilities)).toMatchCss(`
@layer utilities {
@variants {
@keyframes tw-spin {
to { transform: rotate(360deg); }
}
}
}
@layer utilities {
@variants {
.tw-animate-none { animation: none; }
.tw-animate-spin { animation: tw-spin 1s linear infinite; }
.tw-animate-ping { animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite; }
}
}
`)
})