mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Electron-66 (Unit tests) (#120)
* Electron-66 - Added more unit tests for config, getRegistry & throttle * Electron-66 - Added some more unit tests and enabled activity detection unit test
This commit is contained in:
@@ -1,10 +1,30 @@
|
||||
// const activityDetection = require('../js/activityDetection/activityDetection.js');
|
||||
// const electron = require('./__mocks__/electron');
|
||||
const electron = require('./__mocks__/electron');
|
||||
const childProcess = require('child_process');
|
||||
|
||||
xdescribe('Tests for Activity Detection', function() {
|
||||
let activityDetection;
|
||||
|
||||
beforeAll(function () {
|
||||
activityDetection.setActivityWindow(120000, electron.ipcRenderer);
|
||||
describe('Tests for Activity Detection', function() {
|
||||
|
||||
var originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
|
||||
|
||||
beforeAll(function (done) {
|
||||
childProcess.exec('npm rebuild --runtime=electron --target=1.2.2 --disturl=https://atom.io/download/atom-shell --build-from-source', function (err) {
|
||||
activityDetection = require('../js/activityDetection/activityDetection.js');
|
||||
activityDetection.setActivityWindow(120000, electron.ipcRenderer);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks()
|
||||
});
|
||||
|
||||
afterAll(function (done) {
|
||||
childProcess.exec('npm run rebuild', function (err, stdout) {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should get user activity where user is not idle', function() {
|
||||
@@ -37,4 +57,25 @@ xdescribe('Tests for Activity Detection', function() {
|
||||
|
||||
});
|
||||
|
||||
it('should monitor user activity', function () {
|
||||
activityDetection.setActivityWindow(500000, electron.ipcRenderer);
|
||||
const spy = jest.spyOn(activityDetection, 'monitorUserActivity');
|
||||
|
||||
expect(spy).not.toBeCalled();
|
||||
|
||||
activityDetection.monitorUserActivity();
|
||||
expect(spy).toHaveBeenCalled();
|
||||
|
||||
});
|
||||
|
||||
it('should not send activity event as data is undefined', function () {
|
||||
const spy = jest.spyOn(activityDetection, 'send');
|
||||
|
||||
expect(spy).not.toBeCalled();
|
||||
|
||||
activityDetection.send(undefined);
|
||||
expect(spy).toHaveBeenCalledWith(undefined);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user