Merge pull request #152 from KiranNiranjan/ELECTRON-88

Electron-88 (Electron Clipboard)
This commit is contained in:
Vikas Shashidhar 2017-07-05 16:29:19 +05:30 committed by GitHub
commit c4fb2ff12d

63
tests/clipboard.test.js Normal file
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();
});
});
});
});