This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
inversion.js
70 lines (61 loc) · 1.88 KB
/
inversion.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
'use strict';
const { Application } = require('spectron');
const { assert } = require('chai');
const config = require('../../../config.json');
const {
APP_PATH,
WAIT_UNTIL_TIMEOUT
} = config;
describe('View > Inversion', function () {
const app = new Application({
path: APP_PATH,
env: {
ELECTRON_ENABLE_LOGGING: true,
ELECTRON_ENABLE_STACK_DUMPING: true,
NEGATIVE_IGNORE_SETTINGS: true,
NEGATIVE_SKIP_RESET_DIALOG: true,
NEGATIVE_VERBOSE: true,
NODE_ENV: 'development'
}
});
this.timeout(60000);
beforeEach(() => {
return app.start();
});
afterEach(() => {
if (app && app.isRunning()) {
return app.stop();
}
});
it('Should toggle inversion', () => {
return app.client.waitUntilWindowLoaded()
.then(() => {
return app.client.selectorExecute('//body', (elements) => {
return elements[0].classList.contains('inversion-off');
});
})
.then((hasTranslucenceOffClass) => assert.isFalse(hasTranslucenceOffClass, 'The body element should not have the .inversion-off class when on startup.'))
.then(() => app.electron.ipcRenderer.send('test-inversion'))
.then(() => {
return app.client.waitUntil(() => {
return app.client.selectorExecute('//body', (elements) => {
return elements[0].classList.contains('inversion-off');
});
}, WAIT_UNTIL_TIMEOUT);
})
.then((hasTranslucenceOffClass) => assert.isTrue(hasTranslucenceOffClass, 'The body element should have the .inversion-off class when Inversion is off.'))
.catch((err) => {
return app.client.getMainProcessLogs()
.then((logs) => {
console.log('*** MAIN PROCESS LOGS ***');
logs.forEach((log) => console.log(log));
return app.client.getRenderProcessLogs();
})
.then((logs) => {
console.log('*** RENDER PROCESS LOGS ***');
logs.forEach((log) => console.log(log));
throw err;
});
});
});
});