Refactored spectron tests

This commit is contained in:
Kiran Niranjan
2017-07-06 17:06:16 +05:30
committed by Kiran Niranjan
parent d220b6ada6
commit 763d27aa8d
5 changed files with 38 additions and 40 deletions

View File

@@ -1,13 +1,12 @@
const Application = require('./spectron/spectronSetup');
let app = new Application({});
describe('Tests for Always on top', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
let app;
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll((done) => {
const Application = require('./utils/spectronSetup');
app = new Application({});
return app.startApplication().then((startedApp) => {
app = startedApp;
done();

View File

@@ -1,18 +1,17 @@
const Application = require('./spectron/spectronSetup');
let app = new Application({});
describe('Tests for Bring to front', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
let app;
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll((done) => {
const Application = require('./utils/spectronSetup');
app = new Application({});
return app.startApplication().then((startedApp) => {
app = startedApp;
done();
}).catch(() => {
expect(true).toBe(false);
}).catch((err) => {
expect(err).toBeNull();
});
});
@@ -33,11 +32,11 @@ describe('Tests for Bring to front', () => {
return app.client.getWindowCount().then((count) => {
expect(count === 1).toBeTruthy();
done();
}).catch(() => {
expect(true).toBe(false);
}).catch((err) => {
expect(err).toBeNull();
});
}).catch(() => {
expect(true).toBe(false);
}).catch((err) => {
expect(err).toBeNull();
});
});
@@ -45,19 +44,19 @@ describe('Tests for Bring to front', () => {
return app.browserWindow.minimize().then(() => {
return app.browserWindow.isMinimized().then((isMinimized) => {
expect(isMinimized).toBeTruthy();
}).catch(() => {
expect(true).toBe(false);
}).catch((err) => {
expect(err).toBeNull();
});
}).catch(() => {
expect(true).toBe(false);
}).catch((err) => {
expect(err).toBeNull();
});
});
it('should not be focused', () => {
return app.browserWindow.isFocused().then((isFocused) => {
expect(isFocused).toBeFalsy();
}).catch(() => {
expect(true).toBe(false);
}).catch((err) => {
expect(err).toBeNull();
});
});
@@ -65,19 +64,19 @@ describe('Tests for Bring to front', () => {
return app.browserWindow.restore().then(async () => {
return app.browserWindow.isMinimized().then((isMinimized) => {
expect(isMinimized).toBeFalsy();
}).catch(() => {
expect(true).toBe(false);
}).catch((err) => {
expect(err).toBeNull();
});
}).catch(() => {
expect(true).toBe(false);
}).catch((err) => {
expect(err).toBeNull();
});
});
it('should be focused', () => {
return app.browserWindow.isFocused().then((isFocused) => {
expect(isFocused).toBeTruthy();
}).catch(() => {
expect(true).toBe(false);
}).catch((err) => {
expect(err).toBeNull();
});
});

View File

@@ -1,15 +1,13 @@
const Application = require('./spectron/spectronSetup');
const path = require('path');
let app = new Application({});
describe('Tests for clipboard', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
let app;
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll((done) => {
const Application = require('./utils/spectronSetup');
app = new Application({});
return app.startApplication().then((startedApp) => {
app = startedApp;
done();

View File

@@ -1,15 +1,13 @@
const Application = require('./utils/spectronSetup');
const Application = require('./spectron/spectronSetup');
const path = require('path');
let app = new Application({});
describe('Tests for Notification position', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
let app;
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll((done) => {
app = new Application({});
return app.startApplication().then((startedApp) => {
app = startedApp;
done();

View File

@@ -7,7 +7,7 @@ class App {
this.options = options;
if (!this.options.path){
if (!this.options.path) {
this.options.path = App.getAppPath();
this.options.args = [path.join(__dirname, '..', '..', 'js/main.js')];
}
@@ -16,7 +16,7 @@ class App {
}
startApplication() {
return this.app.start().then((app) =>{
return this.app.start().then((app) => {
return app;
}).catch((err) => {
console.log(err);
@@ -31,6 +31,10 @@ class App {
return electronPath
}
static getTimeOut() {
return 90000
}
}
module.exports = App;