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,19 +22,17 @@ 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) => {
|
count.should.equal(1);
|
||||||
count.should.equal(1);
|
}).
|
||||||
}).
|
browserWindow.isDevToolsOpened().then((opened) => {
|
||||||
browserWindow.isDevToolsOpened().then((opened) => {
|
opened.should.be.false;
|
||||||
opened.should.be.false;
|
}).
|
||||||
}).
|
browserWindow.isVisible().then((visible) => {
|
||||||
browserWindow.isVisible().then((visible) => {
|
visible.should.be.true;
|
||||||
visible.should.be.true;
|
});
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it.skip('should restore window bounds', () => {
|
it.skip('should restore window bounds', () => {
|
||||||
|
@ -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,28 +68,24 @@ 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) => {
|
url.should.match(/\/settings.html$/);
|
||||||
url.should.match(/\/settings.html$/);
|
}).
|
||||||
}).
|
isExisting('#newServerModal').then((existing) => {
|
||||||
isExisting('#newServerModal').then((existing) => {
|
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$/);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -99,12 +94,10 @@ describe('application', function desc() {
|
||||||
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,20 +106,18 @@ 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.
|
||||||
// So need to use setTimeout in order to finish this test.
|
// So need to use setTimeout in order to finish this test.
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
done();
|
done();
|
||||||
}, 3000);
|
}, 3000);
|
||||||
secondApp.start().then(() => {
|
secondApp.start().then(() => {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
return secondApp.stop();
|
return secondApp.stop();
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
done(new Error('Second app instance exists'));
|
done(new Error('Second app instance exists'));
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue