Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get complete information about preset points #347

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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