diff --git a/server/lib/device/camera/camera.getImage.js b/server/lib/device/camera/camera.getImage.js index 6eebe471c4..e26b42637f 100644 --- a/server/lib/device/camera/camera.getImage.js +++ b/server/lib/device/camera/camera.getImage.js @@ -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; diff --git a/server/test/lib/device/camera/camera.getImage.test.js b/server/test/lib/device/camera/camera.getImage.test.js index a87b7cf042..a20a10f300 100644 --- a/server/test/lib/device/camera/camera.getImage.test.js +++ b/server/test/lib/device/camera/camera.getImage.test.js @@ -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', { @@ -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', { @@ -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);