Rewrite tests with non-nested promises

This commit is contained in:
Yuya Ochiai 2018-02-07 20:23:32 +09:00
parent 92f56ce2d3
commit d3e43bb8e6

View file

@ -11,6 +11,7 @@ describe('application', function desc() {
env.createTestUserDataDir();
env.cleanTestConfig();
this.app = env.getSpectronApp();
return this.app.start();
});
afterEach(() => {
@ -21,7 +22,6 @@ describe('application', function desc() {
});
it('should show a window', () => {
return this.app.start().then(() => {
return this.app.client.
waitUntilWindowLoaded().
getWindowCount().then((count) => {
@ -34,7 +34,6 @@ describe('application', function desc() {
visible.should.be.true;
});
});
});
it.skip('should restore window bounds', () => {
// bounds seems to be incorrectly calculated in some environments
@ -42,7 +41,7 @@ describe('application', function desc() {
// - CircleCI: NG
const expectedBounds = {x: 100, y: 200, width: 300, height: 400};
fs.writeFileSync(env.boundsInfoPath, JSON.stringify(expectedBounds));
return this.app.start().then(() => {
return this.app.restart().then(() => {
return this.app.browserWindow.getBounds();
}).then((bounds) => {
bounds.should.deep.equal(expectedBounds);
@ -54,7 +53,7 @@ describe('application', function desc() {
// - Windows 10: OK
// - CircleCI: NG
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();
}).then((bounds) => {
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', () => {
return this.app.start().then(() => {
return this.app.client.
waitUntilWindowLoaded().
getUrl().then((url) => {
@ -79,32 +77,27 @@ describe('application', function desc() {
existing.should.equal(true);
});
});
});
it('should show index.html when there is config file', () => {
fs.writeFileSync(env.configFilePath, JSON.stringify({
url: env.mattermostURL
}));
return this.app.start().then(() => {
return this.app.client.
waitUntilWindowLoaded().
getUrl().then((url) => {
return this.app.restart().then(() => {
return this.app.client.waitUntilWindowLoaded().getUrl();
}).then((url) => {
url.should.match(/\/index.html$/);
});
});
});
it('should upgrade v0 config file', () => {
const settings = require('../../src/common/settings');
fs.writeFileSync(env.configFilePath, JSON.stringify({
url: env.mattermostURL
}));
return this.app.start().then(() => {
return this.app.client.
waitUntilWindowLoaded().
getUrl().then((url) => {
return this.app.restart().then(() => {
return this.app.client.waitUntilWindowLoaded().getUrl();
}).then((url) => {
url.should.match(/\/index.html$/);
});
}).then(() => {
var str = fs.readFileSync(env.configFilePath, 'utf8');
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) => {
this.app.start().then(() => {
const secondApp = env.getSpectronApp();
// In the correct case, 'start().then' is not called.
@ -129,4 +121,3 @@ describe('application', function desc() {
});
});
});
});