@@ -3,7 +3,6 @@ import { shallow } from '@edx/react-unit-test-utils';
3
3
4
4
import { useDispatch } from 'react-redux' ;
5
5
6
- import { formatMessage } from 'testUtils' ;
7
6
import * as hooks from './hooks' ;
8
7
import { StartGradingButton } from '.' ;
9
8
@@ -14,13 +13,10 @@ jest.mock('./hooks', () => ({
14
13
buttonHooks : jest . fn ( ) ,
15
14
} ) ) ;
16
15
17
- const intl = { formatMessage } ;
18
-
19
16
let el ;
20
17
describe ( 'StartGradingButton component' , ( ) => {
21
18
describe ( 'component' , ( ) => {
22
19
const dispatch = useDispatch ( ) ;
23
- const props = { intl } ;
24
20
const buttonHooks = {
25
21
hide : false ,
26
22
buttonArgs : { props : 'hooks.buttonArgs' } ,
@@ -30,20 +26,21 @@ describe('StartGradingButton component', () => {
30
26
describe ( 'behavior' , ( ) => {
31
27
it ( 'initializes buttonHooks with dispatch and intl fields' , ( ) => {
32
28
hooks . buttonHooks . mockReturnValueOnce ( buttonHooks ) ;
33
- el = shallow ( < StartGradingButton { ...props } /> ) ;
34
- expect ( hooks . buttonHooks ) . toHaveBeenCalledWith ( { dispatch, intl } ) ;
29
+ el = shallow ( < StartGradingButton /> ) ;
30
+ const expected = { dispatch, intl : { formatMessage : expect . any ( Function ) , formatDate : expect . any ( Function ) } } ;
31
+ expect ( hooks . buttonHooks ) . toHaveBeenCalledWith ( expected ) ;
35
32
} ) ;
36
33
} ) ;
37
34
describe ( 'snapshots' , ( ) => {
38
35
test ( 'hide: renders empty component if hook.hide is true' , ( ) => {
39
36
hooks . buttonHooks . mockReturnValueOnce ( { ...buttonHooks , hide : true } ) ;
40
- el = shallow ( < StartGradingButton { ... props } /> ) ;
37
+ el = shallow ( < StartGradingButton /> ) ;
41
38
expect ( el . snapshot ) . toMatchSnapshot ( ) ;
42
39
expect ( el . isEmptyRender ( ) ) . toEqual ( true ) ;
43
40
} ) ;
44
41
test ( 'smoke test: forwards props to components from hooks' , ( ) => {
45
42
hooks . buttonHooks . mockReturnValueOnce ( buttonHooks ) ;
46
- el = shallow ( < StartGradingButton { ... props } /> ) ;
43
+ el = shallow ( < StartGradingButton /> ) ;
47
44
expect ( el . snapshot ) . toMatchSnapshot ( ) ;
48
45
expect ( el . isEmptyRender ( ) ) . toEqual ( false ) ;
49
46
} ) ;
0 commit comments