@@ -232,13 +232,34 @@ it('transforms flex shorthand with 3 values in reverse order', () => runTest([
232
232
[ 'flex' , '3px 1 2' ] ,
233
233
] , { flexGrow : 1 , flexShrink : 2 , flexBasis : 3 } ) ) ;
234
234
235
- it ( 'transforms flex shorthand with 2 values' , ( ) => runTest ( [
235
+ it ( 'transforms flex shorthand with 2 values of flex-grow and flex-shrink ' , ( ) => runTest ( [
236
236
[ 'flex' , '1 2' ] ,
237
237
] , { flexGrow : 1 , flexShrink : 2 , flexBasis : 0 } ) ) ;
238
238
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 } ) ) ;
254
+
255
+ /*
256
+ A unitless zero that is not already preceded by two flex factors must be interpreted as a flex
257
+ factor. To avoid misinterpretation or invalid declarations, authors must specify a zero
258
+ <‘flex-basis’> component with a unit or precede it by two flex factors.
259
+ */
260
+ it ( 'transforms flex shorthand with flex-grow/shrink taking priority over basis' , ( ) => runTest ( [
261
+ [ 'flex' , '0 1 0' ] ,
262
+ ] , { flexGrow : 0 , flexShrink : 1 , flexBasis : 0 } ) ) ;
242
263
243
264
it ( 'transforms flexFlow shorthand with two values' , ( ) => runTest ( [
244
265
[ 'flex-flow' , 'column wrap' ] ,
@@ -401,6 +422,10 @@ it('does not transform invalid unquoted font-family', () => {
401
422
expect ( ( ) => transformCss ( [ [ 'font-family' , 'Goudy Bookletter 1911' ] ] ) ) . toThrow ( ) ;
402
423
} ) ;
403
424
425
+ it ( 'does not transform invalid flex' , ( ) => {
426
+ expect ( ( ) => transformCss ( [ [ 'flex' , '1 2px 3' ] ] ) ) . toThrow ( ) ;
427
+ } ) ;
428
+
404
429
it ( 'allows blacklisting shorthands' , ( ) => {
405
430
const actualStyles = transformCss ( [ [ 'border-radius' , '50' ] ] , [ 'borderRadius' ] ) ;
406
431
expect ( actualStyles ) . toEqual ( { borderRadius : 50 } ) ;
0 commit comments