Readme

Here are a few tests for val resettableQuotaTracker

  1. Constructor Tests
    • Valid Inputs
      tests the creation of a resettableQuotaTracker with a valid table name and a specific limit.
    • Default Limit
      checks if the constructor uses the default limit of 10 when no limit is specified.
    • Invalid Table Name
      tests the behavior when using an invalid table name (with a hyphen).
    • with existing Table
      validates that runing the constructor for a given table does not modify that table
  2. Method Tests
    • reset Method
      increases the counter and then resets it. Checks if the counter has been reset to 0.
    • Usage Method
      checks if the usage method returns the correct usage value (0) for a newly created tracker.
    • Limit Method
      tests if the limit method returns the correct limit set when creating the tracker.
    • setLimit Method
      changes the limit with the setLimit method and checks if the new value has been set correctly.
    • LimitExceeded Method
      tests the limitExceeded method in two scenarios:
      • when the limit has not been reached yet (expected false)
      • when the limit has been reached (expected true)
    • increment Method
      checks if the increment method correctly increases the usage counter.
    • incrementIfAllowed Method
      tests the behavior of incrementIfAllowed:
      • within the limit (should succeed)
      • upon reaching the limit (should succeed)
      • above the limit (should fail)
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!