Electron-90 Moved the Notification test to Jest from mocha

This commit is contained in:
Kiran Niranjan 2017-07-05 14:03:52 +05:30 committed by Kiran Niranjan
parent f96b04c1a9
commit 9ee4b76d37
4 changed files with 143 additions and 146 deletions

View File

@ -79,9 +79,6 @@
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.10.0",
"jest": "^19.0.2",
"chai-roughly": "^1.0.0",
"chai-as-promised": "^7.0.0",
"chai": "^4.0.2",
"spectron": "^3.7.2"
},
"dependencies": {

View File

@ -1,133 +0,0 @@
const Application = require('../app');
const assert = require('assert');
const path = require('path');
describe('Tests for Notification position', () => {
let app;
before(() => {
app = new Application({});
});
after(() => {
if (app && app.isRunning()) {
return app.stop();
}
});
it('should launch the app', () => {
return app.startApplication().then((startedApp) => {
app = startedApp;
app.client.waitUntilWindowLoaded()
.getWindowCount().should.eventually.equal(1);
});
});
it('should load demo html page', () => {
let filePath;
if (process.platform === 'win32') {
filePath = 'file:///' + path.join(__dirname, '..', '..', 'demo/index.html');
} else {
filePath = 'file://$(pwd)/' + path.join(__dirname, '..', '..', 'demo/index.html')
}
return app.client.url(filePath);
});
it('should load demo html', () => {
return app.client.waitUntilWindowLoaded()
.getTitle().should.eventually.equal('')
});
it('should notification configure window', () => {
return app.client
.click('#open-config-win')
.windowByIndex(1)
.click('#upper-left')
.click('#ok-button')
.windowByIndex(0)
.click('#notf')
.windowByIndex(1)
});
it('should check notification position', () => {
return app.browserWindow
.getBounds().then((bounds) => {
bounds.x.should.be.equal(0);
bounds.y.should.be.above(0);
});
});
it('should change the window', () => {
return app.client.windowByIndex(0).then(() => {
return app.browserWindow.getTitle().should.eventually.equal('Symphony | Secure Seamless Communication')
});
});
it('should change notification position to lower-right', () => {
return app.client
.click('#open-config-win')
.windowByIndex(2)
.click('#lower-right')
.click('#ok-button')
.windowByIndex(0)
.click('#notf')
.windowByIndex(1).then(() => {
return app.browserWindow.getTitle().should.eventually.equal('Electron')
});
});
it('should check notification position and equal to lower-right', () => {
return app.browserWindow
.getBounds().then((bounds) => {
bounds.x.should.be.above(0);
bounds.y.should.be.above(0);
});
});
it('should change the window', () => {
return app.client
.windowByIndex(0).then(() => {
return app.browserWindow.getTitle().should.eventually.equal('Symphony | Secure Seamless Communication')
});
});
it('should change notification position to upper-right', () => {
return app.client
.click('#open-config-win')
.windowByIndex(2)
.click('#upper-right')
.click('#ok-button')
.windowByIndex(0)
.click('#notf')
.windowByIndex(1).then(() => {
return app.browserWindow.getTitle().should.eventually.equal('Electron')
});
});
it('should check notification position and equal to upper-right', () => {
return app.browserWindow
.getBounds().then((bounds) => {
bounds.x.should.be.above(0);
bounds.y.should.be.above(0);
});
});
it('should change the window to main', () => {
return app.client
.windowByIndex(0).then(() => {
return app.browserWindow.getTitle().should.eventually.equal('Symphony | Secure Seamless Communication')
});
});
it('should open notification and close', () => {
return app.client
.windowByIndex(0)
.click('#notf')
.getWindowCount().should.eventually.equal(3)
.windowByIndex(1).then(() => {
return app.browserWindow.getTitle().should.eventually.equal('Electron')
});
});
});

View File

@ -0,0 +1,143 @@
const Application = require('./spectronSetup');
const path = require('path');
describe('Tests for Notification position', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
let app;
beforeAll(() => {
app = new Application({});
});
afterAll(() => {
if (app && app.isRunning()) {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
return app.stop();
}
});
it('should launch the app', () => {
return app.startApplication().then((startedApp) => {
app = startedApp;
return app.client.waitUntilWindowLoaded().then(async () => {
const count = await app.client.getWindowCount();
expect(count === 1).toBeTruthy();
})
});
});
it('should load demo html page', () => {
let filePath;
if (process.platform === 'win32') {
filePath = 'file:///' + path.join(__dirname, '..', 'demo/index.html');
} else {
filePath = 'file://$(pwd)/' + path.join(__dirname, '..', 'demo/index.html')
}
return app.client.url(filePath);
});
it('should load demo html', async () => {
return app.client.waitUntilWindowLoaded().then(async () => {
const title = await app.client.getTitle();
expect(title === '').toBeTruthy();
});
});
it('should notification configure window', () => {
return app.client
.click('#open-config-win')
.windowByIndex(1)
.click('#upper-left')
.click('#ok-button')
.windowByIndex(0)
.click('#notf')
.windowByIndex(1)
});
it('should check notification position', async () => {
const bounds = await app.browserWindow.getBounds();
expect(bounds.x === 0).toBeTruthy();
expect(bounds.y > 0).toBeTruthy();
});
it('should change the window', () => {
return app.client.windowByIndex(0).then(async () => {
const title = await app.browserWindow.getTitle();
expect(title === 'Symphony | Secure Seamless Communication').toBeTruthy();
});
});
it('should change notification position to lower-right', () => {
return app.client
.click('#open-config-win')
.windowByIndex(2)
.click('#lower-right')
.click('#ok-button')
.windowByIndex(0)
.click('#notf')
.windowByIndex(1).then(async () => {
const title = await app.browserWindow.getTitle();
expect(title === 'Electron').toBeTruthy();
});
});
it('should check notification position and equal to lower-right', async () => {
const bounds = await app.browserWindow.getBounds();
expect(bounds.x > 0).toBeTruthy();
expect(bounds.y > 0).toBeTruthy();
});
it('should change the window', () => {
return app.client
.windowByIndex(0).then(async () => {
const title = await app.browserWindow.getTitle();
expect(title === 'Symphony | Secure Seamless Communication').toBeTruthy();
});
});
it('should change notification position to upper-right', () => {
return app.client
.click('#open-config-win')
.windowByIndex(2)
.click('#upper-right')
.click('#ok-button')
.windowByIndex(0)
.click('#notf')
.windowByIndex(1).then(async () => {
const title = await app.browserWindow.getTitle();
expect(title === 'Electron').toBeTruthy();
});
});
it('should check notification position and equal to upper-right', async () => {
const bounds = await app.browserWindow.getBounds();
expect(bounds.x > 0).toBeTruthy();
expect(bounds.y > 0).toBeTruthy();
});
it('should change the window to main', () => {
return app.client
.windowByIndex(0).then(async () => {
const title = await app.browserWindow.getTitle();
expect(title === 'Symphony | Secure Seamless Communication').toBeTruthy();
});
});
it('should open notification and close', () => {
return app.client
.windowByIndex(0)
.click('#notf')
.getWindowCount().then((count) => {
expect(count === 3).toBeTruthy();
})
.windowByIndex(1).then(() => {
return app.browserWindow.getTitle().then((title) => {
expect(title === 'Electron').toBeTruthy();
});
});
});
});

View File

@ -1,14 +1,5 @@
const Application = require('spectron').Application;
const path = require('path');
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
const chaiRoughly = require('chai-roughly');
global.before(function () {
chai.should();
chai.use(chaiAsPromised);
chai.use(chaiRoughly);
});
class App {
@ -26,7 +17,6 @@ class App {
startApplication() {
return this.app.start().then(() => {
chaiAsPromised.transferPromiseness = this.app.transferPromiseness;
return this.app
});
}