Skip to content

Commit

Permalink
Added failing test for virtual_device for _update called with proper …
Browse files Browse the repository at this point in the history
…formatted args
  • Loading branch information
AdamMagaluk committed Jan 19, 2016
1 parent f552c19 commit 572a3d3
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/test_virtual_device.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,31 @@ describe('Virtual Device', function() {
});
});

it('_update should always be called with data.actions in proper format', function(done) {
var called = 0;
var orig = vdevice._update;
vdevice._update = function(data) {
called++;
assert(Array.isArray(data.actions));
data.actions.forEach(function(action) {
assert(action.class);
assert(action.name);
assert(action.method);
assert(action.href);
assert(action.fields);
});
orig.apply(vdevice, arguments);

// _update is called twice on transitions. Once for the return of the transition http POST and again
// for the log topic update.
if (called === 2) {
done();
}
};

vdevice.call('change');
});

it('call should work without arguments', function(done) {
vdevice.call('change', function(err) {
assert.equal(err, null);
Expand Down

0 comments on commit 572a3d3

Please sign in to comment.