File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -35,11 +35,17 @@ describe('ProjectFetcherHOC', () => {
3535 expect ( mockSetProjectIdFunc . mock . calls [ 0 ] [ 0 ] ) . toBe ( '100' ) ;
3636 } ) ;
3737 test ( 'when there is a reduxProjectId and isFetchingWithProjectId is true, it loads the project' , ( ) => {
38+ const mockedOnFetchedProject = jest . fn ( ) ;
3839 const originalLoad = storage . load ;
3940 storage . load = jest . fn ( ( type , id ) => Promise . resolve ( { data : id } ) ) ;
4041 const Component = ( { projectId} ) => < div > { projectId } </ div > ;
4142 const WrappedComponent = ProjectFetcherHOC ( Component ) ;
42- const mounted = mountWithIntl ( < WrappedComponent store = { store } /> ) ;
43+ const mounted = mountWithIntl (
44+ < WrappedComponent
45+ store = { store }
46+ onFetchedProjectData = { mockedOnFetchedProject }
47+ />
48+ ) ;
4349 mounted . setProps ( {
4450 reduxProjectId : '100' ,
4551 isFetchingWithId : true ,
@@ -49,5 +55,10 @@ describe('ProjectFetcherHOC', () => {
4955 storage . AssetType . Project , '100' , storage . DataFormat . JSON
5056 ) ;
5157 storage . load = originalLoad ;
58+ // nextTick needed since storage.load is async, and onFetchedProject is called in its then()
59+ process . nextTick (
60+ ( ) => expect ( mockedOnFetchedProject )
61+ . toHaveBeenLastCalledWith ( '100' , LoadingState . FETCHING_WITH_ID )
62+ ) ;
5263 } ) ;
5364} ) ;
You can’t perform that action at this time.
0 commit comments