project files added
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
const Application = require('spectron').Application;
|
||||
const { join } = require('path');
|
||||
const assert = require('assert')
|
||||
|
||||
const { setUpApp } = require('./utils');
|
||||
|
||||
const app = new Application({
|
||||
env: { TEST_PROCESS_MANAGER: 1 },
|
||||
path: require(join(__dirname, '../node_modules/electron')),
|
||||
args: [join(__dirname, '../example/main.js')]
|
||||
});
|
||||
|
||||
app.start()
|
||||
.then(() => {
|
||||
setUpApp(app);
|
||||
return app.client.waitUntilWindowLoaded();
|
||||
})
|
||||
.then(() => app.electron.ipcRenderer.send('open-process-manager'))
|
||||
.then(() => app.client.waitUntilWindowLoaded())
|
||||
.then(() => assert(app.client.getWindowCount(), 2))
|
||||
.then(() => app.client.changeFocusToMatchingURL(/process-manager\.html/))
|
||||
.then(() => app.client.waitForVisible('#app .process-table'))
|
||||
.then(() => app.stop())
|
||||
.catch(function (error) {
|
||||
console.error('Test failed', error);
|
||||
if (app && app.isRunning()) {
|
||||
app.stop().then(() => process.exit(1))
|
||||
} else process.exit(1);
|
||||
})
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
const Promise = require('bluebird');
|
||||
require('bluebird-extra').usePromise(Promise);
|
||||
|
||||
const setUpApp = function(app) {
|
||||
app.client.addCommand('changeFocusToMatchingURL', URLRegexp => {
|
||||
return app.client.windowHandles()
|
||||
.then(handles => Promise.eachAny(handles.value, handle => {
|
||||
return app.client.window(handle)
|
||||
.then(() => app.client.getUrl())
|
||||
.then(url => !!url.match(URLRegexp) || undefined)
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
module.exports.setUpApp = setUpApp;
|
||||
Reference in New Issue
Block a user