mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
ELECTRON-32 Added unit test cases for activity detection (#84)
This commit is contained in:
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});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user