From 0ce5cdcc35aca019ef81c75a115dd8de9f357644 Mon Sep 17 00:00:00 2001 From: amcharhal mohamed Date: Mon, 4 Nov 2024 11:01:34 +0100 Subject: [PATCH 1/2] get complete information about preset points --- lib/ptz.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ptz.js b/lib/ptz.js index dfc6a0a..c5bb3a5 100644 --- a/lib/ptz.js +++ b/lib/ptz.js @@ -32,7 +32,7 @@ module.exports = function(Cam) { presets = [presets]; } presets.forEach(function(preset) { - this.presets[preset.$.token] = preset.name; + this.presets[preset.$.token] = preset; }.bind(this)); } } From 04cfe08853f3ce027bce52a785cc0686e128fffb Mon Sep 17 00:00:00 2001 From: amcharhal mohamed Date: Mon, 4 Nov 2024 11:22:46 +0100 Subject: [PATCH 2/2] update unit tests --- test/ptz.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/ptz.js b/test/ptz.js index 919740b..0a06b5f 100644 --- a/test/ptz.js +++ b/test/ptz.js @@ -20,10 +20,17 @@ describe('Imaging', () => { }); describe('getPresets', () => { + const isValidPrest = (preset) => { + return typeof preset == 'object' && + // name and PTZPosition are optional in the standard onvif specs + // https://www.onvif.org/ver20/ptz/wsdl/ptz.wsdl + // only token is required + typeof preset.$.token == 'string'; + }; it('should return array of preset objects and sets them to #presets', (done) => { cam.getPresets({}, (err, data) => { assert.strictEqual(err, null); - assert.ok(Object.keys(data).every((presetName) => typeof data[presetName] == 'string')); + assert.ok(Object.keys(data).every((presetName) => isValidPrest(data[presetName]))); assert.strictEqual(cam.presets, data); done(); }); @@ -31,7 +38,7 @@ describe('Imaging', () => { it('should return array of preset objects and sets them to #presets without options', (done) => { cam.getPresets((err, data) => { assert.strictEqual(err, null); - assert.ok(Object.keys(data).every((presetName) => typeof data[presetName] == 'string')); + assert.ok(Object.keys(data).every((presetName) => isValidPrest(data[presetName]))); assert.strictEqual(cam.presets, data); done(); }); @@ -41,7 +48,7 @@ describe('Imaging', () => { serverMockup.conf.one = true; cam.getPresets((err, data) => { assert.strictEqual(err, null); - assert.ok(Object.keys(data).every((presetName) => typeof data[presetName] == 'string')); + assert.ok(Object.keys(data).every((presetName) => isValidPrest(data[presetName]))); assert.strictEqual(cam.presets, data); delete serverMockup.conf.one; done();