@@ -3,6 +3,7 @@ import { shallow } from '@edx/react-unit-test-utils';
33import Header from '@edx/frontend-component-header' ;
44
55import urls from 'data/services/lms/urls' ;
6+ import { apiHooks } from 'hooks' ;
67import LearnerDashboardHeader from '.' ;
78import { findCoursesNavClicked } from './hooks' ;
89
@@ -12,6 +13,9 @@ jest.mock('hooks', () => ({
1213 courseSearchUrl : '/course-search-url' ,
1314 } ) ) ,
1415 } ,
16+ apiHooks : {
17+ useProgramsConfig : jest . fn ( ( ) => ( { } ) ) ,
18+ } ,
1519} ) ) ;
1620jest . mock ( './hooks' , ( ) => ( {
1721 ...jest . requireActual ( './hooks' ) ,
@@ -29,7 +33,13 @@ describe('LearnerDashboardHeader', () => {
2933 expect ( wrapper . instance . findByType ( 'ConfirmEmailBanner' ) ) . toHaveLength ( 1 ) ;
3034 expect ( wrapper . instance . findByType ( 'MasqueradeBar' ) ) . toHaveLength ( 1 ) ;
3135 expect ( wrapper . instance . findByType ( Header ) ) . toHaveLength ( 1 ) ;
32- wrapper . instance . findByType ( Header ) [ 0 ] . props . mainMenuItems [ 2 ] . onClick ( ) ;
36+ wrapper . instance . findByType ( Header ) [ 0 ] . props . mainMenuItems [ 1 ] . onClick ( ) ;
3337 expect ( findCoursesNavClicked ) . toHaveBeenCalledWith ( urls . baseAppUrl ( '/course-search-url' ) ) ;
38+ expect ( wrapper . instance . findByType ( Header ) [ 0 ] . props . mainMenuItems . length ) . toBe ( 2 ) ;
39+ } ) ;
40+ test ( 'should display Programs link if the service is configured in the backend' , ( ) => {
41+ apiHooks . useProgramsConfig . mockReturnValue ( { enabled : true } ) ;
42+ const wrapper = shallow ( < LearnerDashboardHeader /> ) ;
43+ expect ( wrapper . instance . findByType ( Header ) [ 0 ] . props . mainMenuItems . length ) . toBe ( 3 ) ;
3444 } ) ;
3545} ) ;
0 commit comments