mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-27 01:11:13 -06:00
ELECTRON-32 Added unit test cases for activity detection (#84)
This commit is contained in:
parent
c0908e64ef
commit
d6031dd440
@ -89,5 +89,6 @@ function setActivityWindow(period, win) {
|
||||
module.exports = {
|
||||
send: send,
|
||||
setActivityWindow: setActivityWindow,
|
||||
activityDetection: activityDetection,
|
||||
initiateActivityDetection: initiateActivityDetection
|
||||
};
|
||||
|
40
tests/activityDetection.test.js
Normal file
40
tests/activityDetection.test.js
Normal file
@ -0,0 +1,40 @@
|
||||
const activityDetection = require('../js/activityDetection/activityDetection.js');
|
||||
const electron = require('./__mocks__/electron');
|
||||
|
||||
describe('Tests for Activity Detection', function() {
|
||||
|
||||
beforeAll(function () {
|
||||
activityDetection.setActivityWindow(120000, electron.ipcRenderer);
|
||||
});
|
||||
|
||||
it('should get user activity where user is not idle', function() {
|
||||
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();
|
||||
expect(noData).toBeNull();
|
||||
|
||||
});
|
||||
|
||||
it('should send activity event', function () {
|
||||
const spy = jest.spyOn(activityDetection, 'send');
|
||||
|
||||
expect(spy).not.toBeCalled();
|
||||
|
||||
activityDetection.send({systemIdleTime: 120000});
|
||||
expect(spy).toHaveBeenCalledWith({systemIdleTime: 120000});
|
||||
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user