@@ -657,6 +657,94 @@ describe('Modal', () => {
657657 wrapper . unmount ( ) ;
658658 } ) ;
659659
660+ it ( 'should animate when backdrop is "static" and escape key pressed' , ( ) => {
661+ isOpen = true ;
662+ const wrapper = didMount (
663+ < Modal isOpen = { isOpen } toggle = { toggle } backdrop = "static" >
664+ < button id = "clicker" > Does Nothing</ button >
665+ </ Modal >
666+ ) ;
667+ const spy = jest . spyOn ( wrapper . instance ( ) , 'handleStaticBackdropAnimation' ) ;
668+
669+ jest . runTimersToTime ( 300 ) ;
670+
671+ expect ( isOpen ) . toBe ( true ) ;
672+ expect ( document . getElementsByClassName ( 'modal' ) . length ) . toBe ( 1 ) ;
673+
674+ const escapeKeyUpEvent = {
675+ keyCode : keyCodes . esc ,
676+ preventDefault : jest . fn ( ( ) => { } ) ,
677+ stopPropagation : jest . fn ( ( ) => { } ) ,
678+ } ;
679+
680+ wrapper . instance ( ) . handleEscape ( escapeKeyUpEvent ) ;
681+ expect ( spy ) . toHaveBeenCalled ( ) ;
682+
683+ wrapper . unmount ( ) ;
684+ } ) ;
685+
686+ it ( 'should animate when backdrop is "static" and backdrop is clicked' , ( ) => {
687+ isOpen = true ;
688+ const wrapper = didMount (
689+ < Modal isOpen = { isOpen } toggle = { toggle } backdrop = "static" >
690+ < button id = "clicker" > Does Nothing</ button >
691+ </ Modal >
692+ ) ;
693+
694+ const spy = jest . spyOn ( wrapper . instance ( ) , 'handleStaticBackdropAnimation' ) ;
695+
696+ jest . runTimersToTime ( 300 ) ;
697+
698+ expect ( isOpen ) . toBe ( true ) ;
699+ expect ( document . getElementsByClassName ( 'modal' ) . length ) . toBe ( 1 ) ;
700+
701+ const modal = document . getElementsByClassName ( 'modal' ) [ 0 ] ;
702+
703+ const mouseDownEvent = document . createEvent ( 'MouseEvents' ) ;
704+ mouseDownEvent . initEvent ( 'mousedown' , true , true ) ;
705+ modal . dispatchEvent ( mouseDownEvent ) ;
706+
707+ const clickEvent = document . createEvent ( 'MouseEvents' ) ;
708+ clickEvent . initEvent ( 'click' , true , true ) ;
709+ modal . dispatchEvent ( clickEvent ) ;
710+
711+ jest . runTimersToTime ( 300 ) ;
712+ expect ( spy ) . toHaveBeenCalled ( ) ;
713+
714+ wrapper . unmount ( ) ;
715+ } ) ;
716+
717+ it ( 'should not animate when backdrop is "static" and modal is clicked' , ( ) => {
718+ isOpen = true ;
719+ const wrapper = didMount (
720+ < Modal isOpen = { isOpen } toggle = { toggle } backdrop = "static" >
721+ < button id = "clicker" > Does Nothing</ button >
722+ </ Modal >
723+ ) ;
724+
725+ const spy = jest . spyOn ( wrapper . instance ( ) , 'handleStaticBackdropAnimation' ) ;
726+
727+ jest . runTimersToTime ( 300 ) ;
728+
729+ expect ( isOpen ) . toBe ( true ) ;
730+ expect ( document . getElementsByClassName ( 'modal' ) . length ) . toBe ( 1 ) ;
731+
732+ const modalDialog = document . getElementsByClassName ( 'modal-dialog' ) [ 0 ] ;
733+
734+ const mouseDownEvent = document . createEvent ( 'MouseEvents' ) ;
735+ mouseDownEvent . initEvent ( 'mousedown' , true , true ) ;
736+ modalDialog . dispatchEvent ( mouseDownEvent ) ;
737+
738+ const clickEvent = document . createEvent ( 'MouseEvents' ) ;
739+ clickEvent . initEvent ( 'click' , true , true ) ;
740+ modalDialog . dispatchEvent ( clickEvent ) ;
741+
742+ jest . runTimersToTime ( 300 ) ;
743+ expect ( spy ) . not . toHaveBeenCalled ( ) ;
744+
745+ wrapper . unmount ( ) ;
746+ } ) ;
747+
660748 it ( 'should destroy this._element' , ( ) => {
661749 isOpen = true ;
662750 const wrapper = didMount (
0 commit comments