RateLimiter
|
- |
32 |
#constructor
|
- |
11 |
should not error if not given a config
|
- |
|
without config
|
- |
5 |
should return an object
|
- |
|
should default config.limit to null
|
- |
|
should default config.incrementInterval to null
|
- |
|
should default config.increment to null
|
- |
|
should create tokenBuckets
|
- |
|
with config
|
- |
5 |
should return an object
|
- |
|
should assign given incrementInterval to config.limit
|
- |
|
should assign given incrementInterval to config.incrementInterval
|
- |
|
should assign given incrementInterval to config.increment
|
- |
|
should create tokenBuckets
|
- |
|
#destroy
|
- |
2 |
should call destroy() on each key in tokenBuckets
|
- |
|
should null out the objects
|
- |
|
#decrementTokens
|
- |
9 |
should call TokenBucket if the key is new
|
- |
|
should not call TokenBucket if the key already exists
|
- |
|
should call decrementTokens on TokenBucket instance
|
- |
|
should call decrementTokens with an amount if given one
|
- |
|
key validation
|
- |
5 |
should error if nothing is given
|
- |
|
should not error on valid key
|
- |
|
when key is not on an object
|
- |
3 |
should error on int
|
- |
|
should error on function
|
- |
|
should error on object
|
- |
|
#getTokensRemaining
|
- |
10 |
should clean up tokenBuckets every incrementInterval
|
- |
|
should not clean up tokenBuckets that are active
|
- |
|
when request within limits
|
- |
8 |
should call TokenBucket if the key is new
|
- |
|
should not call TokenBucket if the key already exists
|
- |
|
should call getTokensRemaining on TokenBucket instance
|
- |
|
key validation
|
- |
5 |
should error if no key is given
|
- |
|
should do nothing if a key is given
|
- |
|
when key is not a string
|
- |
3 |
should error on int
|
- |
|
should error on function
|
- |
|
should error on object
|
- |
|
TokenBucket
|
- |
21 |
#constructor
|
- |
11 |
should not error if not given a config
|
- |
|
without config
|
- |
5 |
should return an object
|
- |
|
should create maxLimit
|
- |
|
should create limit
|
- |
|
should create a increment
|
- |
|
should set up an interval calling _incrementTokens
|
- |
|
with config
|
- |
5 |
should return an object
|
- |
|
should create maxLimit
|
- |
|
should create limit
|
- |
|
should create a increment
|
- |
|
should set up an interval calling _incrementTokens
|
- |
|
#destroy
|
- |
2 |
should clear the interval
|
- |
|
should destroy the interval
|
- |
|
#_incrementTokens
|
- |
4 |
should increment tokens if not at limit
|
- |
|
should not increment tokens past limit
|
- |
|
should not increment tokens past limit by addition
|
- |
|
should gain config.increment tokens at the end of the config.incrementInterval
|
- |
|
#decrementTokens
|
- |
3 |
should decrement tokens when enough tokens are available
|
- |
|
should throw error if tokens are less than the decrement amount
|
- |
|
should take an amount and decrement that given amount of tokens
|
- |
|
#getTokensRemaining
|
- |
1 |
should return the tokens remaining
|
- |
|