Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("sets the synchronizing icon when receiving a synchronizing event", async () => {
await expect(handler({newState: Synchronizing})).resolves.not.toBeDefined();
expect(menubarMock.tray.setImage).toHaveBeenCalledWith(icons.getSyncIcon());
expect(menubarMock.appState).toEqual(Synchronizing);
});
it("starts the sia backend if sia conf is true but not running", async () => {
getConfig.mockResolvedValueOnce({
sia: true,
syncFolder,
});
await popup();
expect(getConfig).toHaveBeenCalled();
expect(siaStart).toHaveBeenCalledWith(syncFolder);
expect(app.quit).not.toHaveBeenCalled();
expect(menubarMock.tray.setImage).toHaveBeenCalledWith(
icons.getSyncIcon()
);
expect(menubarMock.appState).toEqual(Synchronizing);
});
it("sets the idle icon when receiving an idle event", async () => {
await expect(handler({newState: Idle})).resolves.not.toBeDefined();
expect(menubarMock.tray.setImage).toHaveBeenCalledWith(icons.getIdleIcon());
expect(menubarMock.appState).toEqual(Idle);
});
it("sets the paused icon when the state is Paused", async () => {
await expect(handler(Paused)).resolves.toEqual(Paused);
expect(menubarMock.tray.setImage).toHaveBeenCalledWith(
icons.getPausedIcon()
);
expect(menubarMock.appState).toEqual(Paused);
});
it("sets the idle icon when the state is Synchronizing", async () => {
await expect(handler(Synchronizing)).resolves.toEqual(Synchronizing);
expect(menubarMock.tray.setImage).toHaveBeenCalledWith(
icons.getSyncIcon()
);
expect(menubarMock.appState).toEqual(Synchronizing);
});
beforeAll(() => {
originalPlatform = process.platform;
Object.defineProperty(process, "platform", {
value: "darwin",
});
desktop.register.mockImplementation(() => {});
menubarMock.tray.listeners.mockReturnValue([() => null]);
});
const getTrayEventHandler = event =>
getEventHandler(menubarMock.tray, event);
const menuItems = "sample menu items";