mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-22 17:06:24 -06:00
fix auto launch controller failing test
This commit is contained in:
parent
9e347bab77
commit
5adc162b2e
@ -8,7 +8,7 @@ const appName: string = 'Symphony';
|
||||
const executableName: string = '/Symphony.exe';
|
||||
const isReady: boolean = true;
|
||||
const version: string = '4.0.0';
|
||||
const openAtLogin: boolean = true;
|
||||
|
||||
interface IApp {
|
||||
commandLine: any;
|
||||
getAppPath(): string;
|
||||
@ -20,9 +20,9 @@ interface IApp {
|
||||
once(eventName: any, cb: any): void;
|
||||
setPath(value: string, path: string): void;
|
||||
setLoginItemSettings(settings: { openAtLogin: boolean, path: string }): void;
|
||||
getLoginItemSettings(options?: { path: string, args: string[] }): LoginItemSettings;
|
||||
getLoginItemSettings(options?: { path: string, args: string[] }): ILoginItemSettings;
|
||||
}
|
||||
interface LoginItemSettings {
|
||||
interface ILoginItemSettings {
|
||||
openAtLogin: boolean;
|
||||
}
|
||||
interface IIpcMain {
|
||||
@ -74,7 +74,9 @@ export const app: IApp = {
|
||||
ipcEmitter.on(eventName, cb);
|
||||
},
|
||||
setLoginItemSettings: () => jest.fn(),
|
||||
getLoginItemSettings: () => { openAtLogin },
|
||||
getLoginItemSettings: (): ILoginItemSettings => {
|
||||
return { openAtLogin: true };
|
||||
},
|
||||
};
|
||||
|
||||
// simple ipc mocks for render and main process ipc using
|
||||
|
@ -66,7 +66,7 @@ describe('auto launch controller', async () => {
|
||||
});
|
||||
const spyFn = 'disableAutoLaunch';
|
||||
const spy = jest.spyOn(autoLaunchInstance, spyFn);
|
||||
jest.spyOn(autoLaunchInstance,'isAutoLaunchEnabled').mockImplementation(() => true);
|
||||
jest.spyOn(autoLaunchInstance,'isAutoLaunchEnabled').mockImplementation(() => ({openAtLogin: true}));
|
||||
await autoLaunchInstance.handleAutoLaunch();
|
||||
console.log(autoLaunchInstance.isAutoLaunchEnabled());
|
||||
expect(spy).toBeCalled();
|
||||
|
@ -57,15 +57,12 @@ class AutoLaunchController {
|
||||
const { launchOnStartup }: IConfig = config.getConfigFields([ 'launchOnStartup' ]);
|
||||
const { openAtLogin: isAutoLaunchEnabled }: LoginItemSettings = this.isAutoLaunchEnabled();
|
||||
|
||||
console.log(this.isAutoLaunchEnabled());
|
||||
|
||||
if (typeof launchOnStartup === 'boolean' && launchOnStartup) {
|
||||
if (!isAutoLaunchEnabled) {
|
||||
this.enableAutoLaunch();
|
||||
}
|
||||
return;
|
||||
}
|
||||
console.log(`Auto launch enabled!! ${isAutoLaunchEnabled}`)
|
||||
if (isAutoLaunchEnabled) {
|
||||
this.disableAutoLaunch();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user