Readme

Here are some tests for val floatingQuotaTracker

Test Cases

  1. Constructor with valid inputs
    • creates a new floatingQuotaTracker instance with valid parameters
  2. Constructor with invalid name
    • attempts to create a tracker with an invalid name and checks for error
  3. Limit getter and setter
    • verifies initial limit value
    • tests setting a new limit
    • confirms the new limit is set correctly
  4. Period getter and setter
    • verifies initial period value
    • tests setting a new period
    • confirms the new period is set correctly
  5. Granularity getter and setter
    • verifies initial granularity value
    • tests setting a new granularity
    • confirms the new granularity is set correctly
  6. Usage and increment
    • checks initial usage is zero
    • tests increment method
    • verifies usage after increments
  7. LimitExceeded
    • checks LimitExceeded is false initially
    • tests LimitExceeded at the threshold
    • verifies LimitExceeded is true when limit is exceeded
  8. incrementIfAllowed
    • tests successful increments up to the limit
    • verifies LimitExceeded error is thrown when limit is reached
  9. Reset functionality
    • increments usage
    • tests reset method
    • verifies usage is zero after reset
  10. TimeToWait
  • checks initial TimeToWait is zero
  • tests TimeToWait after exceeding limit
Code
HTTP
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
rozek-floatingquotatracker_test.web.val.run
Updated: January 28, 2025