Add tests for settings

This commit is contained in:
Yuya Ochiai
2016-06-23 00:03:04 +09:00
parent f432846a28
commit 4fca00ec9d
2 changed files with 48 additions and 12 deletions

View File

@@ -141,8 +141,8 @@ var SettingsPage = React.createClass({
onChange={ this.handleChangeHideMenuBar } />);
}
if (process.platform === 'darwin' || process.platform === 'linux') {
options.push(<Input key="inputShowTrayIcon" ref="showTrayIcon" type="checkbox" label="Show Icon on Menu Bar (Need to restart the application)" checked={ this.state.showTrayIcon } onChange={ this.handleChangeShowTrayIcon }
/>);
options.push(<Input key="inputShowTrayIcon" id="inputShowTrayIcon" ref="showTrayIcon" type="checkbox" label="Show Icon on Menu Bar (Need to restart the application)" checked={ this.state.showTrayIcon }
onChange={ this.handleChangeShowTrayIcon } />);
}
if (process.platform === 'linux') {
options.push(<Input key="inputTrayIconTheme" ref="trayIconTheme" type="select" label="Icon theme (Need to restart the application)" value={ this.state.trayIconTheme } onChange={ this.handleChangeTrayIconTheme }>
@@ -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(<Input key="inputAutoStart" ref="autostart" type="checkbox" label="Start app on login." checked={ this.state.autostart } onChange={ this.handleChangeAutoStart } />);
options.push(<Input key="inputAutoStart" id="inputAutoStart" ref="autostart" type="checkbox" label="Start app on login." checked={ this.state.autostart } onChange={ this.handleChangeAutoStart }
/>);
}
var options_row = (options.length > 0) ? (
<Row>
@@ -193,7 +194,7 @@ var SettingsPage = React.createClass({
});
notifications_row = (
<Row>
<Row id="notificationsRow">
<Col md={ 12 }>
<h3>Notifications</h3> Configure, that the taskicon in the taskbar blinks when new message arrives.
{ notificationElements }

View File

@@ -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)
});
});
});
});