Skip to content

Commit

Permalink
Merge pull request #347 from momoAmch/Get_complete_information_about_…
Browse files Browse the repository at this point in the history
…preset_points

get complete information about preset points
  • Loading branch information
agsh authored Nov 4, 2024
2 parents f04f0e3 + 04cfe08 commit 6df0f69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/ptz.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
13 changes: 10 additions & 3 deletions test/ptz.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,25 @@ 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();
});
});
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();
});
Expand All @@ -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();
Expand Down

0 comments on commit 6df0f69

Please sign in to comment.