@stylexjs/stylex 0.2.0-beta.21 → 0.2.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -43
- package/lib/StyleXCSSTypes.js +1 -1
- package/lib/StyleXSheet.js +18 -19
- package/lib/StyleXTypes.d.ts +26 -51
- package/lib/StyleXTypes.js +1 -1
- package/lib/StyleXTypes.js.flow +16 -16
- package/lib/native/CSSCustomPropertyValue.js +1 -1
- package/lib/native/CSSLengthUnitValue.js +7 -7
- package/lib/native/CSSMediaQuery.js +4 -4
- package/lib/native/SpreadOptions.d.ts +1 -0
- package/lib/native/SpreadOptions.js.flow +1 -0
- package/lib/native/__tests__/__snapshots__/stylex-test.js.snap +16 -0
- package/lib/native/__tests__/parseTimeValue-test.js +3 -3
- package/lib/native/__tests__/stylex-css-var-test.js +60 -60
- package/lib/native/__tests__/stylex-test.js +306 -289
- package/lib/native/fixContentBox.js +7 -7
- package/lib/native/flattenStyle.js +1 -1
- package/lib/native/parseShadow.js +4 -4
- package/lib/native/parseTimeValue.js +4 -4
- package/lib/native/stylex.d.ts +15 -5
- package/lib/native/stylex.js +120 -89
- package/lib/native/stylex.js.flow +19 -5
- package/lib/stylex.d.ts +31 -22
- package/lib/stylex.js +81 -59
- package/lib/stylex.js.flow +32 -27
- package/package.json +2 -2
|
@@ -3,125 +3,126 @@
|
|
|
3
3
|
var _stylex = require("../stylex");
|
|
4
4
|
const mockOptions = {
|
|
5
5
|
customProperties: {},
|
|
6
|
+
hover: false,
|
|
6
7
|
viewportHeight: 600,
|
|
7
8
|
viewportWidth: 320
|
|
8
9
|
};
|
|
9
|
-
describe(
|
|
10
|
+
describe('styles', () => {
|
|
10
11
|
beforeEach(() => {
|
|
11
|
-
jest.spyOn(console,
|
|
12
|
+
jest.spyOn(console, 'warn');
|
|
12
13
|
console.warn.mockImplementation(() => {});
|
|
13
14
|
});
|
|
14
15
|
afterEach(() => {
|
|
15
16
|
console.warn.mockRestore();
|
|
16
17
|
});
|
|
17
|
-
test(
|
|
18
|
+
test('animation-delay', () => {
|
|
18
19
|
const styles = _stylex.stylex.create({
|
|
19
20
|
root: {
|
|
20
|
-
animationDelay:
|
|
21
|
+
animationDelay: '0.3s'
|
|
21
22
|
}
|
|
22
23
|
});
|
|
23
|
-
expect(_stylex.stylex.
|
|
24
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot();
|
|
24
25
|
});
|
|
25
|
-
test(
|
|
26
|
+
test('animation-duration', () => {
|
|
26
27
|
const styles = _stylex.stylex.create({
|
|
27
28
|
root: {
|
|
28
|
-
animationDuration:
|
|
29
|
+
animationDuration: '0.5s'
|
|
29
30
|
}
|
|
30
31
|
});
|
|
31
|
-
expect(_stylex.stylex.
|
|
32
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot();
|
|
32
33
|
});
|
|
33
|
-
test(
|
|
34
|
+
test('background-image', () => {
|
|
34
35
|
const styles = _stylex.stylex.create({
|
|
35
36
|
root: {
|
|
36
|
-
backgroundImage:
|
|
37
|
+
backgroundImage: 'url(https://placehold.it/300/300'
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
|
-
_stylex.stylex.
|
|
40
|
+
_stylex.stylex.props(styles.root, mockOptions);
|
|
40
41
|
expect(console.warn).toHaveBeenCalled();
|
|
41
42
|
});
|
|
42
|
-
test(
|
|
43
|
+
test('border-style', () => {
|
|
43
44
|
const styles = _stylex.stylex.create({
|
|
44
45
|
root: {
|
|
45
|
-
borderStyle:
|
|
46
|
+
borderStyle: 'none',
|
|
46
47
|
borderWidth: 10
|
|
47
48
|
},
|
|
48
49
|
override: {
|
|
49
|
-
borderStyle:
|
|
50
|
+
borderStyle: 'solid'
|
|
50
51
|
}
|
|
51
52
|
});
|
|
52
|
-
expect(_stylex.stylex.
|
|
53
|
-
expect(_stylex.stylex.
|
|
53
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot();
|
|
54
|
+
expect(_stylex.stylex.props([styles.root, styles.override], mockOptions)).toMatchSnapshot();
|
|
54
55
|
});
|
|
55
|
-
test(
|
|
56
|
+
test('box-shadow', () => {
|
|
56
57
|
const styles = _stylex.stylex.create({
|
|
57
58
|
root: {
|
|
58
|
-
boxShadow:
|
|
59
|
+
boxShadow: '1px 2px 3px 4px red'
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
|
-
expect(_stylex.stylex.
|
|
62
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot();
|
|
62
63
|
const styles2 = _stylex.stylex.create({
|
|
63
64
|
root: {
|
|
64
|
-
boxShadow:
|
|
65
|
+
boxShadow: '1px 2px 3px 4px red, 2px 3px 4px 5px blue'
|
|
65
66
|
}
|
|
66
67
|
});
|
|
67
|
-
_stylex.stylex.
|
|
68
|
+
_stylex.stylex.props(styles2.root, mockOptions);
|
|
68
69
|
expect(console.warn).toHaveBeenCalledTimes(1);
|
|
69
70
|
const styles3 = _stylex.stylex.create({
|
|
70
71
|
root: {
|
|
71
|
-
boxShadow:
|
|
72
|
+
boxShadow: 'inset 1px 2px 3px 4px red'
|
|
72
73
|
}
|
|
73
74
|
});
|
|
74
|
-
_stylex.stylex.
|
|
75
|
+
_stylex.stylex.props(styles3.root, mockOptions);
|
|
75
76
|
expect(console.warn).toHaveBeenCalledTimes(2);
|
|
76
77
|
});
|
|
77
|
-
test(
|
|
78
|
+
test('box-sizing: content-box', () => {
|
|
78
79
|
const styles = _stylex.stylex.create({
|
|
79
80
|
width: {
|
|
80
|
-
boxSizing:
|
|
81
|
+
boxSizing: 'content-box',
|
|
81
82
|
borderWidth: 2,
|
|
82
83
|
padding: 10,
|
|
83
84
|
width: 100,
|
|
84
|
-
overflow:
|
|
85
|
+
overflow: 'hidden'
|
|
85
86
|
},
|
|
86
87
|
height: {
|
|
87
|
-
boxSizing:
|
|
88
|
+
boxSizing: 'content-box',
|
|
88
89
|
borderWidth: 2,
|
|
89
90
|
padding: 10,
|
|
90
91
|
height: 50
|
|
91
92
|
},
|
|
92
93
|
maxWidth: {
|
|
93
|
-
boxSizing:
|
|
94
|
+
boxSizing: 'content-box',
|
|
94
95
|
borderWidth: 2,
|
|
95
96
|
padding: 10,
|
|
96
97
|
maxWidth: 100
|
|
97
98
|
},
|
|
98
99
|
minWidth: {
|
|
99
|
-
boxSizing:
|
|
100
|
+
boxSizing: 'content-box',
|
|
100
101
|
borderWidth: 2,
|
|
101
102
|
padding: 10,
|
|
102
103
|
minWidth: 100
|
|
103
104
|
},
|
|
104
105
|
maxHeight: {
|
|
105
|
-
boxSizing:
|
|
106
|
+
boxSizing: 'content-box',
|
|
106
107
|
borderWidth: 2,
|
|
107
108
|
padding: 10,
|
|
108
109
|
maxHeight: 50
|
|
109
110
|
},
|
|
110
111
|
minHeight: {
|
|
111
|
-
boxSizing:
|
|
112
|
+
boxSizing: 'content-box',
|
|
112
113
|
borderWidth: 2,
|
|
113
114
|
padding: 10,
|
|
114
115
|
minHeight: 50
|
|
115
116
|
},
|
|
116
117
|
units: {
|
|
117
|
-
boxSizing:
|
|
118
|
+
boxSizing: 'content-box',
|
|
118
119
|
borderWidth: 2,
|
|
119
|
-
padding:
|
|
120
|
-
width:
|
|
120
|
+
padding: '1rem',
|
|
121
|
+
width: '100px',
|
|
121
122
|
height: 50
|
|
122
123
|
},
|
|
123
124
|
allDifferent: {
|
|
124
|
-
boxSizing:
|
|
125
|
+
boxSizing: 'content-box',
|
|
125
126
|
borderTopWidth: 1,
|
|
126
127
|
borderRightWidth: 2,
|
|
127
128
|
borderBottomWidth: 3,
|
|
@@ -134,193 +135,193 @@ describe("styles", () => {
|
|
|
134
135
|
height: 100
|
|
135
136
|
},
|
|
136
137
|
auto: {
|
|
137
|
-
boxSizing:
|
|
138
|
+
boxSizing: 'content-box',
|
|
138
139
|
borderWidth: 2,
|
|
139
140
|
padding: 10,
|
|
140
141
|
height: 50,
|
|
141
|
-
width:
|
|
142
|
+
width: 'auto'
|
|
142
143
|
}
|
|
143
144
|
});
|
|
144
|
-
expect(_stylex.stylex.
|
|
145
|
-
expect(_stylex.stylex.
|
|
146
|
-
expect(_stylex.stylex.
|
|
147
|
-
expect(_stylex.stylex.
|
|
148
|
-
expect(_stylex.stylex.
|
|
149
|
-
expect(_stylex.stylex.
|
|
150
|
-
expect(_stylex.stylex.
|
|
151
|
-
expect(_stylex.stylex.
|
|
152
|
-
expect(_stylex.stylex.
|
|
145
|
+
expect(_stylex.stylex.props(styles.width, mockOptions)).toMatchSnapshot('width');
|
|
146
|
+
expect(_stylex.stylex.props(styles.height, mockOptions)).toMatchSnapshot('height');
|
|
147
|
+
expect(_stylex.stylex.props(styles.maxWidth, mockOptions)).toMatchSnapshot('maxWidth');
|
|
148
|
+
expect(_stylex.stylex.props(styles.maxHeight, mockOptions)).toMatchSnapshot('maxHeight');
|
|
149
|
+
expect(_stylex.stylex.props(styles.minWidth, mockOptions)).toMatchSnapshot('minWidth');
|
|
150
|
+
expect(_stylex.stylex.props(styles.minHeight, mockOptions)).toMatchSnapshot('minHeight');
|
|
151
|
+
expect(_stylex.stylex.props(styles.units, mockOptions)).toMatchSnapshot('units');
|
|
152
|
+
expect(_stylex.stylex.props(styles.allDifferent, mockOptions)).toMatchSnapshot('allDifferent');
|
|
153
|
+
expect(_stylex.stylex.props(styles.auto, mockOptions)).toMatchSnapshot('auto');
|
|
153
154
|
});
|
|
154
|
-
test(
|
|
155
|
+
test('direction', () => {
|
|
155
156
|
const styles = _stylex.stylex.create({
|
|
156
157
|
root: {
|
|
157
|
-
direction:
|
|
158
|
+
direction: 'ltr'
|
|
158
159
|
}
|
|
159
160
|
});
|
|
160
|
-
expect(_stylex.stylex.
|
|
161
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot();
|
|
161
162
|
const styles2 = _stylex.stylex.create({
|
|
162
163
|
root: {
|
|
163
|
-
direction:
|
|
164
|
+
direction: 'rtl'
|
|
164
165
|
}
|
|
165
166
|
});
|
|
166
|
-
expect(_stylex.stylex.
|
|
167
|
+
expect(_stylex.stylex.props(styles2.root, mockOptions)).toMatchSnapshot();
|
|
167
168
|
});
|
|
168
|
-
test(
|
|
169
|
+
test('font-size', () => {
|
|
169
170
|
const styles = _stylex.stylex.create({
|
|
170
171
|
root: {
|
|
171
|
-
fontSize:
|
|
172
|
+
fontSize: '2.5rem'
|
|
172
173
|
}
|
|
173
174
|
});
|
|
174
|
-
expect(_stylex.stylex.
|
|
175
|
-
expect(_stylex.stylex.
|
|
175
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot('default');
|
|
176
|
+
expect(_stylex.stylex.props(styles.root, {
|
|
176
177
|
...mockOptions,
|
|
177
178
|
fontScale: 2
|
|
178
|
-
})).toMatchSnapshot(
|
|
179
|
+
})).toMatchSnapshot('fontScale:2');
|
|
179
180
|
});
|
|
180
|
-
test(
|
|
181
|
+
test('font-variant', () => {
|
|
181
182
|
const styles = _stylex.stylex.create({
|
|
182
183
|
root: {
|
|
183
|
-
fontVariant:
|
|
184
|
+
fontVariant: 'common-ligatures small-caps'
|
|
184
185
|
}
|
|
185
186
|
});
|
|
186
|
-
expect(_stylex.stylex.
|
|
187
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot();
|
|
187
188
|
});
|
|
188
|
-
test(
|
|
189
|
+
test('font-weight', () => {
|
|
189
190
|
const styles = _stylex.stylex.create({
|
|
190
191
|
root: {
|
|
191
192
|
fontWeight: 900
|
|
192
193
|
}
|
|
193
194
|
});
|
|
194
|
-
expect(_stylex.stylex.
|
|
195
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot();
|
|
195
196
|
const styles2 = _stylex.stylex.create({
|
|
196
197
|
root: {
|
|
197
|
-
fontWeight:
|
|
198
|
+
fontWeight: 'bold'
|
|
198
199
|
}
|
|
199
200
|
});
|
|
200
|
-
expect(_stylex.stylex.
|
|
201
|
+
expect(_stylex.stylex.props(styles2.root, mockOptions)).toMatchSnapshot();
|
|
201
202
|
});
|
|
202
|
-
test(
|
|
203
|
+
test('line-clamp', () => {
|
|
203
204
|
const styles = _stylex.stylex.create({
|
|
204
205
|
root: {
|
|
205
206
|
lineClamp: 3
|
|
206
207
|
}
|
|
207
208
|
});
|
|
208
|
-
expect(_stylex.stylex.
|
|
209
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot();
|
|
209
210
|
});
|
|
210
|
-
test(
|
|
211
|
+
test('line-height', () => {
|
|
211
212
|
const styles = _stylex.stylex.create({
|
|
212
213
|
numeric: {
|
|
213
214
|
lineHeight: 1.5
|
|
214
215
|
},
|
|
215
216
|
string: {
|
|
216
|
-
lineHeight:
|
|
217
|
+
lineHeight: '1.5'
|
|
217
218
|
},
|
|
218
219
|
rem: {
|
|
219
|
-
lineHeight:
|
|
220
|
+
lineHeight: '1.5rem'
|
|
220
221
|
},
|
|
221
222
|
px: {
|
|
222
|
-
lineHeight:
|
|
223
|
+
lineHeight: '24px'
|
|
223
224
|
}
|
|
224
225
|
});
|
|
225
|
-
expect(_stylex.stylex.
|
|
226
|
-
expect(_stylex.stylex.
|
|
227
|
-
expect(_stylex.stylex.
|
|
228
|
-
expect(_stylex.stylex.
|
|
226
|
+
expect(_stylex.stylex.props(styles.numeric, mockOptions)).toMatchSnapshot('unitless number');
|
|
227
|
+
expect(_stylex.stylex.props(styles.string, mockOptions)).toMatchSnapshot('unitless string');
|
|
228
|
+
expect(_stylex.stylex.props(styles.rem, mockOptions)).toMatchSnapshot('rem');
|
|
229
|
+
expect(_stylex.stylex.props(styles.px, mockOptions)).toMatchSnapshot('px');
|
|
229
230
|
});
|
|
230
|
-
test(
|
|
231
|
+
test('object-fit', () => {
|
|
231
232
|
const styles = _stylex.stylex.create({
|
|
232
233
|
contain: {
|
|
233
|
-
objectFit:
|
|
234
|
+
objectFit: 'contain'
|
|
234
235
|
},
|
|
235
236
|
cover: {
|
|
236
|
-
objectFit:
|
|
237
|
+
objectFit: 'cover'
|
|
237
238
|
},
|
|
238
239
|
fill: {
|
|
239
|
-
objectFit:
|
|
240
|
+
objectFit: 'fill'
|
|
240
241
|
},
|
|
241
242
|
scaleDown: {
|
|
242
|
-
objectFit:
|
|
243
|
+
objectFit: 'scale-down'
|
|
243
244
|
},
|
|
244
245
|
none: {
|
|
245
|
-
objectFit:
|
|
246
|
+
objectFit: 'none'
|
|
246
247
|
}
|
|
247
248
|
});
|
|
248
|
-
expect(_stylex.stylex.
|
|
249
|
-
expect(_stylex.stylex.
|
|
250
|
-
expect(_stylex.stylex.
|
|
251
|
-
expect(_stylex.stylex.
|
|
252
|
-
expect(_stylex.stylex.
|
|
249
|
+
expect(_stylex.stylex.props(styles.contain, mockOptions)).toMatchSnapshot('contain');
|
|
250
|
+
expect(_stylex.stylex.props(styles.cover, mockOptions)).toMatchSnapshot('contain');
|
|
251
|
+
expect(_stylex.stylex.props(styles.fill, mockOptions)).toMatchSnapshot('fill');
|
|
252
|
+
expect(_stylex.stylex.props(styles.scaleDown, mockOptions)).toMatchSnapshot('scaleDown');
|
|
253
|
+
expect(_stylex.stylex.props(styles.none, mockOptions)).toMatchSnapshot('none');
|
|
253
254
|
});
|
|
254
|
-
test(
|
|
255
|
+
test('pointer-events', () => {
|
|
255
256
|
const styles = _stylex.stylex.create({
|
|
256
257
|
root: {
|
|
257
|
-
pointerEvents:
|
|
258
|
+
pointerEvents: 'none'
|
|
258
259
|
}
|
|
259
260
|
});
|
|
260
|
-
expect(_stylex.stylex.
|
|
261
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot();
|
|
261
262
|
});
|
|
262
|
-
test(
|
|
263
|
+
test('position', () => {
|
|
263
264
|
const styles = _stylex.stylex.create({
|
|
264
265
|
static: {
|
|
265
|
-
position:
|
|
266
|
+
position: 'static'
|
|
266
267
|
},
|
|
267
268
|
relative: {
|
|
268
|
-
position:
|
|
269
|
+
position: 'relative'
|
|
269
270
|
},
|
|
270
271
|
absolute: {
|
|
271
|
-
position:
|
|
272
|
+
position: 'absolute'
|
|
272
273
|
},
|
|
273
274
|
fixed: {
|
|
274
|
-
position:
|
|
275
|
+
position: 'fixed'
|
|
275
276
|
},
|
|
276
277
|
sticky: {
|
|
277
|
-
position:
|
|
278
|
+
position: 'sticky'
|
|
278
279
|
}
|
|
279
280
|
});
|
|
280
|
-
expect(_stylex.stylex.
|
|
281
|
-
expect(_stylex.stylex.
|
|
282
|
-
expect(_stylex.stylex.
|
|
283
|
-
expect(_stylex.stylex.
|
|
284
|
-
expect(_stylex.stylex.
|
|
281
|
+
expect(_stylex.stylex.props(styles.static, mockOptions)).toMatchSnapshot('static');
|
|
282
|
+
expect(_stylex.stylex.props(styles.relative, mockOptions)).toMatchSnapshot('relative');
|
|
283
|
+
expect(_stylex.stylex.props(styles.absolute, mockOptions)).toMatchSnapshot('absolute');
|
|
284
|
+
expect(_stylex.stylex.props(styles.fixed, mockOptions)).toMatchSnapshot('fixed');
|
|
285
|
+
expect(_stylex.stylex.props(styles.sticky, mockOptions)).toMatchSnapshot('sticky');
|
|
285
286
|
expect(console.warn).toHaveBeenCalledTimes(3);
|
|
286
287
|
});
|
|
287
|
-
test(
|
|
288
|
+
test('text-shadow', () => {
|
|
288
289
|
const styles = _stylex.stylex.create({
|
|
289
290
|
root: {
|
|
290
|
-
textShadow:
|
|
291
|
+
textShadow: '1px 2px 3px red'
|
|
291
292
|
}
|
|
292
293
|
});
|
|
293
|
-
expect(_stylex.stylex.
|
|
294
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot();
|
|
294
295
|
const styles2 = _stylex.stylex.create({
|
|
295
296
|
root: {
|
|
296
|
-
textShadow:
|
|
297
|
+
textShadow: '1px 2px 3px red, 2px 3px 4px blue'
|
|
297
298
|
}
|
|
298
299
|
});
|
|
299
|
-
expect(_stylex.stylex.
|
|
300
|
+
expect(_stylex.stylex.props(styles2.root, mockOptions)).toMatchSnapshot();
|
|
300
301
|
expect(console.warn).toHaveBeenCalledTimes(1);
|
|
301
302
|
});
|
|
302
|
-
test(
|
|
303
|
+
test('transform', () => {
|
|
303
304
|
const styles = _stylex.stylex.create({
|
|
304
305
|
none: {
|
|
305
|
-
transform:
|
|
306
|
+
transform: 'none'
|
|
306
307
|
},
|
|
307
308
|
matrix: {
|
|
308
|
-
transform:
|
|
309
|
+
transform: 'matrix(0.1, 1, -0.3, 1, 0, 0)'
|
|
309
310
|
},
|
|
310
311
|
perspective: {
|
|
311
|
-
transform:
|
|
312
|
+
transform: 'perspective(10px)'
|
|
312
313
|
},
|
|
313
314
|
rotate: {
|
|
314
|
-
transform:
|
|
315
|
+
transform: 'rotate(10deg) rotateX(20deg) rotateY(30deg) rotateZ(40deg) rotate3d(0, 0.5, 1, 90deg)'
|
|
315
316
|
},
|
|
316
317
|
scale: {
|
|
317
|
-
transform:
|
|
318
|
+
transform: 'scale(1, 2) scaleX(1) scaleY(2) scaleZ(3) scale3d(1, 2, 3)'
|
|
318
319
|
},
|
|
319
320
|
skew: {
|
|
320
|
-
transform:
|
|
321
|
+
transform: 'skew(10deg, 15deg) skewX(20deg) skewY(30deg)'
|
|
321
322
|
},
|
|
322
323
|
translate: {
|
|
323
|
-
transform:
|
|
324
|
+
transform: 'translate(10px, 20px) translateX(11px) translateY(12px) translateZ(13px) translate3d(20px, 30px, 40px)'
|
|
324
325
|
},
|
|
325
326
|
mixed: {
|
|
326
327
|
transform: `
|
|
@@ -330,153 +331,169 @@ describe("styles", () => {
|
|
|
330
331
|
`
|
|
331
332
|
}
|
|
332
333
|
});
|
|
333
|
-
expect(_stylex.stylex.
|
|
334
|
-
expect(_stylex.stylex.
|
|
335
|
-
expect(_stylex.stylex.
|
|
336
|
-
expect(_stylex.stylex.
|
|
337
|
-
expect(_stylex.stylex.
|
|
338
|
-
expect(_stylex.stylex.
|
|
339
|
-
expect(_stylex.stylex.
|
|
340
|
-
expect(_stylex.stylex.
|
|
341
|
-
expect(_stylex.stylex.
|
|
334
|
+
expect(_stylex.stylex.props(styles.none, mockOptions)).toMatchSnapshot('none');
|
|
335
|
+
expect(_stylex.stylex.props(styles.matrix, mockOptions)).toMatchSnapshot('matrix');
|
|
336
|
+
expect(_stylex.stylex.props(styles.perspective, mockOptions)).toMatchSnapshot('perspective');
|
|
337
|
+
expect(_stylex.stylex.props(styles.rotate, mockOptions)).toMatchSnapshot('rotate');
|
|
338
|
+
expect(_stylex.stylex.props(styles.scale, mockOptions)).toMatchSnapshot('scale');
|
|
339
|
+
expect(_stylex.stylex.props(styles.skew, mockOptions)).toMatchSnapshot('skew');
|
|
340
|
+
expect(_stylex.stylex.props(styles.translate, mockOptions)).toMatchSnapshot('translate');
|
|
341
|
+
expect(_stylex.stylex.props(styles.rotate, mockOptions)).toMatchSnapshot('rotate');
|
|
342
|
+
expect(_stylex.stylex.props(styles.mixed, mockOptions)).toMatchSnapshot('mixed');
|
|
342
343
|
});
|
|
343
|
-
test(
|
|
344
|
+
test('transition-delay', () => {
|
|
344
345
|
const styles = _stylex.stylex.create({
|
|
345
346
|
root: {
|
|
346
|
-
transitionDelay:
|
|
347
|
+
transitionDelay: '0.3s'
|
|
347
348
|
}
|
|
348
349
|
});
|
|
349
|
-
expect(_stylex.stylex.
|
|
350
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot();
|
|
350
351
|
});
|
|
351
|
-
test(
|
|
352
|
+
test('transition-duration', () => {
|
|
352
353
|
const styles = _stylex.stylex.create({
|
|
353
354
|
root: {
|
|
354
|
-
transitionDuration:
|
|
355
|
+
transitionDuration: '0.5s'
|
|
355
356
|
}
|
|
356
357
|
});
|
|
357
|
-
expect(_stylex.stylex.
|
|
358
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot();
|
|
358
359
|
});
|
|
359
|
-
test(
|
|
360
|
+
test('user-select', () => {
|
|
360
361
|
const styles = _stylex.stylex.create({
|
|
361
362
|
root: {
|
|
362
|
-
userSelect:
|
|
363
|
+
userSelect: 'none'
|
|
363
364
|
}
|
|
364
365
|
});
|
|
365
|
-
expect(_stylex.stylex.
|
|
366
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot();
|
|
366
367
|
});
|
|
367
|
-
test(
|
|
368
|
+
test('vertical-align', () => {
|
|
368
369
|
const styles = _stylex.stylex.create({
|
|
369
370
|
middle: {
|
|
370
|
-
verticalAlign:
|
|
371
|
+
verticalAlign: 'middle'
|
|
371
372
|
},
|
|
372
373
|
top: {
|
|
373
|
-
verticalAlign:
|
|
374
|
+
verticalAlign: 'top'
|
|
374
375
|
}
|
|
375
376
|
});
|
|
376
|
-
expect(_stylex.stylex.
|
|
377
|
-
expect(_stylex.stylex.
|
|
377
|
+
expect(_stylex.stylex.props(styles.middle, mockOptions)).toMatchSnapshot('middle');
|
|
378
|
+
expect(_stylex.stylex.props(styles.top, mockOptions)).toMatchSnapshot('top');
|
|
379
|
+
});
|
|
380
|
+
test(':hover syntax', () => {
|
|
381
|
+
const styles = _stylex.stylex.create({
|
|
382
|
+
root: {
|
|
383
|
+
backgroundColor: {
|
|
384
|
+
default: 'red',
|
|
385
|
+
':hover': 'blue'
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot('not hovered');
|
|
390
|
+
const hoverOptions = {
|
|
391
|
+
...mockOptions,
|
|
392
|
+
hover: true
|
|
393
|
+
};
|
|
394
|
+
expect(_stylex.stylex.props(styles.root, hoverOptions)).toMatchSnapshot('hovered');
|
|
378
395
|
});
|
|
379
396
|
});
|
|
380
|
-
describe(
|
|
381
|
-
test(
|
|
397
|
+
describe('logical styles', () => {
|
|
398
|
+
test('blockSize', () => {
|
|
382
399
|
const styles = _stylex.stylex.create({
|
|
383
400
|
blockSize: {
|
|
384
|
-
blockSize:
|
|
401
|
+
blockSize: '100px'
|
|
385
402
|
},
|
|
386
403
|
maxBlockSize: {
|
|
387
|
-
maxBlockSize:
|
|
404
|
+
maxBlockSize: '100px'
|
|
388
405
|
},
|
|
389
406
|
minBlockSize: {
|
|
390
|
-
minBlockSize:
|
|
407
|
+
minBlockSize: '100px'
|
|
391
408
|
}
|
|
392
409
|
});
|
|
393
|
-
expect(_stylex.stylex.
|
|
394
|
-
expect(_stylex.stylex.
|
|
410
|
+
expect(_stylex.stylex.props(styles.blockSize, mockOptions)).toMatchSnapshot('blockSize');
|
|
411
|
+
expect(_stylex.stylex.props([{
|
|
395
412
|
height: 200
|
|
396
|
-
}, styles.blockSize], mockOptions)).toMatchSnapshot(
|
|
397
|
-
expect(_stylex.stylex.
|
|
398
|
-
expect(_stylex.stylex.
|
|
413
|
+
}, styles.blockSize], mockOptions)).toMatchSnapshot('blockSize after height');
|
|
414
|
+
expect(_stylex.stylex.props(styles.maxBlockSize, mockOptions)).toMatchSnapshot('maxBlockSize');
|
|
415
|
+
expect(_stylex.stylex.props([{
|
|
399
416
|
maxHeight: 200
|
|
400
|
-
}, styles.maxBlockSize], mockOptions)).toMatchSnapshot(
|
|
401
|
-
expect(_stylex.stylex.
|
|
402
|
-
expect(_stylex.stylex.
|
|
417
|
+
}, styles.maxBlockSize], mockOptions)).toMatchSnapshot('maxBlockSize after maxHeight');
|
|
418
|
+
expect(_stylex.stylex.props(styles.minBlockSize, mockOptions)).toMatchSnapshot('minBlockSize');
|
|
419
|
+
expect(_stylex.stylex.props([{
|
|
403
420
|
minHeight: 200
|
|
404
|
-
}, styles.minBlockSize], mockOptions)).toMatchSnapshot(
|
|
421
|
+
}, styles.minBlockSize], mockOptions)).toMatchSnapshot('minBlockSize after minHeight');
|
|
405
422
|
});
|
|
406
|
-
test(
|
|
423
|
+
test('inlineSize', () => {
|
|
407
424
|
const styles = _stylex.stylex.create({
|
|
408
425
|
inlineSize: {
|
|
409
|
-
inlineSize:
|
|
426
|
+
inlineSize: '100px'
|
|
410
427
|
},
|
|
411
428
|
maxInlineSize: {
|
|
412
|
-
maxInlineSize:
|
|
429
|
+
maxInlineSize: '100px'
|
|
413
430
|
},
|
|
414
431
|
minInlineSize: {
|
|
415
|
-
minInlineSize:
|
|
432
|
+
minInlineSize: '100px'
|
|
416
433
|
}
|
|
417
434
|
});
|
|
418
|
-
expect(_stylex.stylex.
|
|
419
|
-
expect(_stylex.stylex.
|
|
435
|
+
expect(_stylex.stylex.props(styles.inlineSize, mockOptions)).toMatchSnapshot('inlineSize');
|
|
436
|
+
expect(_stylex.stylex.props([{
|
|
420
437
|
width: 200
|
|
421
|
-
}, styles.inlineSize], mockOptions)).toMatchSnapshot(
|
|
422
|
-
expect(_stylex.stylex.
|
|
423
|
-
expect(_stylex.stylex.
|
|
438
|
+
}, styles.inlineSize], mockOptions)).toMatchSnapshot('inlineSize after width');
|
|
439
|
+
expect(_stylex.stylex.props(styles.maxInlineSize, mockOptions)).toMatchSnapshot('maxInlineSize');
|
|
440
|
+
expect(_stylex.stylex.props([{
|
|
424
441
|
maxWidth: 200
|
|
425
|
-
}, styles.maxInlineSize], mockOptions)).toMatchSnapshot(
|
|
426
|
-
expect(_stylex.stylex.
|
|
427
|
-
expect(_stylex.stylex.
|
|
442
|
+
}, styles.maxInlineSize], mockOptions)).toMatchSnapshot('maxInlineSize after maxWidth');
|
|
443
|
+
expect(_stylex.stylex.props(styles.minInlineSize, mockOptions)).toMatchSnapshot('minInlineSize');
|
|
444
|
+
expect(_stylex.stylex.props([{
|
|
428
445
|
minWidth: 200
|
|
429
|
-
}, styles.minInlineSize], mockOptions)).toMatchSnapshot(
|
|
446
|
+
}, styles.minInlineSize], mockOptions)).toMatchSnapshot('minInlineSize after minWidth');
|
|
430
447
|
});
|
|
431
|
-
test(
|
|
448
|
+
test('borderBlock', () => {
|
|
432
449
|
const styles = _stylex.stylex.create({
|
|
433
450
|
borderBlock: {
|
|
434
|
-
borderBlockColor:
|
|
435
|
-
borderBlockStyle:
|
|
451
|
+
borderBlockColor: 'black',
|
|
452
|
+
borderBlockStyle: 'solid',
|
|
436
453
|
borderBlockWidth: 1
|
|
437
454
|
},
|
|
438
455
|
borderBlockEnd: {
|
|
439
|
-
borderBlockEndColor:
|
|
440
|
-
borderBlockEndStyle:
|
|
456
|
+
borderBlockEndColor: 'red',
|
|
457
|
+
borderBlockEndStyle: 'dotted',
|
|
441
458
|
borderBlockEndWidth: 2
|
|
442
459
|
},
|
|
443
460
|
borderBlockStart: {
|
|
444
|
-
borderBlockStartColor:
|
|
445
|
-
borderBlockStartStyle:
|
|
461
|
+
borderBlockStartColor: 'green',
|
|
462
|
+
borderBlockStartStyle: 'dashed',
|
|
446
463
|
borderBlockStartWidth: 3
|
|
447
464
|
}
|
|
448
465
|
});
|
|
449
|
-
expect(_stylex.stylex.
|
|
450
|
-
expect(_stylex.stylex.
|
|
451
|
-
expect(_stylex.stylex.
|
|
452
|
-
expect(_stylex.stylex.
|
|
453
|
-
expect(_stylex.stylex.
|
|
466
|
+
expect(_stylex.stylex.props(styles.borderBlock, mockOptions)).toMatchSnapshot('borderBlock');
|
|
467
|
+
expect(_stylex.stylex.props(styles.borderBlockEnd, mockOptions)).toMatchSnapshot('borderBlockEnd');
|
|
468
|
+
expect(_stylex.stylex.props(styles.borderBlockStart, mockOptions)).toMatchSnapshot('borderBlockStart');
|
|
469
|
+
expect(_stylex.stylex.props([styles.borderBlockEnd, styles.borderBlock], mockOptions)).toMatchSnapshot('borderBlock after borderBlockEnd');
|
|
470
|
+
expect(_stylex.stylex.props([styles.borderBlockStart, styles.borderBlock], mockOptions)).toMatchSnapshot('borderBlock after borderBlockStart');
|
|
454
471
|
});
|
|
455
|
-
test(
|
|
472
|
+
test('borderInline', () => {
|
|
456
473
|
const styles = _stylex.stylex.create({
|
|
457
474
|
borderInline: {
|
|
458
|
-
borderInlineColor:
|
|
459
|
-
borderInlineStyle:
|
|
475
|
+
borderInlineColor: 'black',
|
|
476
|
+
borderInlineStyle: 'solid',
|
|
460
477
|
borderInlineWidth: 1
|
|
461
478
|
},
|
|
462
479
|
borderInlineEnd: {
|
|
463
|
-
borderInlineEndColor:
|
|
464
|
-
borderInlineEndStyle:
|
|
480
|
+
borderInlineEndColor: 'red',
|
|
481
|
+
borderInlineEndStyle: 'dotted',
|
|
465
482
|
borderInlineEndWidth: 2
|
|
466
483
|
},
|
|
467
484
|
borderInlineStart: {
|
|
468
|
-
borderInlineStartColor:
|
|
469
|
-
borderInlineStartStyle:
|
|
485
|
+
borderInlineStartColor: 'green',
|
|
486
|
+
borderInlineStartStyle: 'dashed',
|
|
470
487
|
borderInlineStartWidth: 3
|
|
471
488
|
}
|
|
472
489
|
});
|
|
473
|
-
expect(_stylex.stylex.
|
|
474
|
-
expect(_stylex.stylex.
|
|
475
|
-
expect(_stylex.stylex.
|
|
476
|
-
expect(_stylex.stylex.
|
|
477
|
-
expect(_stylex.stylex.
|
|
490
|
+
expect(_stylex.stylex.props(styles.borderInline, mockOptions)).toMatchSnapshot('borderInline');
|
|
491
|
+
expect(_stylex.stylex.props(styles.borderInlineEnd, mockOptions)).toMatchSnapshot('borderInlineEnd');
|
|
492
|
+
expect(_stylex.stylex.props(styles.borderInlineStart, mockOptions)).toMatchSnapshot('borderInlineStart');
|
|
493
|
+
expect(_stylex.stylex.props([styles.borderInlineEnd, styles.borderInline], mockOptions)).toMatchSnapshot('borderInline after borderInlineEnd');
|
|
494
|
+
expect(_stylex.stylex.props([styles.borderInlineStart, styles.borderInline], mockOptions)).toMatchSnapshot('borderInline after borderInlineStart');
|
|
478
495
|
});
|
|
479
|
-
test(
|
|
496
|
+
test('borderRadius', () => {
|
|
480
497
|
const styles = _stylex.stylex.create({
|
|
481
498
|
startstart: {
|
|
482
499
|
borderStartStartRadius: 10
|
|
@@ -491,24 +508,24 @@ describe("logical styles", () => {
|
|
|
491
508
|
borderEndEndRadius: 10
|
|
492
509
|
}
|
|
493
510
|
});
|
|
494
|
-
expect(_stylex.stylex.
|
|
495
|
-
expect(_stylex.stylex.
|
|
496
|
-
expect(_stylex.stylex.
|
|
497
|
-
expect(_stylex.stylex.
|
|
511
|
+
expect(_stylex.stylex.props(styles.startstart, mockOptions)).toMatchSnapshot('startstart');
|
|
512
|
+
expect(_stylex.stylex.props(styles.startend, mockOptions)).toMatchSnapshot('startend');
|
|
513
|
+
expect(_stylex.stylex.props(styles.endstart, mockOptions)).toMatchSnapshot('endstart');
|
|
514
|
+
expect(_stylex.stylex.props(styles.endend, mockOptions)).toMatchSnapshot('endend');
|
|
498
515
|
});
|
|
499
|
-
test.skip(
|
|
516
|
+
test.skip('borderStyle', () => {
|
|
500
517
|
const styles = _stylex.stylex.create({
|
|
501
518
|
root: {}
|
|
502
519
|
});
|
|
503
|
-
expect(_stylex.stylex.
|
|
520
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot();
|
|
504
521
|
});
|
|
505
|
-
test.skip(
|
|
522
|
+
test.skip('borderWidth', () => {
|
|
506
523
|
const styles = _stylex.stylex.create({
|
|
507
524
|
root: {}
|
|
508
525
|
});
|
|
509
|
-
expect(_stylex.stylex.
|
|
526
|
+
expect(_stylex.stylex.props(styles.root, mockOptions)).toMatchSnapshot();
|
|
510
527
|
});
|
|
511
|
-
test(
|
|
528
|
+
test('inset', () => {
|
|
512
529
|
const styles = _stylex.stylex.create({
|
|
513
530
|
inset: {
|
|
514
531
|
inset: 1
|
|
@@ -532,31 +549,31 @@ describe("logical styles", () => {
|
|
|
532
549
|
insetInlineEnd: 7
|
|
533
550
|
}
|
|
534
551
|
});
|
|
535
|
-
expect(_stylex.stylex.
|
|
536
|
-
expect(_stylex.stylex.
|
|
537
|
-
expect(_stylex.stylex.
|
|
538
|
-
expect(_stylex.stylex.
|
|
539
|
-
expect(_stylex.stylex.
|
|
540
|
-
expect(_stylex.stylex.
|
|
541
|
-
expect(_stylex.stylex.
|
|
542
|
-
expect(_stylex.stylex.
|
|
552
|
+
expect(_stylex.stylex.props(styles.inset, mockOptions)).toMatchSnapshot('inset');
|
|
553
|
+
expect(_stylex.stylex.props(styles.insetBlock, mockOptions)).toMatchSnapshot('insetBlock');
|
|
554
|
+
expect(_stylex.stylex.props(styles.insetBlockStart, mockOptions)).toMatchSnapshot('insetBlockStart');
|
|
555
|
+
expect(_stylex.stylex.props(styles.insetBlockEnd, mockOptions)).toMatchSnapshot('insetBlockEnd');
|
|
556
|
+
expect(_stylex.stylex.props(styles.insetInline, mockOptions)).toMatchSnapshot('insetInline');
|
|
557
|
+
expect(_stylex.stylex.props(styles.insetInlineStart, mockOptions)).toMatchSnapshot('insetInlineStart');
|
|
558
|
+
expect(_stylex.stylex.props(styles.insetInlineEnd, mockOptions)).toMatchSnapshot('insetInlineEnd');
|
|
559
|
+
expect(_stylex.stylex.props([{
|
|
543
560
|
left: 10,
|
|
544
561
|
right: 10,
|
|
545
562
|
bottom: 100,
|
|
546
563
|
top: 100
|
|
547
|
-
}, styles.insetBlockStart], mockOptions)).toMatchSnapshot(
|
|
548
|
-
expect(_stylex.stylex.
|
|
564
|
+
}, styles.insetBlockStart], mockOptions)).toMatchSnapshot('inset vs top');
|
|
565
|
+
expect(_stylex.stylex.props([{
|
|
549
566
|
bottom: 100,
|
|
550
567
|
top: 100
|
|
551
|
-
}, styles.insetBlockStart], mockOptions)).toMatchSnapshot(
|
|
552
|
-
expect(_stylex.stylex.
|
|
568
|
+
}, styles.insetBlockStart], mockOptions)).toMatchSnapshot('insetBlock vs top');
|
|
569
|
+
expect(_stylex.stylex.props([{
|
|
553
570
|
top: 100
|
|
554
|
-
}, styles.insetBlockStart], mockOptions)).toMatchSnapshot(
|
|
555
|
-
expect(_stylex.stylex.
|
|
571
|
+
}, styles.insetBlockStart], mockOptions)).toMatchSnapshot('insetBlockStart vs top');
|
|
572
|
+
expect(_stylex.stylex.props([{
|
|
556
573
|
bottom: 100
|
|
557
|
-
}, styles.insetBlockEnd], mockOptions)).toMatchSnapshot(
|
|
574
|
+
}, styles.insetBlockEnd], mockOptions)).toMatchSnapshot('insetBlockEnd vs bottom');
|
|
558
575
|
});
|
|
559
|
-
test(
|
|
576
|
+
test('margin', () => {
|
|
560
577
|
const styles = _stylex.stylex.create({
|
|
561
578
|
marginBlock: {
|
|
562
579
|
marginBlock: 1
|
|
@@ -577,14 +594,14 @@ describe("logical styles", () => {
|
|
|
577
594
|
marginInlineEnd: 3
|
|
578
595
|
}
|
|
579
596
|
});
|
|
580
|
-
expect(_stylex.stylex.
|
|
581
|
-
expect(_stylex.stylex.
|
|
582
|
-
expect(_stylex.stylex.
|
|
583
|
-
expect(_stylex.stylex.
|
|
584
|
-
expect(_stylex.stylex.
|
|
585
|
-
expect(_stylex.stylex.
|
|
597
|
+
expect(_stylex.stylex.props(styles.marginBlock, mockOptions)).toMatchSnapshot('marginBlock');
|
|
598
|
+
expect(_stylex.stylex.props(styles.marginBlockStart, mockOptions)).toMatchSnapshot('marginBlockStart');
|
|
599
|
+
expect(_stylex.stylex.props(styles.marginBlockEnd, mockOptions)).toMatchSnapshot('marginBlockEnd');
|
|
600
|
+
expect(_stylex.stylex.props(styles.marginInline, mockOptions)).toMatchSnapshot('marginInline');
|
|
601
|
+
expect(_stylex.stylex.props(styles.marginInlineStart, mockOptions)).toMatchSnapshot('marginInlineStart');
|
|
602
|
+
expect(_stylex.stylex.props(styles.marginInlineEnd, mockOptions)).toMatchSnapshot('marginInlineEnd');
|
|
586
603
|
});
|
|
587
|
-
test(
|
|
604
|
+
test('padding', () => {
|
|
588
605
|
const styles = _stylex.stylex.create({
|
|
589
606
|
paddingBlock: {
|
|
590
607
|
paddingBlock: 1
|
|
@@ -605,28 +622,28 @@ describe("logical styles", () => {
|
|
|
605
622
|
paddingInlineEnd: 3
|
|
606
623
|
}
|
|
607
624
|
});
|
|
608
|
-
expect(_stylex.stylex.
|
|
609
|
-
expect(_stylex.stylex.
|
|
610
|
-
expect(_stylex.stylex.
|
|
611
|
-
expect(_stylex.stylex.
|
|
612
|
-
expect(_stylex.stylex.
|
|
613
|
-
expect(_stylex.stylex.
|
|
625
|
+
expect(_stylex.stylex.props(styles.paddingBlock, mockOptions)).toMatchSnapshot('paddingBlock');
|
|
626
|
+
expect(_stylex.stylex.props(styles.paddingBlockStart, mockOptions)).toMatchSnapshot('paddingBlockStart');
|
|
627
|
+
expect(_stylex.stylex.props(styles.paddingBlockEnd, mockOptions)).toMatchSnapshot('paddingBlockEnd');
|
|
628
|
+
expect(_stylex.stylex.props(styles.paddingInline, mockOptions)).toMatchSnapshot('paddingInline');
|
|
629
|
+
expect(_stylex.stylex.props(styles.paddingInlineStart, mockOptions)).toMatchSnapshot('paddingInlineStart');
|
|
630
|
+
expect(_stylex.stylex.props(styles.paddingInlineEnd, mockOptions)).toMatchSnapshot('paddingInlineEnd');
|
|
614
631
|
});
|
|
615
|
-
test(
|
|
632
|
+
test('textAlign', () => {
|
|
616
633
|
const styles = _stylex.stylex.create({
|
|
617
634
|
start: {
|
|
618
|
-
textAlign:
|
|
635
|
+
textAlign: 'start'
|
|
619
636
|
},
|
|
620
637
|
end: {
|
|
621
|
-
textAlign:
|
|
638
|
+
textAlign: 'end'
|
|
622
639
|
}
|
|
623
640
|
});
|
|
624
|
-
expect(_stylex.stylex.
|
|
625
|
-
expect(_stylex.stylex.
|
|
641
|
+
expect(_stylex.stylex.props(styles.start, mockOptions)).toMatchSnapshot('start');
|
|
642
|
+
expect(_stylex.stylex.props(styles.end, mockOptions)).toMatchSnapshot('end');
|
|
626
643
|
});
|
|
627
644
|
});
|
|
628
|
-
describe(
|
|
629
|
-
const unitsToTest = [
|
|
645
|
+
describe('length units', () => {
|
|
646
|
+
const unitsToTest = ['em', 'px', 'rem', 'vh', 'vmax', 'vmin', 'vw'];
|
|
630
647
|
const value = 10;
|
|
631
648
|
for (const unitToTest of unitsToTest) {
|
|
632
649
|
test(`${value} "${unitToTest}" units are resolved to pixels`, () => {
|
|
@@ -635,7 +652,7 @@ describe("length units", () => {
|
|
|
635
652
|
width: `${value}${unitToTest}`
|
|
636
653
|
}
|
|
637
654
|
});
|
|
638
|
-
expect(_stylex.stylex.
|
|
655
|
+
expect(_stylex.stylex.props(styles.underTest, mockOptions)).toMatchSnapshot();
|
|
639
656
|
});
|
|
640
657
|
}
|
|
641
658
|
test(`${value} "em" units based on inherited font-size`, () => {
|
|
@@ -644,44 +661,44 @@ describe("length units", () => {
|
|
|
644
661
|
width: `${value}em`
|
|
645
662
|
}
|
|
646
663
|
});
|
|
647
|
-
expect(_stylex.stylex.
|
|
664
|
+
expect(_stylex.stylex.props(styles.underTest, {
|
|
648
665
|
...mockOptions,
|
|
649
666
|
inheritedFontSize: 12
|
|
650
667
|
})).toMatchSnapshot();
|
|
651
668
|
});
|
|
652
669
|
});
|
|
653
|
-
describe(
|
|
670
|
+
describe('custom properties', () => {
|
|
654
671
|
beforeEach(() => {
|
|
655
|
-
jest.spyOn(console,
|
|
672
|
+
jest.spyOn(console, 'error');
|
|
656
673
|
console.error.mockImplementation(() => {});
|
|
657
674
|
});
|
|
658
675
|
afterEach(() => {
|
|
659
676
|
console.error.mockRestore();
|
|
660
677
|
});
|
|
661
|
-
test(
|
|
678
|
+
test('filters out the property and emits a warning when encountering a variable name which has not been provided', () => {
|
|
662
679
|
const {
|
|
663
680
|
underTest
|
|
664
681
|
} = _stylex.stylex.create({
|
|
665
682
|
underTest: {
|
|
666
|
-
width:
|
|
683
|
+
width: 'var(--unprovided)'
|
|
667
684
|
}
|
|
668
685
|
});
|
|
669
|
-
expect(_stylex.stylex.
|
|
670
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
686
|
+
expect(_stylex.stylex.props(underTest, mockOptions)).toMatchSnapshot();
|
|
687
|
+
expect(console.error).toHaveBeenCalledWith('stylex: Unrecognized custom property "--unprovided"');
|
|
671
688
|
});
|
|
672
689
|
test("resolves custom properties' values", () => {
|
|
673
690
|
const {
|
|
674
691
|
underTest
|
|
675
692
|
} = _stylex.stylex.create({
|
|
676
693
|
underTest: {
|
|
677
|
-
color:
|
|
678
|
-
width:
|
|
694
|
+
color: 'var(--slightly-darker-black)',
|
|
695
|
+
width: 'var(--the-best-width)'
|
|
679
696
|
}
|
|
680
697
|
});
|
|
681
|
-
expect(_stylex.stylex.
|
|
698
|
+
expect(_stylex.stylex.props(underTest, {
|
|
682
699
|
...mockOptions,
|
|
683
700
|
customProperties: {
|
|
684
|
-
slightlyDarkerBlack:
|
|
701
|
+
slightlyDarkerBlack: '#333',
|
|
685
702
|
theBestWidth: 42
|
|
686
703
|
}
|
|
687
704
|
})).toMatchSnapshot();
|
|
@@ -703,7 +720,7 @@ expect.extend({
|
|
|
703
720
|
}
|
|
704
721
|
}
|
|
705
722
|
});
|
|
706
|
-
const props = _stylex.stylex.
|
|
723
|
+
const props = _stylex.stylex.props(underTest, {
|
|
707
724
|
viewportHeight: height,
|
|
708
725
|
viewportWidth: width
|
|
709
726
|
});
|
|
@@ -721,68 +738,68 @@ expect.extend({
|
|
|
721
738
|
}
|
|
722
739
|
}
|
|
723
740
|
});
|
|
724
|
-
describe(
|
|
725
|
-
test(
|
|
726
|
-
expect(
|
|
741
|
+
describe('media queries', () => {
|
|
742
|
+
test('matches a "min-width" query', () => {
|
|
743
|
+
expect('(min-width: 400px)').toMatchWindowDimensions({
|
|
727
744
|
width: 450,
|
|
728
745
|
height: 0
|
|
729
746
|
});
|
|
730
|
-
expect(
|
|
747
|
+
expect('(min-width: 400px)').not.toMatchWindowDimensions({
|
|
731
748
|
width: 350,
|
|
732
749
|
height: 0
|
|
733
750
|
});
|
|
734
751
|
});
|
|
735
|
-
test(
|
|
736
|
-
expect(
|
|
752
|
+
test('matches a "max-width" query', () => {
|
|
753
|
+
expect('(max-width: 400px)').toMatchWindowDimensions({
|
|
737
754
|
width: 350,
|
|
738
755
|
height: 0
|
|
739
756
|
});
|
|
740
|
-
expect(
|
|
757
|
+
expect('(max-width: 400px)').not.toMatchWindowDimensions({
|
|
741
758
|
width: 450,
|
|
742
759
|
height: 0
|
|
743
760
|
});
|
|
744
761
|
});
|
|
745
|
-
test(
|
|
746
|
-
expect(
|
|
762
|
+
test('matches a "min-height" query', () => {
|
|
763
|
+
expect('(min-height: 400px)').toMatchWindowDimensions({
|
|
747
764
|
width: 0,
|
|
748
765
|
height: 450
|
|
749
766
|
});
|
|
750
|
-
expect(
|
|
767
|
+
expect('(min-height: 400px)').not.toMatchWindowDimensions({
|
|
751
768
|
width: 0,
|
|
752
769
|
height: 350
|
|
753
770
|
});
|
|
754
771
|
});
|
|
755
|
-
test(
|
|
756
|
-
expect(
|
|
772
|
+
test('matches a "max-height" query', () => {
|
|
773
|
+
expect('(max-height: 400px)').toMatchWindowDimensions({
|
|
757
774
|
width: 0,
|
|
758
775
|
height: 350
|
|
759
776
|
});
|
|
760
|
-
expect(
|
|
777
|
+
expect('(max-height: 400px)').not.toMatchWindowDimensions({
|
|
761
778
|
width: 0,
|
|
762
779
|
height: 450
|
|
763
780
|
});
|
|
764
781
|
});
|
|
765
782
|
});
|
|
766
|
-
describe(
|
|
783
|
+
describe('unsupported style properties', () => {
|
|
767
784
|
beforeEach(() => {
|
|
768
|
-
jest.spyOn(console,
|
|
785
|
+
jest.spyOn(console, 'warn');
|
|
769
786
|
console.warn.mockImplementation(() => {});
|
|
770
787
|
});
|
|
771
788
|
afterEach(() => {
|
|
772
789
|
console.warn.mockRestore();
|
|
773
790
|
});
|
|
774
|
-
test("
|
|
791
|
+
test('"filter"', () => {
|
|
775
792
|
const {
|
|
776
793
|
underTest
|
|
777
794
|
} = _stylex.stylex.create({
|
|
778
795
|
underTest: {
|
|
779
|
-
filter:
|
|
796
|
+
filter: 'blur(1px)'
|
|
780
797
|
}
|
|
781
798
|
});
|
|
782
|
-
expect(_stylex.stylex.
|
|
799
|
+
expect(_stylex.stylex.props(underTest, mockOptions)).toMatchSnapshot();
|
|
783
800
|
expect(console.warn).toHaveBeenCalled();
|
|
784
801
|
});
|
|
785
|
-
test("
|
|
802
|
+
test('"marginStart"', () => {
|
|
786
803
|
const {
|
|
787
804
|
underTest
|
|
788
805
|
} = _stylex.stylex.create({
|
|
@@ -790,10 +807,10 @@ describe("unsupported style properties", () => {
|
|
|
790
807
|
marginStart: 10
|
|
791
808
|
}
|
|
792
809
|
});
|
|
793
|
-
expect(_stylex.stylex.
|
|
810
|
+
expect(_stylex.stylex.props(underTest, mockOptions)).toMatchSnapshot();
|
|
794
811
|
expect(console.warn).toHaveBeenCalled();
|
|
795
812
|
});
|
|
796
|
-
test("
|
|
813
|
+
test('"marginEnd"', () => {
|
|
797
814
|
const {
|
|
798
815
|
underTest
|
|
799
816
|
} = _stylex.stylex.create({
|
|
@@ -801,10 +818,10 @@ describe("unsupported style properties", () => {
|
|
|
801
818
|
marginEnd: 10
|
|
802
819
|
}
|
|
803
820
|
});
|
|
804
|
-
expect(_stylex.stylex.
|
|
821
|
+
expect(_stylex.stylex.props(underTest, mockOptions)).toMatchSnapshot();
|
|
805
822
|
expect(console.warn).toHaveBeenCalled();
|
|
806
823
|
});
|
|
807
|
-
test("
|
|
824
|
+
test('"marginHorizontal"', () => {
|
|
808
825
|
const {
|
|
809
826
|
underTest
|
|
810
827
|
} = _stylex.stylex.create({
|
|
@@ -812,10 +829,10 @@ describe("unsupported style properties", () => {
|
|
|
812
829
|
marginHorizontal: 10
|
|
813
830
|
}
|
|
814
831
|
});
|
|
815
|
-
expect(_stylex.stylex.
|
|
832
|
+
expect(_stylex.stylex.props(underTest, mockOptions)).toMatchSnapshot();
|
|
816
833
|
expect(console.warn).toHaveBeenCalled();
|
|
817
834
|
});
|
|
818
|
-
test("
|
|
835
|
+
test('"marginVertical"', () => {
|
|
819
836
|
const {
|
|
820
837
|
underTest
|
|
821
838
|
} = _stylex.stylex.create({
|
|
@@ -823,10 +840,10 @@ describe("unsupported style properties", () => {
|
|
|
823
840
|
marginVertical: 10
|
|
824
841
|
}
|
|
825
842
|
});
|
|
826
|
-
expect(_stylex.stylex.
|
|
843
|
+
expect(_stylex.stylex.props(underTest, mockOptions)).toMatchSnapshot();
|
|
827
844
|
expect(console.warn).toHaveBeenCalled();
|
|
828
845
|
});
|
|
829
|
-
test("
|
|
846
|
+
test('"paddingHorizontal"', () => {
|
|
830
847
|
const {
|
|
831
848
|
underTest
|
|
832
849
|
} = _stylex.stylex.create({
|
|
@@ -834,10 +851,10 @@ describe("unsupported style properties", () => {
|
|
|
834
851
|
paddingHorizontal: 10
|
|
835
852
|
}
|
|
836
853
|
});
|
|
837
|
-
expect(_stylex.stylex.
|
|
854
|
+
expect(_stylex.stylex.props(underTest, mockOptions)).toMatchSnapshot();
|
|
838
855
|
expect(console.warn).toHaveBeenCalled();
|
|
839
856
|
});
|
|
840
|
-
test("
|
|
857
|
+
test('"paddingVertical"', () => {
|
|
841
858
|
const {
|
|
842
859
|
underTest
|
|
843
860
|
} = _stylex.stylex.create({
|
|
@@ -845,63 +862,63 @@ describe("unsupported style properties", () => {
|
|
|
845
862
|
paddingVertical: 10
|
|
846
863
|
}
|
|
847
864
|
});
|
|
848
|
-
expect(_stylex.stylex.
|
|
865
|
+
expect(_stylex.stylex.props(underTest, mockOptions)).toMatchSnapshot();
|
|
849
866
|
expect(console.warn).toHaveBeenCalled();
|
|
850
867
|
});
|
|
851
|
-
test("
|
|
868
|
+
test('"transitionProperty" passthrough', () => {
|
|
852
869
|
const {
|
|
853
870
|
underTest
|
|
854
871
|
} = _stylex.stylex.create({
|
|
855
872
|
underTest: {
|
|
856
|
-
transitionProperty:
|
|
873
|
+
transitionProperty: 'opacity'
|
|
857
874
|
}
|
|
858
875
|
});
|
|
859
|
-
expect(_stylex.stylex.
|
|
876
|
+
expect(_stylex.stylex.props(underTest, {
|
|
860
877
|
...mockOptions,
|
|
861
|
-
passthroughProperties: [
|
|
878
|
+
passthroughProperties: ['transitionProperty']
|
|
862
879
|
})).toMatchSnapshot();
|
|
863
880
|
expect(console.warn).not.toHaveBeenCalled();
|
|
864
881
|
});
|
|
865
882
|
});
|
|
866
|
-
describe(
|
|
883
|
+
describe('unsupported style values', () => {
|
|
867
884
|
beforeEach(() => {
|
|
868
|
-
jest.spyOn(console,
|
|
885
|
+
jest.spyOn(console, 'warn');
|
|
869
886
|
console.warn.mockImplementation(() => {});
|
|
870
887
|
});
|
|
871
888
|
afterEach(() => {
|
|
872
889
|
console.warn.mockRestore();
|
|
873
890
|
});
|
|
874
|
-
test(
|
|
891
|
+
test('calc', () => {
|
|
875
892
|
const {
|
|
876
893
|
underTest
|
|
877
894
|
} = _stylex.stylex.create({
|
|
878
895
|
underTest: {
|
|
879
|
-
width:
|
|
896
|
+
width: 'calc(2 * 1rem)'
|
|
880
897
|
}
|
|
881
898
|
});
|
|
882
|
-
expect(_stylex.stylex.
|
|
899
|
+
expect(_stylex.stylex.props(underTest, mockOptions)).toMatchSnapshot();
|
|
883
900
|
expect(console.warn).toHaveBeenCalled();
|
|
884
901
|
});
|
|
885
|
-
test(
|
|
902
|
+
test('inherit', () => {
|
|
886
903
|
const {
|
|
887
904
|
underTest
|
|
888
905
|
} = _stylex.stylex.create({
|
|
889
906
|
underTest: {
|
|
890
|
-
fontSize:
|
|
907
|
+
fontSize: 'inherit'
|
|
891
908
|
}
|
|
892
909
|
});
|
|
893
|
-
expect(_stylex.stylex.
|
|
910
|
+
expect(_stylex.stylex.props(underTest, mockOptions)).toMatchSnapshot();
|
|
894
911
|
expect(console.warn).toHaveBeenCalled();
|
|
895
912
|
});
|
|
896
|
-
test(
|
|
913
|
+
test('initial', () => {
|
|
897
914
|
const {
|
|
898
915
|
underTest
|
|
899
916
|
} = _stylex.stylex.create({
|
|
900
917
|
underTest: {
|
|
901
|
-
fontSize:
|
|
918
|
+
fontSize: 'initial'
|
|
902
919
|
}
|
|
903
920
|
});
|
|
904
|
-
expect(_stylex.stylex.
|
|
921
|
+
expect(_stylex.stylex.props(underTest, mockOptions)).toMatchSnapshot();
|
|
905
922
|
expect(console.warn).toHaveBeenCalled();
|
|
906
923
|
});
|
|
907
924
|
});
|