File tree 1 file changed +4
-3
lines changed
client/app/widgets/ToggleLocale/__tests__
1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -13,20 +13,21 @@ describe('ToggleLocale', () => {
13
13
beforeEach ( ( ) => {
14
14
jest . spyOn ( Cookies , 'get' ) . mockImplementation ( ( ) => 'en' ) ;
15
15
jest . spyOn ( Cookies , 'set' ) ;
16
- jest . spyOn ( axios , 'post' ) . mockImplementation ( ( ) => Promise . resolve ( ) ) ;
17
16
} ) ;
18
17
19
18
it ( 'does nothing if the previous locale is the same as the selected' , async ( ) => {
19
+ const axiosPostSpy = jest . spyOn ( axios , 'post' ) . mockImplementation ( ( ) => Promise . resolve ( ) ) ;
20
20
render ( component ) ;
21
21
await userEvent . selectOptions ( screen . getByRole ( 'combobox' ) , 'en' ) ;
22
- expect ( axios . post ) . not . toHaveBeenCalled ( ) ;
22
+ expect ( axiosPostSpy ) . not . toHaveBeenCalled ( ) ;
23
23
} ) ;
24
24
25
25
it ( 'sets the locale cookie and makes a post request if the selected locale is different from the previous' , async ( ) => {
26
+ const axiosPostSpy = jest . spyOn ( axios , 'post' ) . mockImplementation ( ( ) => Promise . resolve ( ) ) ;
26
27
render ( component ) ;
27
28
await userEvent . selectOptions ( screen . getByRole ( 'combobox' ) , 'es' ) ;
28
29
expect ( Cookies . set ) . toHaveBeenCalledWith ( 'locale' , 'es' ) ;
29
- expect ( axios . post ) . toHaveBeenCalledWith ( '/toggle_locale' , {
30
+ expect ( axiosPostSpy ) . toHaveBeenCalledWith ( '/toggle_locale' , {
30
31
locale : 'es' ,
31
32
} ) ;
32
33
} ) ;
You can’t perform that action at this time.
0 commit comments