Subtheme of barrio
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
879 B

2 years ago
var vows = require('vows');
var assert = require('assert');
var RateLimiter = require('../lib/rateLimiter');
vows.describe('RateLimiter').addBatch({
'interval validation': {
'invalid interval': function() {
assert.throws(function() { new RateLimiter(1, 'junk'); }, /interval/);
},
'valid intervals': function() {
assert.doesNotThrow(function() { new RateLimiter(1, 'sec'); });
assert.doesNotThrow(function() { new RateLimiter(1, 'second'); });
assert.doesNotThrow(function() { new RateLimiter(1, 'min'); });
assert.doesNotThrow(function() { new RateLimiter(1, 'minute'); });
assert.doesNotThrow(function() { new RateLimiter(1, 'hr'); });
assert.doesNotThrow(function() { new RateLimiter(1, 'hour'); });
assert.doesNotThrow(function() { new RateLimiter(1, 'day'); });
}
}
}).export(module);