Skip to content

Commit

Permalink
Update test cases to cover issue #101.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricioschneider committed Mar 19, 2015
1 parent 807334c commit 7d64ef7
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions lib/agent/plugins/control-panel/interval/test/interval_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,40 @@ describe('interval', function () {

var api_stub = {};

before(function () {
beforeEach(function () {
interval.unload();
reset_spies();
});

before(function () {
api_stub = sinon.stub(api.devices.get, 'commands', function (cb) {
return true;
var err = new Error("Something wrong"),
resp = {
statusCode: 503
};
cb(err, resp);
});
});

after(function() {
api_stub.restore();
});

it('triggers a request', function(done) {

load_module(function (err, emitter) {
load_module(function (err, emitter) {});
interval.check();
api_stub.calledOnce.should.equal(true);
done();

interval.check();
api_stub.calledOnce.should.equal(true);
done();
});

});
it('queues a request', function(done) {

load_module(function (err, emitter) {});
interval.check();
setTimeout_spy.calledTwice.should.equal(true);
done();

});

Expand Down

0 comments on commit 7d64ef7

Please sign in to comment.