mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-25 02:10:32 -06:00
55e75cf5e5
- Skipping npm rebuild every time and only running it once. - Changed the time-out to 60000ms - Moved the require to global - Added done fail in all the catch functions - Removed unwanted require
63 lines
1.7 KiB
JavaScript
63 lines
1.7 KiB
JavaScript
const electron = require('./__mocks__/electron');
|
|
const activityDetection = require('../js/activityDetection');
|
|
|
|
describe('Tests for Activity Detection', function() {
|
|
|
|
const originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
|
|
|
|
beforeAll(function(done) {
|
|
activityDetection.setActivityWindow(900000, electron.ipcRenderer);
|
|
done();
|
|
});
|
|
|
|
beforeEach(function() {
|
|
jest.clearAllMocks()
|
|
});
|
|
|
|
afterAll(function(done) {
|
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
|
done();
|
|
});
|
|
|
|
it('should return null', function() {
|
|
|
|
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 });
|
|
|
|
});
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|