SymphonyElectron/spec/autoLaunchController.spec.ts
Vishwas Shashidhar c09eabbc8b
feat: ELECTRON-1463: support linux build (#770)
* ELECTRON-1463: support linux build

* ELECTRON-1463: add scripts for linux build

* ELECTRON-1463: fix unit tests

* ELECTRON-1463: fix logger issue

* ELECTRON-1463: fix menu not showing up

* ELECTRON-1463: add screen-snippet functionality for linux

* ELECTRON-1463: fix log path for linux

* ELECTRON-1463: fix config path for linux

* ELECTRON-1463: fix config path for linux

* ELECTRON-1463: fix path in spellchecker

* ELECTRON-1463: fix log path issues

* ELECTRON-1463: remove unneeded dependencies and support rpm
2019-08-20 14:30:13 +05:30

74 lines
2.4 KiB
TypeScript

import { autoLaunchInstance } from '../src/app/auto-launch-controller';
import { config } from '../src/app/config-handler';
import { app } from './__mocks__/electron';
jest.mock('electron-log');
jest.mock('../src/app/config-handler', () => {
return {
config: {
getGlobalConfigFields: jest.fn(() => ''),
getConfigFields: jest.fn(() => {
return {
launchOnStartup: true,
};
}),
updateUserConfig: jest.fn(),
},
};
});
describe('auto launch controller', async () => {
beforeEach(() => {
jest.spyOn(config, 'getConfigFields').mockImplementation(() => {
return {
launchOnStartup: true,
};
});
jest.clearAllMocks();
});
it('should call `enableAutoLaunch` correctly', async () => {
const spyFn = 'setLoginItemSettings';
const spy = jest.spyOn(app, spyFn);
await autoLaunchInstance.enableAutoLaunch();
expect(spy).toBeCalled();
});
it('should call `disableAutoLaunch` correctly', async () => {
const spyFn = 'setLoginItemSettings';
const spy = jest.spyOn(app, spyFn);
await autoLaunchInstance.disableAutoLaunch();
expect(spy).toBeCalled();
});
it('should call `isAutoLaunchEnabled` correctly', async () => {
const spyFn = 'getLoginItemSettings';
const spy = jest.spyOn(app, spyFn);
await autoLaunchInstance.isAutoLaunchEnabled();
expect(spy).toBeCalled();
});
it('should enable AutoLaunch when `handleAutoLaunch` is called', async () => {
const spyFn = 'enableAutoLaunch';
const spy = jest.spyOn(autoLaunchInstance, spyFn);
jest.spyOn(autoLaunchInstance,'isAutoLaunchEnabled').mockImplementation(() => false);
await autoLaunchInstance.handleAutoLaunch();
expect(spy).toBeCalled();
});
it('should disable AutoLaunch when `handleAutoLaunch` is called', async () => {
jest.spyOn(config, 'getConfigFields').mockImplementation(() => {
return {
launchOnStartup: false,
};
});
const spyFn = 'disableAutoLaunch';
const spy = jest.spyOn(autoLaunchInstance, spyFn);
jest.spyOn(autoLaunchInstance,'isAutoLaunchEnabled').mockImplementation(() => ({openAtLogin: true}));
await autoLaunchInstance.handleAutoLaunch();
expect(spy).toBeCalled();
});
});