resettableQuotaTracker_Test
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
main.tsx
https://rozek--9190f2f226d511f0a5b3569c3dd06744.web.val.run
Here are a few tests for val resettableQuotaTracker
- 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
- Valid Inputs
- Method Tests
resetMethod
increases the counter and then resets it. Checks if the counter has been reset to 0.UsageMethod
checks if the usage method returns the correct usage value (0) for a newly created tracker.LimitMethod
tests if the limit method returns the correct limit set when creating the tracker.setLimitMethod
changes the limit with the setLimit method and checks if the new value has been set correctly.LimitExceededMethod
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)
incrementMethod
checks if the increment method correctly increases the usage counter.incrementIfAllowedMethod
tests the behavior of incrementIfAllowed:- within the limit (should succeed)
- upon reaching the limit (should succeed)
- above the limit (should fail)