This repository was archived by the owner on Dec 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgradient.test.js
129 lines (124 loc) · 4.53 KB
/
gradient.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
const expectAll = require('../utils/expect-all');
describe('CSS Type: <gradient>', () => {
// Test valid values
expectAll([
['repeating-linear-gradient(to right, rgba(20, 3, 4, 0.4) 10% 20%, #3f87a6, #fff 3em)', {
type: 'gradient',
repeating: true,
variant: 'linear',
value: {
type: 'linear',
modifier: {
type: 'side',
value: ['right']
},
stops: [
{
type: 'color-stop',
color: {
type: 'color',
format: 'rgba',
value: [
{type: 'number', value: 20},
{type: 'number', value: 3},
{type: 'number', value: 4},
{type: 'number', value: 0.4}
]
},
range: [
{type: 'percentage', value: 10},
{type: 'percentage', value: 20}
]
},
{
type: 'color-stop',
color: {type: 'color', format: 'hex', value: '3f87a6'},
range: null
},
{
type: 'color-stop',
color: {type: 'color', format: 'hex', value: 'fff'},
range: [{type: 'length', unit: 'em', value: 3}]
}
]
}
}],
['radial-gradient(farthest-corner at 40px 40px, #f35 0%, #43e 100%)', {
type: 'gradient',
repeating: false,
variant: 'radial',
value: {
type: 'radial',
modifier: 'farthest-corner',
position: {
type: 'position',
value: [
{type: 'length', unit: 'px', value: 40},
{type: 'length', unit: 'px', value: 40}
]
},
stops: [
{
type: 'color-stop',
color: {type: 'color', format: 'hex', value: 'f35'},
range: [{type: 'percentage', value: 0}]
},
{
type: 'color-stop',
color: {type: 'color', format: 'hex', value: '43e'},
range: [{type: 'percentage', value: 100}]
}
]
}
}],
['conic-gradient(from 0.25turn at 50% 30%, #f69d3c, 10deg, #ebf8e1 10deg 20deg)', {
type: 'gradient',
repeating: false,
variant: 'conic',
value: {
type: 'conic',
angle: {
type: 'angle',
unit: 'turn',
value: 0.25
},
position: {
type: 'position',
value: [
{type: 'percentage', value: 50},
{type: 'percentage', value: 30}
]
},
stops: [
{
type: 'color-stop',
color: {type: 'color', format: 'hex', value: 'f69d3c'},
range: null
},
{
type: 'color-stop',
color: null,
range: [
{type: 'angle', unit: 'deg', value: 10}
]
},
{
type: 'color-stop',
color: {type: 'color', format: 'hex', value: 'ebf8e1'},
range: [
{type: 'angle', unit: 'deg', value: 10},
{type: 'angle', unit: 'deg', value: 20}
]
}
]
}
}]
]);
// Test invalid values
expectAll([
'conic-gradient(from 0.25turn at 30deg 30%, #f69d3c, 10deg, #ebf8e1 10deg 20deg)',
'linear-gradient(to right)',
'linear-gradient(to right, rgba(20, 3, 4, 0.4) 10% 20% 20%)',
'radial-gradient(farthest-corner at 40px 40px, #f35)'
]);
});