File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
spec/pivotal-ui-react/modals Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 1
1
import '../spec_helper' ;
2
2
import { findByClass , findAllByClass , clickOn } from '../spec_helper' ;
3
3
import { Modal , BaseModal } from '../../../src/react/modals' ;
4
+ import AnimationMixin from 'pui-react-animation' ;
4
5
5
6
let result ;
6
7
@@ -238,6 +239,20 @@ describe('BaseModal', () => {
238
239
239
240
expect ( onHide ) . not . toHaveBeenCalled ( ) ;
240
241
} ) ;
242
+
243
+ describe ( 'when animation is true' , ( ) => {
244
+ beforeEach ( ( ) => {
245
+ spyOn ( AnimationMixin , 'componentWillUnmount' ) . and . callThrough ( ) ;
246
+ } ) ;
247
+
248
+ it ( 'resets animation if unmounted before animation finishes' , ( ) => {
249
+ result = renderIntoDom ( { show : true , onHide, animation : true } ) ;
250
+ ReactDOM . unmountComponentAtNode ( root ) ;
251
+ MockRaf . next ( ) ;
252
+
253
+ expect ( AnimationMixin . componentWillUnmount ) . toHaveBeenCalled ( ) ;
254
+ } ) ;
255
+ } ) ;
241
256
} ) ;
242
257
243
258
describe ( 'acquireFocus' , ( ) => {
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ export class BaseModal extends mixin(React.PureComponent).with(Animation) {
76
76
}
77
77
78
78
componentWillUnmount ( ) {
79
+ if ( super . componentWillUnmount ) super . componentWillUnmount ( ) ;
79
80
const document = this . props . getDocument ( ) ;
80
81
if ( typeof document !== 'object' ) return ;
81
82
document . removeEventListener ( 'keydown' , this . onKeyDown ) ;
You can’t perform that action at this time.
0 commit comments