Modify test-code style for 'Hide Manu Bar'

This commit is contained in:
Yuya Ochiai
2016-06-22 00:35:04 +09:00
parent 2347d5e299
commit f432846a28

View File

@@ -5,12 +5,6 @@ const fs = require('fs');
const env = require('../../modules/environment'); const env = require('../../modules/environment');
function initClient(client) {
return client
.url('file://' + path.join(env.sourceRootDir, 'dist/browser/settings.html'))
.waitUntilWindowLoaded();
}
function addClientCommands(client) { function addClientCommands(client) {
client.addCommand('loadSettingsPage', function() { client.addCommand('loadSettingsPage', function() {
return this return this
@@ -46,14 +40,18 @@ describe('browser/settings.html', function() {
}); });
it('should show index.thml when Cancel button is clicked', function() { it('should show index.thml when Cancel button is clicked', function() {
return initClient(this.app.client) addClientCommands(this.app.client);
return this.app.client
.loadSettingsPage()
.click('#btnCancel') .click('#btnCancel')
.pause(1000) .pause(1000)
.getUrl().should.eventually.match(/\/index.html$/) .getUrl().should.eventually.match(/\/index.html$/)
}); });
it('should show index.thml when Save button is clicked', function() { it('should show index.thml when Save button is clicked', function() {
return initClient(this.app.client) addClientCommands(this.app.client);
return this.app.client
.loadSettingsPage()
.click('#btnSave') .click('#btnSave')
.pause(1000) .pause(1000)
.getUrl().should.eventually.match(/\/index.html$/) .getUrl().should.eventually.match(/\/index.html$/)
@@ -63,7 +61,9 @@ describe('browser/settings.html', function() {
describe('Hide Menu Bar', function() { describe('Hide Menu Bar', function() {
it('should appear on win32 or linux', function() { it('should appear on win32 or linux', function() {
const expected = (process.platform === 'win32' || process.platform === 'linux'); const expected = (process.platform === 'win32' || process.platform === 'linux');
return initClient(this.app.client) addClientCommands(this.app.client);
return this.app.client
.loadSettingsPage()
.isExisting('#inputHideMenuBar').should.eventually.equal(expected) .isExisting('#inputHideMenuBar').should.eventually.equal(expected)
}); });
@@ -75,7 +75,9 @@ describe('browser/settings.html', function() {
new_config.hideMenuBar = v; new_config.hideMenuBar = v;
fs.writeFileSync(env.configFilePath, JSON.stringify(new_config)); fs.writeFileSync(env.configFilePath, JSON.stringify(new_config));
return this.app.restart().then(() => { return this.app.restart().then(() => {
return initClient(this.app.client) addClientCommands(this.app.client);
return this.app.client
.loadSettingsPage()
.isSelected('#inputHideMenuBar input').should.eventually.equal(v) .isSelected('#inputHideMenuBar input').should.eventually.equal(v)
.browserWindow.isMenuBarAutoHide().should.eventually.equal(v); .browserWindow.isMenuBarAutoHide().should.eventually.equal(v);
}); });
@@ -85,7 +87,9 @@ describe('browser/settings.html', function() {
it('should be saved as config.json', function() { it('should be saved as config.json', function() {
env.shouldTestForPlatforms(this, ['win32', 'linux']); env.shouldTestForPlatforms(this, ['win32', 'linux']);
return this.app.restart().then(() => { return this.app.restart().then(() => {
return initClient(this.app.client) addClientCommands(this.app.client);
return this.app.client
.loadSettingsPage()
.click('#inputHideMenuBar input') .click('#inputHideMenuBar input')
.click('#btnSave') .click('#btnSave')
.pause(1000) .pause(1000)