Rewrite tests with non-nested promises
This commit is contained in:
parent
92f56ce2d3
commit
d3e43bb8e6
|
@ -11,6 +11,7 @@ describe('application', function desc() {
|
||||||
env.createTestUserDataDir();
|
env.createTestUserDataDir();
|
||||||
env.cleanTestConfig();
|
env.cleanTestConfig();
|
||||||
this.app = env.getSpectronApp();
|
this.app = env.getSpectronApp();
|
||||||
|
return this.app.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -21,7 +22,6 @@ describe('application', function desc() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show a window', () => {
|
it('should show a window', () => {
|
||||||
return this.app.start().then(() => {
|
|
||||||
return this.app.client.
|
return this.app.client.
|
||||||
waitUntilWindowLoaded().
|
waitUntilWindowLoaded().
|
||||||
getWindowCount().then((count) => {
|
getWindowCount().then((count) => {
|
||||||
|
@ -34,7 +34,6 @@ describe('application', function desc() {
|
||||||
visible.should.be.true;
|
visible.should.be.true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it.skip('should restore window bounds', () => {
|
it.skip('should restore window bounds', () => {
|
||||||
// bounds seems to be incorrectly calculated in some environments
|
// bounds seems to be incorrectly calculated in some environments
|
||||||
|
@ -42,7 +41,7 @@ describe('application', function desc() {
|
||||||
// - CircleCI: NG
|
// - CircleCI: NG
|
||||||
const expectedBounds = {x: 100, y: 200, width: 300, height: 400};
|
const expectedBounds = {x: 100, y: 200, width: 300, height: 400};
|
||||||
fs.writeFileSync(env.boundsInfoPath, JSON.stringify(expectedBounds));
|
fs.writeFileSync(env.boundsInfoPath, JSON.stringify(expectedBounds));
|
||||||
return this.app.start().then(() => {
|
return this.app.restart().then(() => {
|
||||||
return this.app.browserWindow.getBounds();
|
return this.app.browserWindow.getBounds();
|
||||||
}).then((bounds) => {
|
}).then((bounds) => {
|
||||||
bounds.should.deep.equal(expectedBounds);
|
bounds.should.deep.equal(expectedBounds);
|
||||||
|
@ -54,7 +53,7 @@ describe('application', function desc() {
|
||||||
// - Windows 10: OK
|
// - Windows 10: OK
|
||||||
// - CircleCI: NG
|
// - CircleCI: NG
|
||||||
fs.writeFileSync(env.boundsInfoPath, JSON.stringify({x: -100000, y: 200, width: 300, height: 400}));
|
fs.writeFileSync(env.boundsInfoPath, JSON.stringify({x: -100000, y: 200, width: 300, height: 400}));
|
||||||
return this.app.start().then(() => {
|
return this.app.restart().then(() => {
|
||||||
return this.app.browserWindow.getBounds();
|
return this.app.browserWindow.getBounds();
|
||||||
}).then((bounds) => {
|
}).then((bounds) => {
|
||||||
bounds.x.should.satisfy((x) => (x > -10000));
|
bounds.x.should.satisfy((x) => (x > -10000));
|
||||||
|
@ -69,7 +68,6 @@ describe('application', function desc() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show settings.html when there is no config file', () => {
|
it('should show settings.html when there is no config file', () => {
|
||||||
return this.app.start().then(() => {
|
|
||||||
return this.app.client.
|
return this.app.client.
|
||||||
waitUntilWindowLoaded().
|
waitUntilWindowLoaded().
|
||||||
getUrl().then((url) => {
|
getUrl().then((url) => {
|
||||||
|
@ -79,32 +77,27 @@ describe('application', function desc() {
|
||||||
existing.should.equal(true);
|
existing.should.equal(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('should show index.html when there is config file', () => {
|
it('should show index.html when there is config file', () => {
|
||||||
fs.writeFileSync(env.configFilePath, JSON.stringify({
|
fs.writeFileSync(env.configFilePath, JSON.stringify({
|
||||||
url: env.mattermostURL
|
url: env.mattermostURL
|
||||||
}));
|
}));
|
||||||
return this.app.start().then(() => {
|
return this.app.restart().then(() => {
|
||||||
return this.app.client.
|
return this.app.client.waitUntilWindowLoaded().getUrl();
|
||||||
waitUntilWindowLoaded().
|
}).then((url) => {
|
||||||
getUrl().then((url) => {
|
|
||||||
url.should.match(/\/index.html$/);
|
url.should.match(/\/index.html$/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('should upgrade v0 config file', () => {
|
it('should upgrade v0 config file', () => {
|
||||||
const settings = require('../../src/common/settings');
|
const settings = require('../../src/common/settings');
|
||||||
fs.writeFileSync(env.configFilePath, JSON.stringify({
|
fs.writeFileSync(env.configFilePath, JSON.stringify({
|
||||||
url: env.mattermostURL
|
url: env.mattermostURL
|
||||||
}));
|
}));
|
||||||
return this.app.start().then(() => {
|
return this.app.restart().then(() => {
|
||||||
return this.app.client.
|
return this.app.client.waitUntilWindowLoaded().getUrl();
|
||||||
waitUntilWindowLoaded().
|
}).then((url) => {
|
||||||
getUrl().then((url) => {
|
|
||||||
url.should.match(/\/index.html$/);
|
url.should.match(/\/index.html$/);
|
||||||
});
|
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
var str = fs.readFileSync(env.configFilePath, 'utf8');
|
var str = fs.readFileSync(env.configFilePath, 'utf8');
|
||||||
var config = JSON.parse(str);
|
var config = JSON.parse(str);
|
||||||
|
@ -113,7 +106,6 @@ describe('application', function desc() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it.skip('should be stopped when the app instance already exists', (done) => {
|
it.skip('should be stopped when the app instance already exists', (done) => {
|
||||||
this.app.start().then(() => {
|
|
||||||
const secondApp = env.getSpectronApp();
|
const secondApp = env.getSpectronApp();
|
||||||
|
|
||||||
// In the correct case, 'start().then' is not called.
|
// In the correct case, 'start().then' is not called.
|
||||||
|
@ -128,5 +120,4 @@ describe('application', function desc() {
|
||||||
done(new Error('Second app instance exists'));
|
done(new Error('Second app instance exists'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue