ratelimiter-test.js 859 B

1234567891011121314151617181920
  1. var vows = require('vows');
  2. var assert = require('assert');
  3. var RateLimiter = require('../lib/rateLimiter');
  4. vows.describe('RateLimiter').addBatch({
  5. 'interval validation': {
  6. 'invalid interval': function() {
  7. assert.throws(function() { new RateLimiter(1, 'junk'); }, /interval/);
  8. },
  9. 'valid intervals': function() {
  10. assert.doesNotThrow(function() { new RateLimiter(1, 'sec'); });
  11. assert.doesNotThrow(function() { new RateLimiter(1, 'second'); });
  12. assert.doesNotThrow(function() { new RateLimiter(1, 'min'); });
  13. assert.doesNotThrow(function() { new RateLimiter(1, 'minute'); });
  14. assert.doesNotThrow(function() { new RateLimiter(1, 'hr'); });
  15. assert.doesNotThrow(function() { new RateLimiter(1, 'hour'); });
  16. assert.doesNotThrow(function() { new RateLimiter(1, 'day'); });
  17. }
  18. }
  19. }).export(module);