Skip to content

Commit ba3f1e5

Browse files
committed
Improve flex tests
1 parent b901f2d commit ba3f1e5

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/index.test.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,25 @@ it('transforms flex shorthand with 3 values in reverse order', () => runTest([
232232
['flex', '3px 1 2'],
233233
], { flexGrow: 1, flexShrink: 2, flexBasis: 3 }));
234234

235-
it('transforms flex shorthand with 2 values', () => runTest([
235+
it('transforms flex shorthand with 2 values of flex-grow and flex-shrink', () => runTest([
236236
['flex', '1 2'],
237237
], { flexGrow: 1, flexShrink: 2, flexBasis: 0 }));
238238

239-
it('transforms flex shorthand with 1 values', () => runTest([
240-
['flex', '1'],
241-
], { flexGrow: 1, flexShrink: 1, flexBasis: 0 }));
239+
it('transforms flex shorthand with 2 values of flex-grow and flex-basis', () => runTest([
240+
['flex', '2 2px'],
241+
], { flexGrow: 2, flexShrink: 1, flexBasis: 2 }));
242+
243+
it('transforms flex shorthand with 2 values of flex-grow and flex-basis (reversed)', () => runTest([
244+
['flex', '2px 2'],
245+
], { flexGrow: 2, flexShrink: 1, flexBasis: 2 }));
246+
247+
it('transforms flex shorthand with 1 value of flex-grow', () => runTest([
248+
['flex', '2'],
249+
], { flexGrow: 2, flexShrink: 1, flexBasis: 0 }));
250+
251+
it('transforms flex shorthand with 1 value of flex-basis', () => runTest([
252+
['flex', '10px'],
253+
], { flexGrow: 1, flexShrink: 1, flexBasis: 10 }));
242254

243255
/*
244256
A unitless zero that is not already preceded by two flex factors must be interpreted as a flex
@@ -410,6 +422,10 @@ it('does not transform invalid unquoted font-family', () => {
410422
expect(() => transformCss([['font-family', 'Goudy Bookletter 1911']])).toThrow();
411423
});
412424

425+
it('does not transform invalid flex', () => {
426+
expect(() => transformCss([['flex', '1 2px 3']])).toThrow();
427+
});
428+
413429
it('allows blacklisting shorthands', () => {
414430
const actualStyles = transformCss([['border-radius', '50']], ['borderRadius']);
415431
expect(actualStyles).toEqual({ borderRadius: 50 });

0 commit comments

Comments
 (0)