Add tests for hideMenuBar

This commit is contained in:
Yuya Ochiai
2016-05-03 00:42:13 +09:00
parent 47486d8b8e
commit a199f09216
2 changed files with 55 additions and 6 deletions

View File

@@ -81,8 +81,8 @@ var SettingsPage = React.createClass({
var options = [];
if (process.platform === 'win32' || process.platform === 'linux') {
options.push(<Input key="inputHideMenuBar" ref="hideMenuBar" type="checkbox" label="Hide Menu Bar (Press Alt to show Menu Bar)" checked={ this.state.hideMenuBar } onChange={ this.handleChangeHideMenuBar }
/>);
options.push(<Input key="inputHideMenuBar" id="inputHideMenuBar" ref="hideMenuBar" type="checkbox" label="Hide Menu Bar (Press Alt to show Menu Bar)" checked={ this.state.hideMenuBar }
onChange={ this.handleChangeHideMenuBar } />);
}
if (process.platform === 'darwin') {
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 }

View File

@@ -6,6 +6,12 @@ const fs = require('fs');
const env = require('../../modules/environment');
function initClient(client) {
return client
.init()
.url('file://' + path.join(env.sourceRootDir, 'dist/browser/settings.html'));
}
describe('browser/settings.html', function() {
this.timeout(10000);
@@ -34,8 +40,6 @@ describe('browser/settings.html', function() {
beforeEach(function() {
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
return client.init()
.url('file://' + path.join(env.sourceRootDir, 'dist/browser/settings.html'))
});
afterEach(function() {
@@ -47,7 +51,7 @@ describe('browser/settings.html', function() {
});
it('should show index.thml when Cancel button is clicked', function() {
return client
return initClient(client)
.waitForExist('#btnCancel')
.click('#btnCancel')
.pause(1000)
@@ -59,7 +63,7 @@ describe('browser/settings.html', function() {
});
it('should show index.thml when Save button is clicked', function() {
return client
return initClient(client)
.waitForExist('#btnSave')
.click('#btnSave')
.pause(1000)
@@ -69,4 +73,49 @@ describe('browser/settings.html', function() {
})
.end();
});
describe('Options', function() {
describe('Hide Menu Bar', function() {
it('should appear on win32 or linux', function() {
return initClient(client)
.isExisting('#inputHideMenuBar').then(function(isExisting) {
if (process.platform === 'win32' || process.platform === 'linux') {
isExisting.should.be.true();
}
else {
isExisting.should.be.false();
}
})
.end();
});
if (process.platform === 'win32' || process.platform === 'linux') {
[true, false].forEach(function(v) {
it(`should be loaded from config: ${v}`, function() {
var new_config = {};
Object.assign(new_config, config);
new_config.hideMenuBar = v;
fs.writeFileSync(env.configFilePath, JSON.stringify(new_config));
return initClient(client)
.isSelected('#inputHideMenuBar input').then(function(value) {
value.should.equal(v);
})
.end();
});
});
it('should be saved as config.json', function() {
return initClient(client)
.click('#inputHideMenuBar input')
.click('#btnSave')
.pause(1000)
.then(function() {
const saved_config = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));
saved_config.hideMenuBar.should.be.true();
})
.end();
});
}
});
});
});