File tree Expand file tree Collapse file tree
packages/react-native/Libraries/StyleSheet/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -213,10 +213,36 @@ describe('processBoxShadow', () => {
213213 expect ( processBoxShadow ( 'red 10foo 5px 2px 3px,' ) ) . toEqual ( [ ] ) ;
214214 } ) ;
215215
216+ it ( 'should fail to parse decimal number with invalid unit' , ( ) => {
217+ expect ( processBoxShadow ( '1.5dog 2px' ) ) . toEqual ( [ ] ) ;
218+ } ) ;
219+
216220 it ( 'should fail to parse invalid argument' , ( ) => {
217221 expect ( processBoxShadow ( 'red asf 5px 2px 3px' ) ) . toEqual ( [ ] ) ;
218222 } ) ;
219223
224+ it ( 'should parse string with leading dot decimal' , ( ) => {
225+ expect ( processBoxShadow ( '.5px 2px' ) ) . toEqual ( [
226+ {
227+ offsetX : 0.5 ,
228+ offsetY : 2 ,
229+ } ,
230+ ] ) ;
231+ } ) ;
232+
233+ it ( 'should parse string with explicit positive sign' , ( ) => {
234+ expect ( processBoxShadow ( '+5px 2px' ) ) . toEqual ( [
235+ {
236+ offsetX : 5 ,
237+ offsetY : 2 ,
238+ } ,
239+ ] ) ;
240+ } ) ;
241+
242+ it ( 'should fail to parse trailing dot without fractional digits' , ( ) => {
243+ expect ( processBoxShadow ( '10.px 5px' ) ) . toEqual ( [ ] ) ;
244+ } ) ;
245+
220246 it ( 'should fail to parse negative blur' , ( ) => {
221247 expect ( processBoxShadow ( 'red 5px 2px -3px' ) ) . toEqual ( [ ] ) ;
222248 } ) ;
@@ -306,4 +332,15 @@ describe('processBoxShadow', () => {
306332 ] ) ,
307333 ) . toEqual ( [ ] ) ;
308334 } ) ;
335+
336+ it ( 'should fail to parse object with unitless non-zero string' , ( ) => {
337+ expect (
338+ processBoxShadow ( [
339+ {
340+ offsetX : '5' ,
341+ offsetY : 10 ,
342+ } ,
343+ ] ) ,
344+ ) . toEqual ( [ ] ) ;
345+ } ) ;
309346} ) ;
You can’t perform that action at this time.
0 commit comments