@@ -3,7 +3,6 @@ import { shallow } from '@edx/react-unit-test-utils';
33
44import { useDispatch } from 'react-redux' ;
55
6- import { formatMessage } from 'testUtils' ;
76import * as hooks from './hooks' ;
87import { StartGradingButton } from '.' ;
98
@@ -14,13 +13,10 @@ jest.mock('./hooks', () => ({
1413 buttonHooks : jest . fn ( ) ,
1514} ) ) ;
1615
17- const intl = { formatMessage } ;
18-
1916let el ;
2017describe ( 'StartGradingButton component' , ( ) => {
2118 describe ( 'component' , ( ) => {
2219 const dispatch = useDispatch ( ) ;
23- const props = { intl } ;
2420 const buttonHooks = {
2521 hide : false ,
2622 buttonArgs : { props : 'hooks.buttonArgs' } ,
@@ -30,20 +26,21 @@ describe('StartGradingButton component', () => {
3026 describe ( 'behavior' , ( ) => {
3127 it ( 'initializes buttonHooks with dispatch and intl fields' , ( ) => {
3228 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 ) ;
3532 } ) ;
3633 } ) ;
3734 describe ( 'snapshots' , ( ) => {
3835 test ( 'hide: renders empty component if hook.hide is true' , ( ) => {
3936 hooks . buttonHooks . mockReturnValueOnce ( { ...buttonHooks , hide : true } ) ;
40- el = shallow ( < StartGradingButton { ... props } /> ) ;
37+ el = shallow ( < StartGradingButton /> ) ;
4138 expect ( el . snapshot ) . toMatchSnapshot ( ) ;
4239 expect ( el . isEmptyRender ( ) ) . toEqual ( true ) ;
4340 } ) ;
4441 test ( 'smoke test: forwards props to components from hooks' , ( ) => {
4542 hooks . buttonHooks . mockReturnValueOnce ( buttonHooks ) ;
46- el = shallow ( < StartGradingButton { ... props } /> ) ;
43+ el = shallow ( < StartGradingButton /> ) ;
4744 expect ( el . snapshot ) . toMatchSnapshot ( ) ;
4845 expect ( el . isEmptyRender ( ) ) . toEqual ( false ) ;
4946 } ) ;
0 commit comments