1- import rn from 'react-native' ;
1+ import { Platform } from 'react-native' ;
22import { create } from '../' ;
33
44describe ( `transform utilities` , ( ) => {
@@ -243,11 +243,9 @@ describe(`transform utilities`, () => {
243243 } ) ;
244244
245245 test ( `translate w/percentage values` , ( ) => {
246- rn . Platform . constants . reactNativeVersion = {
247- major : 0 ,
248- minor : 75 ,
249- patch : 0 ,
250- } ;
246+ Platform . OS = `web` ;
247+ jest . spyOn ( Platform , `constants` , `get` ) . mockReturnValue ( undefined as any ) ;
248+ tw = create ( ) ;
251249
252250 expect ( tw . style ( `translate-x-full` ) ) . toMatchObject ( {
253251 transform : [ { translateX : `100%` } ] ,
@@ -274,11 +272,51 @@ describe(`transform utilities`, () => {
274272 transform : [ { translateY : `20%` } ] ,
275273 } ) ;
276274
277- rn . Platform . constants . reactNativeVersion = {
278- major : 0 ,
279- minor : 74 ,
280- patch : 0 ,
281- } ;
275+ Platform . OS = `ios` ;
276+ jest . spyOn ( Platform , `constants` , `get` ) . mockReturnValue ( {
277+ ...Platform . constants ,
278+ reactNativeVersion : {
279+ major : 0 ,
280+ minor : 75 ,
281+ patch : 0 ,
282+ } ,
283+ } ) ;
284+ tw = create ( ) ;
285+
286+ expect ( tw . style ( `translate-x-full` ) ) . toMatchObject ( {
287+ transform : [ { translateX : `100%` } ] ,
288+ } ) ;
289+ expect ( tw . style ( `translate-y-full` ) ) . toMatchObject ( {
290+ transform : [ { translateY : `100%` } ] ,
291+ } ) ;
292+ expect ( tw . style ( `translate-x-1/2` ) ) . toMatchObject ( {
293+ transform : [ { translateX : `50%` } ] ,
294+ } ) ;
295+ expect ( tw . style ( `translate-y-1/2` ) ) . toMatchObject ( {
296+ transform : [ { translateY : `50%` } ] ,
297+ } ) ;
298+ expect ( tw . style ( `translate-x-[10%]` ) ) . toMatchObject ( {
299+ transform : [ { translateX : `10%` } ] ,
300+ } ) ;
301+ expect ( tw . style ( `translate-y-[10%]` ) ) . toMatchObject ( {
302+ transform : [ { translateY : `10%` } ] ,
303+ } ) ;
304+ expect ( tw . style ( `translate-x-1/5` ) ) . toMatchObject ( {
305+ transform : [ { translateX : `20%` } ] ,
306+ } ) ;
307+ expect ( tw . style ( `translate-y-1/5` ) ) . toMatchObject ( {
308+ transform : [ { translateY : `20%` } ] ,
309+ } ) ;
310+
311+ jest . spyOn ( Platform , `constants` , `get` ) . mockReturnValue ( {
312+ ...Platform . constants ,
313+ reactNativeVersion : {
314+ major : 0 ,
315+ minor : 74 ,
316+ patch : 0 ,
317+ } ,
318+ } ) ;
319+ tw = create ( ) ;
282320
283321 expect ( tw . style ( `translate-x-full` ) ) . toMatchObject ( { } ) ;
284322 expect ( tw . style ( `translate-y-full` ) ) . toMatchObject ( { } ) ;
0 commit comments