Electron-88 Moved the Clipboard test to Jest from mocha

This commit is contained in:
Kiran Niranjan
2017-07-05 14:52:06 +05:30
committed by Kiran Niranjan
parent 2050d00605
commit 5c462a490d
2 changed files with 63 additions and 60 deletions
-60
View File
@@ -1,60 +0,0 @@
const Application = require('../app');
const path = require('path');
const assert = require('assert');
describe('Tests for clipboard', () => {
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 check window count', () => {
return app.client.url('file:///' + path.join(__dirname, '..', '..', 'demo/index.html'))
});
it('should set the username field', () => {
return app.client
.windowByIndex(0)
.setValue('#tag', 'Test')
.getValue('#tag')
.should.eventually.equal('Test')
});
it('should verify electron clipboard', (done) => {
app.client
.getValue('#tag').then((value) => {
app.electron.clipboard.writeText(value)
.electron.clipboard.readText().then(function (clipboardText) {
assert(clipboardText, 'Test');
done();
});
});
});
it('should verify electron clipboard copy', (done) => {
app.electron.clipboard.writeText('Testing copy')
.electron.clipboard.readText().then(function (clipboardText) {
app.client
.setValue('#tag', clipboardText)
.getValue('#tag').then((value) => {
assert(value, 'Testing copy');
done();
});
});
});
});
+63
View File
@@ -0,0 +1,63 @@
const Application = require('./spectronSetup');
const path = require('path');
describe('Tests for clipboard', () => {
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 check window count', () => {
return app.client.url('file:///' + path.join(__dirname, '..', 'demo/index.html'))
});
it('should set the username field', () => {
return app.client
.windowByIndex(0)
.setValue('#tag', 'Test')
.getValue('#tag').then((value) => {
expect(value === 'Test').toBeTruthy();
});
});
it('should verify electron clipboard', () => {
return app.client
.getValue('#tag').then((value) => {
app.electron.clipboard.writeText(value)
.electron.clipboard.readText().then(function (clipboardText) {
expect(clipboardText === 'Test').toBeTruthy();
});
});
});
it('should verify electron clipboard copy', () => {
return app.electron.clipboard.writeText('Testing copy')
.electron.clipboard.readText().then(function (clipboardText) {
return app.client.setValue('#tag', clipboardText).getValue('#tag').then((value) => {
expect(value === 'Testing copy').toBeTruthy();
});
});
});
});