@@ -4,48 +4,34 @@ import renderer from 'react-test-renderer';
44
55import ActionButton from '../actionButton' ;
66
7- const TEST_ID = 'test-id' ;
8-
97describe ( 'Test ActionButton Component' , ( ) => {
108 test ( 'Match ActionButton Snapshot' , ( ) => {
119 const TEST_FN = jest . fn ( ) ;
1210 const component = renderer . create (
13- < ActionButton closeModal = { TEST_FN } > </ ActionButton >
11+ < ActionButton close = { TEST_FN } > </ ActionButton >
1412 ) ;
1513 const tree = component . toJSON ( ) ;
16-
1714 expect ( tree ) . toMatchSnapshot ( ) ;
1815 } ) ;
1916
2017 test ( 'The ActionButton actionFn' , ( ) => {
2118 const ACTION_FN = jest . fn ( ( ) => false ) ;
2219 const MODAL_FN = jest . fn ( ) ;
23- const wrapper = render (
24- < ActionButton
25- data-testid = { TEST_ID }
26- actionFn = { ACTION_FN }
27- closeModal = { MODAL_FN }
28- />
20+ const { container } = render (
21+ < ActionButton actionFn = { ACTION_FN } close = { MODAL_FN } />
2922 ) ;
30- const button = wrapper . getByTestId ( TEST_ID ) ;
31-
32- fireEvent . click ( button ) ;
23+ fireEvent . click ( container . querySelector ( '.mo-btn' ) ! ) ;
3324 expect ( ACTION_FN ) . toBeCalled ( ) ;
3425 expect ( MODAL_FN ) . toBeCalled ( ) ;
3526 } ) ;
3627
37- test ( 'The ActionButton closeModal ' , ( ) => {
28+ test ( 'The ActionButton close ' , ( ) => {
3829 const CLOSE_FN = jest . fn ( ) ;
3930 const ACTION_FN = jest . fn ( ( ) => Promise . resolve ( 1 ) ) ;
40- const wrapper = render (
41- < ActionButton
42- data-testid = { TEST_ID }
43- actionFn = { ACTION_FN }
44- closeModal = { CLOSE_FN }
45- />
31+ const { container } = render (
32+ < ActionButton actionFn = { ACTION_FN } close = { CLOSE_FN } />
4633 ) ;
47- const button = wrapper . getByTestId ( TEST_ID ) ;
48-
34+ const button = container . querySelector ( '.mo-btn' ) ! ;
4935 fireEvent . click ( button ) ;
5036 expect ( ACTION_FN ) . toBeCalled ( ) ;
5137 } ) ;
0 commit comments