2016-05-02 06:34:00 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const should = require('should');
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const env = require('../modules/environment');
|
|
|
|
|
|
|
|
describe('application', function() {
|
|
|
|
this.timeout(10000);
|
|
|
|
|
|
|
|
before(function(done) {
|
2016-05-21 01:23:23 -07:00
|
|
|
this.app = env.getSpectronApp();
|
|
|
|
fs.unlink(env.configFilePath, () => {
|
|
|
|
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
|
|
|
});
|
|
|
|
|
|
|
|
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(() => {
|
|
|
|
this.app.client
|
|
|
|
.pause(1000)
|
|
|
|
.getUrl().then(function(url) {
|
|
|
|
var p = path.parse(url);
|
|
|
|
p.base.should.equal('settings.html');
|
|
|
|
})
|
|
|
|
});
|
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(() => {
|
|
|
|
this.app.client
|
|
|
|
.pause(1000)
|
|
|
|
.getUrl().then(function(url) {
|
|
|
|
var p = path.parse(url);
|
|
|
|
p.base.should.equal('index.html');
|
|
|
|
});
|
|
|
|
});
|
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(() => {
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|
2016-05-02 06:34:00 -07:00
|
|
|
});
|
|
|
|
});
|