@@ -150,7 +150,7 @@ describe('DropdownAlert component', () => {
150150 test ( 'expect to return error string value' , ( ) => {
151151 const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } /> ) ;
152152 const expected = TypeError ( 'Converting circular structure to JSON' ) . toString ( ) ;
153- let circularObject = { } ;
153+ let circularObject = { } ;
154154 circularObject . a = circularObject ;
155155 const value = wrapper . instance ( ) . getStringValue ( circularObject ) ;
156156 expect ( value ) . toEqual ( expected ) ;
@@ -331,10 +331,33 @@ describe('DropdownAlert component', () => {
331331 expect ( wrapper . instance ( ) . state . topValue ) . toBe ( 0 ) ;
332332 expect ( wrapper . instance ( ) . closeTimeoutID ) . toBeDefined ( ) ;
333333 } ) ;
334+ test ( 'expect error type to be open state and have alert data with payload and source defined' , ( ) => {
335+ const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } /> ) ;
336+ wrapper . instance ( ) . setState ( { isOpen : true } ) ;
337+ wrapper . instance ( ) . closeTimeoutID = setTimeout ( ( ) => { } ) ;
338+ wrapper . update ( ) ;
339+ const type = TYPE . error ;
340+ const title = 'Excepteur dolore aute culpa occaecat reprehenderit veniam sint tempor exercitation cillum aliquip id reprehenderit.' ;
341+ const message = 'Et id irure proident ipsum veniam ad magna cillum fugiat.' ;
342+ const payload = {
343+ source : imageSrc ,
344+ } ;
345+ wrapper . instance ( ) . alertWithType ( type , title , message , payload ) ;
346+ expect ( wrapper . instance ( ) . alertData ) . toBeDefined ( ) ;
347+ expect ( wrapper . instance ( ) . alertData . type ) . toBe ( type ) ;
348+ expect ( wrapper . instance ( ) . alertData . title ) . toBe ( title ) ;
349+ expect ( wrapper . instance ( ) . alertData . message ) . toBe ( message ) ;
350+ expect ( wrapper . instance ( ) . alertData . payload . source ) . toBeDefined ( ) ;
351+ expect ( wrapper . instance ( ) . alertData . payload . source ) . toBe ( imageSrc ) ;
352+ expect ( wrapper . instance ( ) . alertData . payload ) . toBe ( payload ) ;
353+ expect ( wrapper . instance ( ) . state . isOpen ) . toBeTruthy ( ) ;
354+ expect ( wrapper . instance ( ) . state . topValue ) . toBe ( 0 ) ;
355+ expect ( wrapper . instance ( ) . closeTimeoutID ) . toBeDefined ( ) ;
356+ } ) ;
334357 } ) ;
335358 describe ( 'open' , ( ) => {
336359 test ( 'expect open to be okay with no data' , ( ) => {
337- const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } /> ) ;
360+ const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } /> ) ;
338361 wrapper . instance ( ) . open ( ) ;
339362 expect ( wrapper . instance ( ) . state . isOpen ) . toBeTruthy ( ) ;
340363 } ) ;
@@ -369,36 +392,65 @@ describe('DropdownAlert component', () => {
369392 expect ( wrapper . instance ( ) . state . isOpen ) . toBeFalsy ( ) ;
370393 } ) ;
371394 } ) ;
372- describe ( 'close' , ( ) => { } ) ;
373- describe ( 'updateStatusBar' , ( ) => {
374- // FIXME: mock platform
375- // jest.mock('Platform', () => ({
376- // OS: 'android',
377- // }));
378- test ( 'expect should update status bar to active state' , ( ) => {
379- const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } /> ) ;
380- wrapper . instance ( ) . updateStatusBar ( true , true ) ;
395+ describe ( 'close' , ( ) => {
396+ test ( 'expect close with onTap' , ( ) => {
397+ const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } onTap = { ( ) => { } } /> ) ;
398+ wrapper . instance ( ) . close ( ACTION . tap , ( ) => {
399+ expect ( wrapper . instance ( ) . alertData ) . toBeDefined ( ) ;
400+ } ) ;
381401 } ) ;
382- test ( 'expect should not update status bar' , ( ) => {
383- const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } /> ) ;
384- wrapper . instance ( ) . updateStatusBar ( false , true ) ;
402+ } ) ;
403+ describe ( 'updateStatusBar' , ( ) => {
404+ describe ( 'ios' , ( ) => {
405+ beforeEach ( ( ) => {
406+ jest . mock ( 'Platform' , ( ) => ( {
407+ OS : 'ios' ,
408+ } ) ) ;
409+ } ) ;
410+ test ( 'expect should update status bar to active state' , ( ) => {
411+ const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } /> ) ;
412+ wrapper . instance ( ) . updateStatusBar ( true , true ) ;
413+ } ) ;
414+ test ( 'expect should not update status bar' , ( ) => {
415+ const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } /> ) ;
416+ wrapper . instance ( ) . updateStatusBar ( false , true ) ;
417+ } ) ;
418+ test ( 'expect without parameters to be okay' , ( ) => {
419+ const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } /> ) ;
420+ wrapper . instance ( ) . updateStatusBar ( ) ;
421+ } ) ;
385422 } ) ;
386- test ( 'expect without parameters to be okay' , ( ) => {
387- const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } /> ) ;
388- wrapper . instance ( ) . updateStatusBar ( ) ;
423+ describe ( 'android' , ( ) => {
424+ beforeEach ( ( ) => {
425+ jest . mock ( 'Platform' , ( ) => ( {
426+ OS : 'android' ,
427+ } ) ) ;
428+ } ) ;
429+ test ( 'expect should update status bar to active state' , ( ) => {
430+ const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } /> ) ;
431+ wrapper . instance ( ) . updateStatusBar ( true , true ) ;
432+ } ) ;
433+ test ( 'expect should not update status bar' , ( ) => {
434+ const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } /> ) ;
435+ wrapper . instance ( ) . updateStatusBar ( false , true ) ;
436+ } ) ;
437+ test ( 'expect without parameters to be okay' , ( ) => {
438+ const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } /> ) ;
439+ wrapper . instance ( ) . updateStatusBar ( ) ;
440+ } ) ;
389441 } ) ;
390442 } ) ;
391443 describe ( 'clearCloseTimeoutID' , ( ) => { } ) ;
392444 describe ( 'animate' , ( ) => {
393445 test ( 'expect animation lock to be true' , ( ) => {
394446 const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } useAnimationLock = { true } /> ) ;
395- wrapper . instance ( ) . animate ( 1 , 450 , ( ) => { } )
447+ wrapper . instance ( ) . animate ( 1 , 450 , ( ) => { } ) ;
396448 const lock = wrapper . instance ( ) . animationLock ;
397449 expect ( lock ) . toBeTruthy ( ) ;
398450 } ) ;
399451 test ( 'expect animation lock to be false' , ( ) => {
400452 const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } useAnimationLock = { false } /> ) ;
401- wrapper . instance ( ) . animate ( 0 )
453+ wrapper . instance ( ) . animate ( 0 ) ;
402454 const lock = wrapper . instance ( ) . animationLock ;
403455 expect ( lock ) . toBeFalsy ( ) ;
404456 } ) ;
@@ -573,5 +625,10 @@ describe('DropdownAlert component', () => {
573625 const button = wrapper . instance ( ) . _renderCancel ( true ) ;
574626 expect ( button ) . toBeDefined ( ) ;
575627 } ) ;
628+ test ( 'expect show to be false and button to be null' , ( ) => {
629+ const wrapper = shallow ( < DropdownAlert imageSrc = { imageSrc } /> ) ;
630+ const button = wrapper . instance ( ) . _renderCancel ( false ) ;
631+ expect ( button ) . toBeNull ( ) ;
632+ } ) ;
576633 } ) ;
577634} ) ;
0 commit comments