@@ -3,30 +3,24 @@ import { render, screen, waitFor } from '@testing-library/react';
33import { IntlProvider } from '@edx/frontend-platform/i18n' ;
44import { getConfig } from '@edx/frontend-platform' ;
55
6- import { RequestKeys } from 'data/constants/requests' ;
7- import { reduxHooks } from 'hooks' ;
6+ import { useInitializeLearnerHome } from 'data/hooks' ;
87import { App } from './App' ;
98import messages from './messages' ;
109
10+ jest . mock ( 'data/hooks' , ( ) => ( {
11+ useInitializeLearnerHome : jest . fn ( ) ,
12+ } ) ) ;
13+
14+ jest . mock ( 'data/context' , ( ) => ( {
15+ useMasquerade : jest . fn ( ( ) => ( { masqueradeUser : null } ) ) ,
16+ } ) ) ;
17+
1118jest . mock ( '@edx/frontend-component-footer' , ( ) => ( {
1219 FooterSlot : jest . fn ( ( ) => < div > FooterSlot</ div > ) ,
1320} ) ) ;
1421jest . mock ( 'containers/Dashboard' , ( ) => jest . fn ( ( ) => < div > Dashboard</ div > ) ) ;
1522jest . mock ( 'containers/LearnerDashboardHeader' , ( ) => jest . fn ( ( ) => < div > LearnerDashboardHeader</ div > ) ) ;
1623jest . mock ( 'containers/AppWrapper' , ( ) => jest . fn ( ( { children } ) => < div className = "AppWrapper" > { children } </ div > ) ) ;
17- jest . mock ( 'data/redux' , ( ) => ( {
18- selectors : 'redux.selectors' ,
19- actions : 'redux.actions' ,
20- thunkActions : 'redux.thunkActions' ,
21- } ) ) ;
22- jest . mock ( 'hooks' , ( ) => ( {
23- reduxHooks : {
24- useRequestIsFailed : jest . fn ( ) ,
25- usePlatformSettingsData : jest . fn ( ) ,
26- useLoadData : jest . fn ( ) ,
27- } ,
28- } ) ) ;
29- jest . mock ( 'data/store' , ( ) => 'data/store' ) ;
3024
3125jest . mock ( '@edx/frontend-platform' , ( ) => ( {
3226 getConfig : jest . fn ( ( ) => ( { } ) ) ,
@@ -37,11 +31,15 @@ jest.mock('@edx/frontend-platform/react', () => ({
3731 ErrorPage : ( ) => 'ErrorPage' ,
3832} ) ) ;
3933
40- const loadData = jest . fn ( ) ;
41- reduxHooks . useLoadData . mockReturnValue ( loadData ) ;
42-
4334const supportEmail = 'test@support.com' ;
44- reduxHooks . usePlatformSettingsData . mockReturnValue ( { supportEmail } ) ;
35+ useInitializeLearnerHome . mockReturnValue ( {
36+ data : {
37+ platformSettings : {
38+ supportEmail,
39+ } ,
40+ } ,
41+ isError : false ,
42+ } ) ;
4543
4644describe ( 'App router component' , ( ) => {
4745 describe ( 'component' , ( ) => {
@@ -66,7 +64,6 @@ describe('App router component', () => {
6664 describe ( 'no network failure' , ( ) => {
6765 beforeEach ( ( ) => {
6866 jest . clearAllMocks ( ) ;
69- reduxHooks . useRequestIsFailed . mockReturnValue ( false ) ;
7067 getConfig . mockReturnValue ( { } ) ;
7168 render ( < IntlProvider locale = "en" > < App /> </ IntlProvider > ) ;
7269 } ) ;
@@ -79,7 +76,6 @@ describe('App router component', () => {
7976 describe ( 'no network failure with optimizely url' , ( ) => {
8077 beforeEach ( ( ) => {
8178 jest . clearAllMocks ( ) ;
82- reduxHooks . useRequestIsFailed . mockReturnValue ( false ) ;
8379 getConfig . mockReturnValue ( { OPTIMIZELY_URL : 'fake.url' } ) ;
8480 render ( < IntlProvider locale = "en" > < App /> </ IntlProvider > ) ;
8581 } ) ;
@@ -92,7 +88,6 @@ describe('App router component', () => {
9288 describe ( 'no network failure with optimizely project id' , ( ) => {
9389 beforeEach ( ( ) => {
9490 jest . clearAllMocks ( ) ;
95- reduxHooks . useRequestIsFailed . mockReturnValue ( false ) ;
9691 getConfig . mockReturnValue ( { OPTIMIZELY_PROJECT_ID : 'fakeId' } ) ;
9792 render ( < IntlProvider locale = "en" > < App /> </ IntlProvider > ) ;
9893 } ) ;
@@ -105,7 +100,10 @@ describe('App router component', () => {
105100 describe ( 'initialize failure' , ( ) => {
106101 beforeEach ( ( ) => {
107102 jest . clearAllMocks ( ) ;
108- reduxHooks . useRequestIsFailed . mockImplementation ( ( key ) => key === RequestKeys . initialize ) ;
103+ useInitializeLearnerHome . mockReturnValue ( {
104+ data : null ,
105+ isError : true ,
106+ } ) ;
109107 getConfig . mockReturnValue ( { } ) ;
110108 render ( < IntlProvider locale = "en" messages = { messages } > < App /> </ IntlProvider > ) ;
111109 } ) ;
@@ -119,7 +117,6 @@ describe('App router component', () => {
119117 } ) ;
120118 describe ( 'refresh failure' , ( ) => {
121119 beforeEach ( ( ) => {
122- reduxHooks . useRequestIsFailed . mockImplementation ( ( key ) => key === RequestKeys . refreshList ) ;
123120 getConfig . mockReturnValue ( { } ) ;
124121 render ( < IntlProvider locale = "en" > < App /> </ IntlProvider > ) ;
125122 } ) ;
0 commit comments