Rewrite tests with chai-as-promised
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
const should = require('should');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
@@ -9,10 +8,10 @@ const env = require('../modules/environment');
|
||||
describe('application', function() {
|
||||
this.timeout(10000);
|
||||
|
||||
before(function(done) {
|
||||
beforeEach(function(done) {
|
||||
this.app = env.getSpectronApp();
|
||||
fs.unlink(env.configFilePath, () => {
|
||||
done()
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,14 +21,19 @@ describe('application', function() {
|
||||
}
|
||||
});
|
||||
|
||||
it('should show a window', function() {
|
||||
return this.app.start().then(() => {
|
||||
return this.app.client.waitUntilWindowLoaded()
|
||||
.getWindowCount().should.eventually.equal(1)
|
||||
.browserWindow.isDevToolsOpened().should.eventually.be.false
|
||||
.browserWindow.isVisible().should.eventually.be.true
|
||||
});
|
||||
});
|
||||
|
||||
it('should show settings.html when there is no config file', function() {
|
||||
return this.app.start().then(() => {
|
||||
this.app.client
|
||||
.pause(1000)
|
||||
.getUrl().then(function(url) {
|
||||
var p = path.parse(url);
|
||||
p.base.should.equal('settings.html');
|
||||
})
|
||||
return this.app.client.waitUntilWindowLoaded()
|
||||
.getUrl().should.eventually.match(/\/settings.html$/)
|
||||
});
|
||||
});
|
||||
|
||||
@@ -38,12 +42,8 @@ describe('application', function() {
|
||||
url: env.mattermostURL
|
||||
}));
|
||||
return this.app.start().then(() => {
|
||||
this.app.client
|
||||
.pause(1000)
|
||||
.getUrl().then(function(url) {
|
||||
var p = path.parse(url);
|
||||
p.base.should.equal('index.html');
|
||||
});
|
||||
return this.app.client.waitUntilWindowLoaded()
|
||||
.getUrl().should.eventually.match(/\/index.html$/)
|
||||
});
|
||||
});
|
||||
|
||||
@@ -53,17 +53,12 @@ describe('application', function() {
|
||||
url: env.mattermostURL
|
||||
}));
|
||||
return this.app.start().then(() => {
|
||||
this.app.client
|
||||
.pause(1000)
|
||||
.getUrl().then(function(url) {
|
||||
var p = path.parse(url);
|
||||
p.base.should.equal('index.html');
|
||||
})
|
||||
.end().then(function() {
|
||||
var str = fs.readFileSync(env.configFilePath, 'utf8');
|
||||
var config = JSON.parse(str);
|
||||
config.version.should.equal(settings.version);
|
||||
});
|
||||
return this.app.client.waitUntilWindowLoaded()
|
||||
.getUrl().should.eventually.match(/\/index.html$/)
|
||||
}).then(function() {
|
||||
var str = fs.readFileSync(env.configFilePath, 'utf8');
|
||||
var config = JSON.parse(str);
|
||||
config.version.should.equal(settings.version);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user