mattermost-desktop/test/specs/app_test.js

65 lines
1.9 KiB
JavaScript
Raw Normal View History

2016-05-02 06:34:00 -07:00
'use strict';
const path = require('path');
const fs = require('fs');
const env = require('../modules/environment');
describe('application', function() {
this.timeout(10000);
2016-06-05 08:41:35 -07:00
beforeEach(function(done) {
2016-05-21 01:23:23 -07:00
this.app = env.getSpectronApp();
fs.unlink(env.configFilePath, () => {
2016-06-05 08:41:35 -07:00
done();
2016-05-02 06:34:00 -07:00
});
});
afterEach(function() {
2016-05-21 01:23:23 -07:00
if (this.app && this.app.isRunning()) {
return this.app.stop()
}
2016-05-02 06:34:00 -07:00
});
2016-06-05 08:41:35 -07:00
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
});
});
2016-05-02 06:34:00 -07:00
it('should show settings.html when there is no config file', function() {
2016-05-21 01:23:23 -07:00
return this.app.start().then(() => {
2016-06-05 08:41:35 -07:00
return this.app.client.waitUntilWindowLoaded()
.getUrl().should.eventually.match(/\/settings.html$/)
2016-05-21 01:23:23 -07:00
});
2016-05-02 06:34:00 -07:00
});
it('should show index.html when there is config file', function() {
fs.writeFileSync(env.configFilePath, JSON.stringify({
url: env.mattermostURL
}));
2016-05-21 01:23:23 -07:00
return this.app.start().then(() => {
2016-06-05 08:41:35 -07:00
return this.app.client.waitUntilWindowLoaded()
.getUrl().should.eventually.match(/\/index.html$/)
2016-05-21 01:23:23 -07:00
});
2016-05-02 06:34:00 -07:00
});
it('should upgrade v0 config file', function() {
const settings = require('../../src/common/settings');
fs.writeFileSync(env.configFilePath, JSON.stringify({
url: env.mattermostURL
}));
2016-05-21 01:23:23 -07:00
return this.app.start().then(() => {
2016-06-05 08:41:35 -07:00
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);
2016-05-21 01:23:23 -07:00
});
2016-05-02 06:34:00 -07:00
});
});