1
1
/* eslint-env mocha */
2
+ import 'should' ;
2
3
import sinon from 'sinon' ;
3
- import expect from 'expect' ;
4
4
import React from 'react' ;
5
5
import ReactDOM from 'react-dom' ;
6
6
import TestUtils from 'react-dom/test-utils' ;
7
- import Modal from '../src/components/Modal' ;
7
+ import Modal from '../src/components/Modal.js ' ;
8
8
import {
9
9
moverlay , mcontent ,
10
10
clickAt , mouseDownAt , mouseUpAt , escKeyDown , tabKeyDown ,
11
11
renderModal , emptyDOM
12
12
} from './helper' ;
13
13
14
- describe ( 'Events' , ( ) => {
14
+ export default ( ) => {
15
15
afterEach ( 'Unmount modal' , emptyDOM ) ;
16
16
17
17
it ( 'should trigger the onAfterOpen callback' , ( ) => {
18
18
const afterOpenCallback = sinon . spy ( ) ;
19
19
renderModal ( { isOpen : true , onAfterOpen : afterOpenCallback } ) ;
20
- expect ( afterOpenCallback . called ) . toBeTruthy ( ) ;
20
+ afterOpenCallback . called . should . be . ok ( ) ;
21
21
} ) ;
22
22
23
23
it ( 'keeps focus inside the modal when child has no tabbable elements' , ( ) => {
24
24
let tabPrevented = false ;
25
25
const modal = renderModal ( { isOpen : true } , 'hello' ) ;
26
26
const content = mcontent ( modal ) ;
27
- expect ( document . activeElement ) . toEqual ( content ) ;
27
+ document . activeElement . should . be . eql ( content ) ;
28
28
tabKeyDown ( content , {
29
29
preventDefault ( ) { tabPrevented = true ; }
30
30
} ) ;
31
- expect ( tabPrevented ) . toEqual ( true ) ;
31
+ tabPrevented . should . be . eql ( true ) ;
32
32
} ) ;
33
33
34
34
it ( 'handles case when child has no tabbable elements' , ( ) => {
35
35
const modal = renderModal ( { isOpen : true } , 'hello' ) ;
36
36
const content = mcontent ( modal ) ;
37
37
tabKeyDown ( content ) ;
38
- expect ( document . activeElement ) . toEqual ( content ) ;
38
+ document . activeElement . should . be . eql ( content ) ;
39
39
} ) ;
40
40
41
41
it ( 'should close on Esc key event' , ( ) => {
@@ -46,10 +46,10 @@ describe('Events', () => {
46
46
onRequestClose : requestCloseCallback
47
47
} ) ;
48
48
escKeyDown ( mcontent ( modal ) ) ;
49
- expect ( requestCloseCallback . called ) . toBeTruthy ( ) ;
49
+ requestCloseCallback . called . should . be . ok ( ) ;
50
50
// Check if event is passed to onRequestClose callback.
51
- const event = requestCloseCallback . getCall ( 0 ) . args [ 0 ] ;
52
- expect ( event ) . toExist ( ) ;
51
+ const ev = requestCloseCallback . getCall ( 0 ) . args [ 0 ] ;
52
+ ev . should . be . ok ( ) ;
53
53
} ) ;
54
54
55
55
describe ( 'shouldCloseOnoverlayClick' , ( ) => {
@@ -61,7 +61,7 @@ describe('Events', () => {
61
61
} ) ;
62
62
const overlay = moverlay ( modal ) ;
63
63
clickAt ( overlay ) ;
64
- expect ( ! requestCloseCallback . called ) . toBeTruthy ( ) ;
64
+ requestCloseCallback . called . should . not . be . ok ( ) ;
65
65
} ) ;
66
66
67
67
it ( 'when true, click on overlay must close' , ( ) => {
@@ -72,7 +72,7 @@ describe('Events', () => {
72
72
onRequestClose : requestCloseCallback
73
73
} ) ;
74
74
clickAt ( moverlay ( modal ) ) ;
75
- expect ( requestCloseCallback . called ) . toBeTruthy ( ) ;
75
+ requestCloseCallback . called . should . be . ok ( ) ;
76
76
} ) ;
77
77
78
78
it ( 'overlay mouse down and content mouse up, should not close' , ( ) => {
@@ -84,7 +84,7 @@ describe('Events', () => {
84
84
} ) ;
85
85
mouseDownAt ( moverlay ( modal ) ) ;
86
86
mouseUpAt ( mcontent ( modal ) ) ;
87
- expect ( ! requestCloseCallback . called ) . toBeTruthy ( ) ;
87
+ requestCloseCallback . called . should . not . be . ok ( ) ;
88
88
} ) ;
89
89
90
90
it ( 'content mouse down and overlay mouse up, should not close' , ( ) => {
@@ -96,7 +96,7 @@ describe('Events', () => {
96
96
} ) ;
97
97
mouseDownAt ( mcontent ( modal ) ) ;
98
98
mouseUpAt ( moverlay ( modal ) ) ;
99
- expect ( ! requestCloseCallback . called ) . toBeTruthy ( ) ;
99
+ requestCloseCallback . called . should . not . be . ok ( ) ;
100
100
} ) ;
101
101
} ) ;
102
102
@@ -110,7 +110,7 @@ describe('Events', () => {
110
110
hasPropagated = true ;
111
111
} ) ;
112
112
moverlay ( modal ) . dispatchEvent ( new MouseEvent ( 'click' , { bubbles : true } ) ) ;
113
- expect ( hasPropagated ) . toBeTruthy ( ) ;
113
+ hasPropagated . should . be . ok ( ) ;
114
114
} ) ;
115
115
116
116
it ( 'verify event passing on overlay click' , ( ) => {
@@ -125,9 +125,9 @@ describe('Events', () => {
125
125
// Used to test that this was the event received
126
126
fakeData : 'ABC'
127
127
} ) ;
128
- expect ( requestCloseCallback . called ) . toBeTruthy ( ) ;
128
+ requestCloseCallback . called . should . be . ok ( ) ;
129
129
// Check if event is passed to onRequestClose callback.
130
130
const event = requestCloseCallback . getCall ( 0 ) . args [ 0 ] ;
131
- expect ( event ) . toExist ( ) ;
131
+ event . should . be . ok ( ) ;
132
132
} ) ;
133
- } ) ;
133
+ } ;
0 commit comments