This commit is contained in:
2021-03-14 19:06:51 +01:00
parent de211eb1d3
commit 560b0f4c74
43 changed files with 5944 additions and 175 deletions

8
tests/.eslintrc.js Normal file
View File

@@ -0,0 +1,8 @@
module.exports = {
env: {
node: true,
},
rules: {
'@typescript-eslint/no-var-requires': 'off',
},
};

43
tests/app.spec.js Normal file
View File

@@ -0,0 +1,43 @@
const {Application} = require('spectron');
const {strict: assert} = require('assert');
const {join} = require('path');
const app = new Application({
path: require('electron'),
requireName: 'electronRequire',
args: [join(__dirname, '../dist/source')],
});
app.start()
.then(async () => {
const isVisible = await app.browserWindow.isVisible();
assert.ok(isVisible, 'Main window not visible');
})
.then(async () => {
const isDevtoolsOpen = await app.webContents.isDevToolsOpened();
assert.ok(!isDevtoolsOpen, 'DevTools opened');
})
.then(async function () {
// Get the window content
const content = await app.client.$('#app');
assert.notStrictEqual(await content.getHTML(), '<div id="app"></div>', 'Window content is empty');
})
.then(function () {
if (app && app.isRunning()) {
return app.stop();
}
})
.then(() => process.exit(0))
.catch(function (error) {
console.error(error);
if (app && app.isRunning()) {
app.stop();
}
process.exit(1);
});

16
tests/url.spec.js Normal file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/node
const assert = require ('assert');
const {format} = require ('url');
const {join} = require ('path');
const expected = format({
protocol: 'file',
pathname: join(__dirname, '../renderer/index.html'),
slashes: true,
});
const actual = new URL('renderer/index.html', 'file://' + __dirname);
assert.strictEqual(actual.toString(), expected);