Skip to content

Commit

Permalink
Fix tests & remove log
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles committed Sep 12, 2023
1 parent 48eb6dd commit 77b67bd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 0 additions & 1 deletion server/lib/device/camera/camera.getImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ async function getImage(selector) {
if (!deviceFeature) {
throw new NotFoundError('Camera image feature not found');
}
console.log(deviceFeature.last_value_changed);
let lastValueInTimestamp = new Date(deviceFeature.last_value_changed).getTime();
if (!isNumeric(lastValueInTimestamp)) {
lastValueInTimestamp = 0;
Expand Down
22 changes: 20 additions & 2 deletions server/test/lib/device/camera/camera.getImage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Camera.getImage', () => {
const promise = deviceManager.camera.getImage('camera-not-found');
return assert.isRejected(promise, 'Camera not found');
});
it('should return camera image is too old', async () => {
it('should return camera image is too old (old date)', async () => {
const stateManager = new StateManager(event);
const deviceManager = new Device(event, {}, stateManager, {}, {}, {}, job);
stateManager.setState('device', 'test-camera', {
Expand All @@ -64,7 +64,7 @@ describe('Camera.getImage', () => {
const promise = deviceManager.camera.getImage('test-camera');
return assert.isRejected(promise, 'Camera image is too old');
});
it('should return camera image is too old', async () => {
it('should return camera image is too old (null date)', async () => {
const stateManager = new StateManager(event);
const deviceManager = new Device(event, {}, stateManager, {}, {}, {}, job);
stateManager.setState('device', 'test-camera', {
Expand All @@ -82,6 +82,24 @@ describe('Camera.getImage', () => {
const promise = deviceManager.camera.getImage('test-camera');
return assert.isRejected(promise, 'Camera image is too old');
});
it('should return camera image is too old (wrong date)', async () => {
const stateManager = new StateManager(event);
const deviceManager = new Device(event, {}, stateManager, {}, {}, {}, job);
stateManager.setState('device', 'test-camera', {
features: [
{
id: '565d05fc-1736-4b76-99ca-581232901d96',
selector: 'test-camera',
category: 'camera',
type: 'image',
last_value_changed: 'lalala',
last_value_string: null,
},
],
});
const promise = deviceManager.camera.getImage('test-camera');
return assert.isRejected(promise, 'Camera image is too old');
});
it('should return camera not found', async () => {
const stateManager = new StateManager(event);
const deviceManager = new Device(event, {}, stateManager, {}, {}, {}, job);
Expand Down

0 comments on commit 77b67bd

Please sign in to comment.