mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-01-13 18:22:12 -06:00
ELECTRON-66 (Unit Tests) (#129)
* ELECTRON-66 - Fixed activity detection unit test and added dynamic target version * ELECTRON-66 - Fixed activity detection unit test
This commit is contained in:
parent
4abe5c87d8
commit
05cde10299
@ -80,7 +80,8 @@
|
||||
"eslint-plugin-import": "^2.2.0",
|
||||
"eslint-plugin-jsx-a11y": "^4.0.0",
|
||||
"eslint-plugin-react": "^6.10.0",
|
||||
"jest": "^19.0.2"
|
||||
"jest": "^19.0.2",
|
||||
"node-abi": "^2.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@paulcbetts/system-idle-time": "^1.0.4",
|
||||
|
@ -1,17 +1,20 @@
|
||||
const electron = require('./__mocks__/electron');
|
||||
const childProcess = require('child_process');
|
||||
const nodeAbi = require('node-abi');
|
||||
|
||||
let activityDetection;
|
||||
let nodeVersion = nodeAbi.getAbi(process.version, 'node');
|
||||
let targetElectronVersion = nodeAbi.getTarget(nodeVersion, 'electron');
|
||||
|
||||
describe('Tests for Activity Detection', function() {
|
||||
|
||||
var originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
|
||||
|
||||
beforeAll(function (done) {
|
||||
childProcess.exec('npm rebuild --runtime=electron --disturl=https://atom.io/download/atom-shell --build-from-source', function (err) {
|
||||
childProcess.exec(`npm rebuild --runtime=electron --target=${targetElectronVersion} --disturl=https://atom.io/download/atom-shell --build-from-source`, function (err) {
|
||||
activityDetection = require('../js/activityDetection/activityDetection.js');
|
||||
activityDetection.setActivityWindow(120000, electron.ipcRenderer);
|
||||
activityDetection.setActivityWindow(900000, electron.ipcRenderer);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -27,20 +30,7 @@ describe('Tests for Activity Detection', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should get user activity where user is not idle', function() {
|
||||
activityDetection.setActivityWindow(120000, electron.ipcRenderer);
|
||||
const data = activityDetection.activityDetection();
|
||||
|
||||
expect(data.isUserIdle).toBe(false);
|
||||
expect(data.systemIdleTime).toBeLessThan(120000);
|
||||
});
|
||||
|
||||
it('should return null', function() {
|
||||
const spy = jest.spyOn(activityDetection, 'activityDetection');
|
||||
const data = activityDetection.activityDetection();
|
||||
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(data.isUserIdle).toBe(false);
|
||||
|
||||
activityDetection.setActivityWindow(0, electron.ipcRenderer);
|
||||
const noData = activityDetection.activityDetection();
|
||||
|
Loading…
Reference in New Issue
Block a user