11import { changeUserSessionLanguage } from './languageManager' ;
2- import { getConfig } from '../config' ;
3- import { getCookies , handleRtl , LOCALE_CHANGED } from './lib' ;
2+ import { handleRtl , LOCALE_CHANGED } from './lib' ;
43import { logError } from '../logging' ;
54import { publish } from '../pubSub' ;
65import { updateAuthenticatedUserPreferences , setSessionLanguage } from './languageApi' ;
76
8- jest . mock ( '../config' ) ;
97jest . mock ( './lib' ) ;
108jest . mock ( '../logging' ) ;
119jest . mock ( '../pubSub' ) ;
1210jest . mock ( './languageApi' ) ;
1311
14- const LMS_BASE_URL = 'http://test.lms' ;
15- const LANGUAGE_PREFERENCE_COOKIE_NAME = 'lang' ;
16-
1712describe ( 'languageManager' , ( ) => {
18- let mockCookies ;
1913 let mockReload ;
2014
2115 beforeEach ( ( ) => {
2216 jest . clearAllMocks ( ) ;
23- getConfig . mockReturnValue ( {
24- LMS_BASE_URL ,
25- LANGUAGE_PREFERENCE_COOKIE_NAME ,
26- } ) ;
27-
28- mockCookies = { set : jest . fn ( ) } ;
29- getCookies . mockReturnValue ( mockCookies ) ;
3017
3118 mockReload = jest . fn ( ) ;
3219 Object . defineProperty ( window , 'location' , {
@@ -42,11 +29,6 @@ describe('languageManager', () => {
4229 describe ( 'changeUserSessionLanguage' , ( ) => {
4330 it ( 'should perform complete language change process' , async ( ) => {
4431 await changeUserSessionLanguage ( 'fr' ) ;
45-
46- expect ( getCookies ( ) . set ) . toHaveBeenCalledWith (
47- LANGUAGE_PREFERENCE_COOKIE_NAME ,
48- 'fr' ,
49- ) ;
5032 expect ( updateAuthenticatedUserPreferences ) . toHaveBeenCalledWith ( {
5133 prefLang : 'fr' ,
5234 } ) ;
0 commit comments