@segment/clear-intervals
Version:
Clear all active interval timers.
34 lines (28 loc) • 661 B
JavaScript
;
var assert = require('proclaim');
var clearIntervals = require('../lib');
describe('clear-intervals', function() {
var interval;
var j = 0;
beforeEach(function() {
interval = setInterval(function() {
j += 1;
}, 10);
});
afterEach(function() {
clearInterval(interval);
});
it('should clean all intervals', function(done) {
setTimeout(function() {
assert.strictEqual(j, 1);
setTimeout(function() {
assert.strictEqual(j, 2);
clearIntervals();
setTimeout(function() {
assert.strictEqual(j, 2);
done();
}, 40);
}, 11);
}, 11);
});
});