diff --git a/lib/agent/plugins/control-panel/interval/test/interval_spec.js b/lib/agent/plugins/control-panel/interval/test/interval_spec.js index 28fdcc2d7..a74cd58b1 100644 --- a/lib/agent/plugins/control-panel/interval/test/interval_spec.js +++ b/lib/agent/plugins/control-panel/interval/test/interval_spec.js @@ -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(); });