Skip to content

Commit 966860b

Browse files
committed
Fix Axios mocks in ToggleLocale.spec.jsx
1 parent ee50bcc commit 966860b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: client/app/widgets/ToggleLocale/__tests__/ToggleLocale.spec.jsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,21 @@ describe('ToggleLocale', () => {
1313
beforeEach(() => {
1414
jest.spyOn(Cookies, 'get').mockImplementation(() => 'en');
1515
jest.spyOn(Cookies, 'set');
16-
jest.spyOn(axios, 'post').mockImplementation(() => Promise.resolve());
1716
});
1817

1918
it('does nothing if the previous locale is the same as the selected', async () => {
19+
const axiosPostSpy = jest.spyOn(axios, 'post').mockImplementation(() => Promise.resolve());
2020
render(component);
2121
await userEvent.selectOptions(screen.getByRole('combobox'), 'en');
22-
expect(axios.post).not.toHaveBeenCalled();
22+
expect(axiosPostSpy).not.toHaveBeenCalled();
2323
});
2424

2525
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());
2627
render(component);
2728
await userEvent.selectOptions(screen.getByRole('combobox'), 'es');
2829
expect(Cookies.set).toHaveBeenCalledWith('locale', 'es');
29-
expect(axios.post).toHaveBeenCalledWith('/toggle_locale', {
30+
expect(axiosPostSpy).toHaveBeenCalledWith('/toggle_locale', {
3031
locale: 'es',
3132
});
3233
});

0 commit comments

Comments
 (0)