Skip to content

Commit

Permalink
tests: assert that ipc channel is called to change language setting n…
Browse files Browse the repository at this point in the history
  • Loading branch information
emlys committed Jul 20, 2023
1 parent 659065c commit 9a8d547
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions workbench/tests/main/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ describe('createWindow', () => {
const expectedOnChannels = [
ipcMainChannels.DOWNLOAD_URL,
ipcMainChannels.GET_ELECTRON_PATHS,
ipcMainChannels.GET_LANGUAGE,
ipcMainChannels.INVEST_RUN,
ipcMainChannels.INVEST_KILL,
ipcMainChannels.INVEST_READ_LOG,
Expand Down
6 changes: 5 additions & 1 deletion workbench/tests/renderer/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
saveSettingsStore,
clearSettingsStore,
} from '../../src/renderer/components/SettingsModal/SettingsStorage';
import { ipcMainChannels } from '../../src/main/ipcMainChannels';
import { mockUISpec } from './utils';
// It's quite a pain to dynamically mock a const from a module,
// here we do it by importing as another object, then
Expand Down Expand Up @@ -434,6 +435,8 @@ describe('InVEST global settings: dialog interactions', () => {
const tgLoggingLevel = 'DEBUG';
const languageValue = 'es';

const spy = jest.spyOn(ipcRenderer, 'invoke')

const {
getByText, getByRole, getByLabelText, findByRole,
} = render(
Expand Down Expand Up @@ -467,7 +470,8 @@ describe('InVEST global settings: dialog interactions', () => {
expect(await getSettingsValue('nWorkers')).toBe(nWorkersValue);
expect(await getSettingsValue('loggingLevel')).toBe(loggingLevel);
expect(await getSettingsValue('taskgraphLoggingLevel')).toBe(tgLoggingLevel);
expect(Store.get.toHaveBeenCalled());

expect(spy).toHaveBeenCalledWith(ipcMainChannels.CHANGE_LANGUAGE, languageValue);
});

test('Load invest settings from storage and test Reset', async () => {
Expand Down

0 comments on commit 9a8d547

Please sign in to comment.