-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest.js
99 lines (85 loc) · 2.16 KB
/
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
const cssMatcher = require('jest-matcher-css')
const plugin = require('./index')
const { run } = require('../../testing/run')
expect.extend({
toMatchCss: cssMatcher,
})
it('should generate the animate classes', () => {
const config = {
content: [
{
raw: String.raw`
<ul class="stagger-fade-left stagger-interval-200 stagger-delay-200">
<li class="duration-500">1</li>
<li class="duration-500">2</li>
<li class="duration-500">3</li>
</ul>
`,
},
],
theme: {
animate: {
triggerClass: '-observed',
staggerDelay: {
'200': '200ms',
},
staggerInterval: {
'200': '200ms',
},
maxItemIntervalSupport: 5,
animations: {
'fade-left': {
from: {
transform: 'translateX(-20px)',
opacity: 0,
},
to: {
transform: 'translateX(0)',
opacity: 1,
},
},
},
},
},
}
const output = String.raw`
.duration-500 {
transition-duration: 500ms;
}
.animate-fade-left:not(.-observed), .stagger-fade-left:not(.-observed) > * {
transform: translateX(-20px);
opacity: 0;
}
.animate-fade-left.-observed,.stagger-fade-left.-observed > * {
transform: translateX(0);
opacity: 1;
}
.stagger-interval-200 > * {
--stagger-delay: 0s;
transition-delay: calc(var(--animate-index) * 200ms + var(--stagger-delay));
}
.stagger-delay-200 > * {
--stagger-delay: 200ms;
}
[class*="stagger"] > *:nth-child(1) {
--animate-index: 1;
}
[class*="stagger"] > *:nth-child(2) {
--animate-index: 2;
}
[class*="stagger"] > *:nth-child(3) {
--animate-index: 3;
}
[class*="stagger"] > *:nth-child(4) {
--animate-index: 4;
}
[class*="stagger"] > *:nth-child(5) {
--animate-index: 5;
}
`
expect.assertions(2)
return run(plugin, config).then((result) => {
expect(result.warnings().length).toBe(0)
expect(result.css).toMatchCss(output)
})
})