Modify test-code style for 'Hide Manu Bar'
This commit is contained in:
parent
2347d5e299
commit
f432846a28
|
@ -5,12 +5,6 @@ const fs = require('fs');
|
|||
|
||||
const env = require('../../modules/environment');
|
||||
|
||||
function initClient(client) {
|
||||
return client
|
||||
.url('file://' + path.join(env.sourceRootDir, 'dist/browser/settings.html'))
|
||||
.waitUntilWindowLoaded();
|
||||
}
|
||||
|
||||
function addClientCommands(client) {
|
||||
client.addCommand('loadSettingsPage', function() {
|
||||
return this
|
||||
|
@ -46,14 +40,18 @@ describe('browser/settings.html', 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')
|
||||
.pause(1000)
|
||||
.getUrl().should.eventually.match(/\/index.html$/)
|
||||
});
|
||||
|
||||
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')
|
||||
.pause(1000)
|
||||
.getUrl().should.eventually.match(/\/index.html$/)
|
||||
|
@ -63,7 +61,9 @@ describe('browser/settings.html', function() {
|
|||
describe('Hide Menu Bar', function() {
|
||||
it('should appear on win32 or linux', function() {
|
||||
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)
|
||||
});
|
||||
|
||||
|
@ -75,7 +75,9 @@ describe('browser/settings.html', function() {
|
|||
new_config.hideMenuBar = v;
|
||||
fs.writeFileSync(env.configFilePath, JSON.stringify(new_config));
|
||||
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)
|
||||
.browserWindow.isMenuBarAutoHide().should.eventually.equal(v);
|
||||
});
|
||||
|
@ -85,7 +87,9 @@ describe('browser/settings.html', function() {
|
|||
it('should be saved as config.json', function() {
|
||||
env.shouldTestForPlatforms(this, ['win32', 'linux']);
|
||||
return this.app.restart().then(() => {
|
||||
return initClient(this.app.client)
|
||||
addClientCommands(this.app.client);
|
||||
return this.app.client
|
||||
.loadSettingsPage()
|
||||
.click('#inputHideMenuBar input')
|
||||
.click('#btnSave')
|
||||
.pause(1000)
|
||||
|
|
Loading…
Reference in a new issue