Functional Weave
Code in Python

time.countdown@1.0.0

vectors.json

1,809 bytes · view raw

[
  {"name": "a fresh one-hour token reads 1:00:00", "args": [1790427600, 1790424000], "expect": {"expired": false, "seconds": 3600, "text": "1:00:00"}},
  {"name": "one second under an hour drops to minutes and seconds", "args": [1790427599, 1790424000], "expect": {"expired": false, "seconds": 3599, "text": "59:59"}},
  {"name": "a Retry-After of 754 seconds", "args": [1000754, 1000000], "expect": {"expired": false, "seconds": 754, "text": "12:34"}},
  {"name": "exactly one minute", "args": [60, 0], "expect": {"expired": false, "seconds": 60, "text": "1:00"}},
  {"name": "under a minute keeps a leading 0:", "args": [59, 0], "expect": {"expired": false, "seconds": 59, "text": "0:59"}},
  {"name": "the last second", "args": [1790427600, 1790427599], "expect": {"expired": false, "seconds": 1, "text": "0:01"}},
  {"name": "reached at until itself, as a JWT exp is", "args": [1790427600, 1790427600], "expect": {"expired": true, "seconds": 0, "text": "0:00"}},
  {"name": "long past is 0, never negative", "args": [100, 5000], "expect": {"expired": true, "seconds": 0, "text": "0:00"}},
  {"name": "hours are not wrapped at a day: 25h 1m 1s", "args": [90061, 0], "expect": {"expired": false, "seconds": 90061, "text": "25:01:01"}},
  {"name": "minutes and seconds under ten are padded after an hour", "args": [3661, 0], "expect": {"expired": false, "seconds": 3661, "text": "1:01:01"}},
  {"name": "times before 1970 count the same way", "args": [-10, -70], "expect": {"expired": false, "seconds": 60, "text": "1:00"}},
  {"name": "a fractional until is refused", "args": [1.5, 0], "expectError": "until must be a whole number of seconds"},
  {"name": "a fractional now is refused (Date.now()/1000 not floored)", "args": [100, 1790424000.25], "expectError": "now must be a whole number of seconds"}
]