From 4fca00ec9de9a62cc927fd9019679c79393fb1ee Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Thu, 23 Jun 2016 00:03:04 +0900 Subject: [PATCH] Add tests for settings --- src/browser/settings.jsx | 9 ++--- test/specs/browser/settings_test.js | 51 ++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/src/browser/settings.jsx b/src/browser/settings.jsx index 1cab5007..d38b213e 100644 --- a/src/browser/settings.jsx +++ b/src/browser/settings.jsx @@ -141,8 +141,8 @@ var SettingsPage = React.createClass({ onChange={ this.handleChangeHideMenuBar } />); } if (process.platform === 'darwin' || process.platform === 'linux') { - options.push(); + options.push(); } if (process.platform === 'linux') { options.push( @@ -154,7 +154,8 @@ var SettingsPage = React.createClass({ checked={ this.state.disablewebsecurity } onChange={ this.handleChangeDisableWebSecurity } />); //OSX has an option in the Dock, to set the app to autostart, so we choose to not support this option for OSX if (process.platform === 'win32' || process.platform === 'linux') { - options.push(); + options.push(); } var options_row = (options.length > 0) ? ( @@ -193,7 +194,7 @@ var SettingsPage = React.createClass({ }); notifications_row = ( - +

Notifications

Configure, that the taskicon in the taskbar blinks when new message arrives. { notificationElements } diff --git a/test/specs/browser/settings_test.js b/test/specs/browser/settings_test.js index 093e9c24..87b7e0de 100644 --- a/test/specs/browser/settings_test.js +++ b/test/specs/browser/settings_test.js @@ -84,20 +84,26 @@ describe('browser/settings.html', function() { }); }); - it('should be saved as config.json', function() { - env.shouldTestForPlatforms(this, ['win32', 'linux']); - return this.app.restart().then(() => { + [true, false].forEach(function(v) { + it(`should be saved as config.json: ${v}`, function() { + env.shouldTestForPlatforms(this, ['win32', 'linux']); + return this.app.restart().then(() => { addClientCommands(this.app.client); return this.app.client .loadSettingsPage() - .click('#inputHideMenuBar input') + .isSelected('#inputHideMenuBar input').then((isSelected) => { + if (isSelected !== v) { + return this.app.client.click('#inputHideMenuBar input') + } + }) .click('#btnSave') .pause(1000) - }) - .then(() => { - const saved_config = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8')); - saved_config.hideMenuBar.should.be.true; + .then(() => { + const saved_config = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8')); + saved_config.hideMenuBar.should.equal(v); + }); }); + }); }); }); @@ -143,7 +149,36 @@ describe('browser/settings.html', function() { }); }); }); + }); + describe('Start app on login', function() { + it('should appear on win32 or linux', function() { + const expected = (process.platform === 'win32' || process.platform === 'linux'); + addClientCommands(this.app.client); + return this.app.client + .loadSettingsPage() + .isExisting('#inputAutoStart').should.eventually.equal(expected) + }); + }); + + describe('Show tray icon', function() { + it('should appear on darwin or linux', function() { + const expected = (process.platform === 'darwin' || process.platform === 'linux'); + addClientCommands(this.app.client); + return this.app.client + .loadSettingsPage() + .isExisting('#inputShowTrayIcon').should.eventually.equal(expected) + }); + }); + + describe('Notifications', function() { + it('should appear on win32', function() { + const expected = (process.platform === 'win32'); + addClientCommands(this.app.client); + return this.app.client + .loadSettingsPage() + .isExisting('#notificationsRow').should.eventually.equal(expected) + }); }); }); });