From d69d4b253ad38796b32dff964a1c0055c530ace0 Mon Sep 17 00:00:00 2001 From: Adam Weeden Date: Tue, 22 Jun 2021 19:09:11 -0400 Subject: [PATCH] Fix tray icon always on (regression from #1235) --- app/src/components/trayIcon.ts | 2 +- src/cli.test.ts | 29 ++++++++++++++--------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/src/components/trayIcon.ts b/app/src/components/trayIcon.ts index 59d7790..e799a81 100644 --- a/app/src/components/trayIcon.ts +++ b/app/src/components/trayIcon.ts @@ -9,7 +9,7 @@ export function createTrayIcon( ): Tray { const options = { ...nativefierOptions }; - if (options.tray) { + if (options.tray && options.tray !== 'false') { const iconPath = getAppIcon(); const nimage = nativeImage.createFromPath(iconPath); const appIcon = new Tray(nativeImage.createEmpty()); diff --git a/src/cli.test.ts b/src/cli.test.ts index 0e7c0f3..a0b0ba2 100644 --- a/src/cli.test.ts +++ b/src/cli.test.ts @@ -309,23 +309,22 @@ describe('initArgs + parseArgs', () => { { arg: 'tray', value: 'false' }, { arg: 'tray', value: 'start-in-tray' }, { arg: 'tray', value: '' }, - { arg: 'tray', value: undefined }, ])('test tray valyue %s', ({ arg, value }) => { - if (value !== undefined) { - const args = parseArgs( - initArgs(['https://google.com', `--${arg}`, `${value}`]), - ) as Record; - if (value !== '') { - expect(args[arg]).toBe(value); - } else { - expect(args[arg]).toBe('true'); - } + const args = parseArgs( + initArgs(['https://google.com', `--${arg}`, `${value}`]), + ) as Record; + if (value !== '') { + expect(args[arg]).toBe(value); } else { - const args = parseArgs(initArgs(['https://google.com'])) as Record< - string, - number - >; - expect(args[arg]).toBe('false'); + expect(args[arg]).toBe('true'); } }); + + test('test tray value defaults to false', () => { + const args = parseArgs(initArgs(['https://google.com'])) as Record< + string, + number + >; + expect(args.tray).toBe('false'); + }); });