Files
mattermostest/src/main/AutoLauncher.test.js
Devin Binnie 59e4e7e516 [MM-14058] Add support for i18n (#2190)
* Add language files

* Add react-intl, mmjstool, setup for adding translations

* Translated main module

* Translations for renderer

* A few minor fixes

* More fixes

* Add CI, add missing menu translations, other cleanup

* Added setting to manually select the language of the app

* Force English for E2e

* Unit tests

* Fix mmjstool

* Move set language to before update menu

* PR feedback
2022-07-14 11:04:18 -04:00

55 lines
1.3 KiB
JavaScript

// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import AutoLaunch from 'auto-launch';
import {AutoLauncher} from './AutoLauncher';
jest.mock('auto-launch', () => jest.fn());
jest.mock('electron', () => ({
app: {
name: 'Mattermost',
},
}));
jest.mock('electron-is-dev', () => false);
jest.mock('main/i18nManager', () => ({
localizeMessage: jest.fn(),
}));
describe('main/AutoLauncher', () => {
let autoLauncher;
const isEnabled = jest.fn();
const enable = jest.fn();
const disable = jest.fn();
beforeEach(() => {
AutoLaunch.mockImplementation(() => ({
isEnabled,
enable,
disable,
}));
autoLauncher = new AutoLauncher();
});
it('should toggle enabled/disabled', async () => {
isEnabled.mockReturnValue(true);
await autoLauncher.enable();
expect(enable).not.toBeCalled();
isEnabled.mockReturnValue(false);
await autoLauncher.enable();
expect(enable).toBeCalled();
isEnabled.mockReturnValue(false);
await autoLauncher.disable();
expect(disable).not.toBeCalled();
isEnabled.mockReturnValue(true);
await autoLauncher.disable();
expect(disable).toBeCalled();
});
});