@@ -2,7 +2,7 @@ import { useSelector } from 'react-redux';
22import { getConfig , setConfig } from '@edx/frontend-platform' ;
33import { renderHook } from '@testing-library/react' ;
44import messages from './messages' ;
5- import { useContentMenuItems , useToolsMenuItems , useSettingMenuItems } from './hooks' ;
5+ import { useContentMenuItems , useToolsMenuItems , useSettingMenuItems , useLibrarySettingsMenuItems , useLibraryToolsMenuItems } from './hooks' ;
66import { mockWaffleFlags } from '../data/apiHooks.mock' ;
77
88jest . mock ( '@edx/frontend-platform/i18n' , ( ) => ( {
@@ -28,7 +28,7 @@ jest.mock('react-redux', () => ({
2828describe ( 'header utils' , ( ) => {
2929 describe ( 'getContentMenuItems' , ( ) => {
3030 it ( 'when video upload page enabled should include Video Uploads option' , ( ) => {
31- useSelector . mockReturnValue ( {
31+ jest . mocked ( useSelector ) . mockReturnValue ( {
3232 librariesV2Enabled : false ,
3333 } ) ;
3434 setConfig ( {
@@ -39,7 +39,7 @@ describe('header utils', () => {
3939 expect ( actualItems ) . toHaveLength ( 5 ) ;
4040 } ) ;
4141 it ( 'when video upload page disabled should not include Video Uploads option' , ( ) => {
42- useSelector . mockReturnValue ( {
42+ jest . mocked ( useSelector ) . mockReturnValue ( {
4343 librariesV2Enabled : false ,
4444 } ) ;
4545 setConfig ( {
@@ -50,7 +50,7 @@ describe('header utils', () => {
5050 expect ( actualItems ) . toHaveLength ( 4 ) ;
5151 } ) ;
5252 it ( 'adds course libraries link to content menu when libraries v2 is enabled' , ( ) => {
53- useSelector . mockReturnValue ( {
53+ jest . mocked ( useSelector ) . mockReturnValue ( {
5454 librariesV2Enabled : true ,
5555 } ) ;
5656 const actualItems = renderHook ( ( ) => useContentMenuItems ( 'course-123' ) ) . result . current ;
@@ -60,7 +60,7 @@ describe('header utils', () => {
6060
6161 describe ( 'getSettingsMenuitems' , ( ) => {
6262 beforeEach ( ( ) => {
63- useSelector . mockReturnValue ( {
63+ jest . mocked ( useSelector ) . mockReturnValue ( {
6464 canAccessAdvancedSettings : true ,
6565 } ) ;
6666 } ) ;
@@ -86,7 +86,7 @@ describe('header utils', () => {
8686 expect ( actualItemsTitle ) . toContain ( 'Advanced Settings' ) ;
8787 } ) ;
8888 it ( 'when user has no access to advanced settings should not include advanced settings option' , ( ) => {
89- useSelector . mockReturnValue ( { canAccessAdvancedSettings : false } ) ;
89+ jest . mocked ( useSelector ) . mockReturnValue ( { canAccessAdvancedSettings : false } ) ;
9090 const actualItemsTitle = renderHook ( ( ) => useSettingMenuItems ( 'course-123' ) ) . result . current . map ( ( item ) => item . title ) ;
9191 expect ( actualItemsTitle ) . not . toContain ( 'Advanced Settings' ) ;
9292 } ) ;
@@ -137,4 +137,22 @@ describe('header utils', () => {
137137 expect ( actualItemsTitle ) . not . toContain ( messages [ 'header.links.optimizer' ] . defaultMessage ) ;
138138 } ) ;
139139 } ) ;
140+
141+ describe ( 'useLibrarySettingsMenuItems' , ( ) => {
142+ it ( 'should contain team access url' , ( ) => {
143+ const items = renderHook ( ( ) => useLibrarySettingsMenuItems ( ) ) . result . current ;
144+ expect ( items ) . toContainEqual ( { title : 'Team Access' , href : 'http://localhost/?sa=manage-team' } ) ;
145+ } ) ;
146+ } ) ;
147+
148+ describe ( 'useLibraryToolsMenuItems' , ( ) => {
149+ it ( 'should contain backup and import url' , ( ) => {
150+ const items = renderHook ( ( ) => useLibraryToolsMenuItems ( 'course-123' ) ) . result . current ;
151+ expect ( items ) . toContainEqual ( {
152+ href : '/library/course-123/backup' ,
153+ title : 'Backup to local archive'
154+ } ) ;
155+ expect ( items ) . toContainEqual ( { href : '/library/course-123/import' , title : 'Import' } ) ;
156+ } ) ;
157+ } ) ;
140158} ) ;
0 commit comments