Enable minimize to tray on linux in production
This commit is contained in:
parent
2ce23c20ee
commit
beee8414a3
6 changed files with 81 additions and 48 deletions
|
@ -28,21 +28,16 @@ describe('SystemTraySettingCache', () => {
|
|||
});
|
||||
|
||||
it('returns MinimizeToAndStartInSystemTray if passed the --start-in-tray argument', async () => {
|
||||
const justOneArg = new SystemTraySettingCache(
|
||||
config,
|
||||
['--start-in-tray'],
|
||||
'1.2.3'
|
||||
);
|
||||
const justOneArg = new SystemTraySettingCache(config, ['--start-in-tray']);
|
||||
assert.strictEqual(
|
||||
await justOneArg.get(),
|
||||
SystemTraySetting.MinimizeToAndStartInSystemTray
|
||||
);
|
||||
|
||||
const bothArgs = new SystemTraySettingCache(
|
||||
config,
|
||||
['--start-in-tray', '--use-tray-icon'],
|
||||
'1.2.3'
|
||||
);
|
||||
const bothArgs = new SystemTraySettingCache(config, [
|
||||
'--start-in-tray',
|
||||
'--use-tray-icon',
|
||||
]);
|
||||
assert.strictEqual(
|
||||
await bothArgs.get(),
|
||||
SystemTraySetting.MinimizeToAndStartInSystemTray
|
||||
|
@ -53,11 +48,7 @@ describe('SystemTraySettingCache', () => {
|
|||
});
|
||||
|
||||
it('returns MinimizeToSystemTray if passed the --use-tray-icon argument', async () => {
|
||||
const cache = new SystemTraySettingCache(
|
||||
config,
|
||||
['--use-tray-icon'],
|
||||
'1.2.3'
|
||||
);
|
||||
const cache = new SystemTraySettingCache(config, ['--use-tray-icon']);
|
||||
assert.strictEqual(
|
||||
await cache.get(),
|
||||
SystemTraySetting.MinimizeToSystemTray
|
||||
|
@ -70,7 +61,7 @@ describe('SystemTraySettingCache', () => {
|
|||
it('returns Uninitialized if system tray is supported but no preference is stored', async () => {
|
||||
sandbox.stub(process, 'platform').value('win32');
|
||||
|
||||
const cache = new SystemTraySettingCache(config, [], '1.2.3');
|
||||
const cache = new SystemTraySettingCache(config, []);
|
||||
assert.strictEqual(await cache.get(), SystemTraySetting.Uninitialized);
|
||||
assert(configGetStub.calledOnceWith('system-tray-setting'));
|
||||
assert(
|
||||
|
@ -86,7 +77,7 @@ describe('SystemTraySettingCache', () => {
|
|||
|
||||
configGetStub.returns('garbage');
|
||||
|
||||
const cache = new SystemTraySettingCache(config, [], '1.2.3');
|
||||
const cache = new SystemTraySettingCache(config, []);
|
||||
assert.strictEqual(await cache.get(), SystemTraySetting.Uninitialized);
|
||||
assert(configGetStub.calledOnceWith('system-tray-setting'));
|
||||
assert(
|
||||
|
@ -102,7 +93,7 @@ describe('SystemTraySettingCache', () => {
|
|||
|
||||
configGetStub.returns('MinimizeToSystemTray');
|
||||
|
||||
const cache = new SystemTraySettingCache(config, [], '1.2.3');
|
||||
const cache = new SystemTraySettingCache(config, []);
|
||||
assert.strictEqual(
|
||||
await cache.get(),
|
||||
SystemTraySetting.MinimizeToSystemTray
|
||||
|
@ -113,7 +104,7 @@ describe('SystemTraySettingCache', () => {
|
|||
it('returns DoNotUseSystemTray if system tray is unsupported and there are no CLI flags', async () => {
|
||||
sandbox.stub(process, 'platform').value('darwin');
|
||||
|
||||
const cache = new SystemTraySettingCache(config, [], '1.2.3');
|
||||
const cache = new SystemTraySettingCache(config, []);
|
||||
assert.strictEqual(await cache.get(), SystemTraySetting.DoNotUseSystemTray);
|
||||
|
||||
sinon.assert.notCalled(configGetStub);
|
||||
|
|
|
@ -7,6 +7,7 @@ import { assert } from 'chai';
|
|||
|
||||
import { getOSFunctions } from '../../util/os/shared';
|
||||
import * as Settings from '../../types/Settings';
|
||||
import { SystemTraySetting } from '../../types/SystemTraySetting';
|
||||
|
||||
describe('Settings', () => {
|
||||
let sandbox: Sinon.SinonSandbox;
|
||||
|
@ -128,26 +129,59 @@ describe('Settings', () => {
|
|||
it('returns false on macOS', () => {
|
||||
sandbox.stub(process, 'platform').value('darwin');
|
||||
const OS = getOSFunctions(os.release());
|
||||
assert.isFalse(Settings.isSystemTraySupported(OS, '1.2.3'));
|
||||
assert.isFalse(Settings.isSystemTraySupported(OS));
|
||||
});
|
||||
|
||||
it('returns true on Windows 8', () => {
|
||||
sandbox.stub(process, 'platform').value('win32');
|
||||
sandbox.stub(os, 'release').returns('8.0.0');
|
||||
const OS = getOSFunctions(os.release());
|
||||
assert.isTrue(Settings.isSystemTraySupported(OS, '1.2.3'));
|
||||
assert.isTrue(Settings.isSystemTraySupported(OS));
|
||||
});
|
||||
|
||||
it('returns false on Linux production', () => {
|
||||
it('returns true on Linux', () => {
|
||||
sandbox.stub(process, 'platform').value('linux');
|
||||
const OS = getOSFunctions(os.release());
|
||||
assert.isFalse(Settings.isSystemTraySupported(OS, '1.2.3'));
|
||||
assert.isTrue(Settings.isSystemTraySupported(OS));
|
||||
});
|
||||
});
|
||||
|
||||
describe('getDefaultSystemTraySetting', () => {
|
||||
it('returns DoNotUseSystemTray is unsupported OS', () => {
|
||||
sandbox.stub(process, 'platform').value('darwin');
|
||||
const OS = getOSFunctions(os.release());
|
||||
assert.strictEqual(
|
||||
Settings.getDefaultSystemTraySetting(OS, '1.2.3'),
|
||||
SystemTraySetting.DoNotUseSystemTray
|
||||
);
|
||||
});
|
||||
|
||||
it('returns true on Linux beta', () => {
|
||||
it('returns MinimizeToSystemTray on Windows 8', () => {
|
||||
sandbox.stub(process, 'platform').value('win32');
|
||||
sandbox.stub(os, 'release').returns('8.0.0');
|
||||
const OS = getOSFunctions(os.release());
|
||||
assert.strictEqual(
|
||||
Settings.getDefaultSystemTraySetting(OS, '1.2.3'),
|
||||
SystemTraySetting.MinimizeToSystemTray
|
||||
);
|
||||
});
|
||||
|
||||
it('returns MinimizeToSystemTray on Linux Beta', () => {
|
||||
sandbox.stub(process, 'platform').value('linux');
|
||||
const OS = getOSFunctions(os.release());
|
||||
assert.isTrue(Settings.isSystemTraySupported(OS, '1.2.3-beta.4'));
|
||||
assert.strictEqual(
|
||||
Settings.getDefaultSystemTraySetting(OS, '1.2.3-beta.1'),
|
||||
SystemTraySetting.MinimizeToSystemTray
|
||||
);
|
||||
});
|
||||
|
||||
it('returns DoNotUseSystemTray on Linux Prod', () => {
|
||||
sandbox.stub(process, 'platform').value('linux');
|
||||
const OS = getOSFunctions(os.release());
|
||||
assert.strictEqual(
|
||||
Settings.getDefaultSystemTraySetting(OS, '1.2.3'),
|
||||
SystemTraySetting.DoNotUseSystemTray
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue