Browse Source

Check queue when capacity/interval updated, add test

master
dustinlarimer 7 years ago
parent
commit
fd9ce4d921
  1. 2
      lib/defer-events.js
  2. 6
      test/unit/modules/defer-events-spec.js

2
lib/defer-events.js

@ -44,12 +44,14 @@ function deferEvents(eventsHash){
function queueCapacity(num){
if (!arguments.length) return this.queue.config.capacity;
this.queue.config.capacity = num ? Number(num): 0;
this.queue.check();
return this;
}
function queueInterval(num){
if (!arguments.length) return this.queue.config.interval;
this.queue.config.interval = num ? Number(num): 0;
this.queue.check();
return this;
}

6
test/unit/modules/defer-events-spec.js

@ -95,4 +95,10 @@ describe('.deferEvent(s) methods', function() {
this.client.recordDeferredEvents();
});
it('should clear internal queue timer when .queueInterval() is set to 0', function(){
assert.ok(this.client.queue.timer);
this.client.queueInterval(0);
assert.isNull(this.client.queue.timer);
});
});

Loading…
Cancel
Save