TapDate
TapDate is a mixin for the node-tap testing framework. It extends the tap test harness with new assertions for performing comparisons of date values.
Installation
TapDate requires that node-tap be installed as a peer dependency.
npm install tap tapdate
Usage
TapDate may be applied strictly to an individual test...
var test = test;var tapdate = ; ;
... or to the tap framework as a whole.
var test = test;var Test = ;Testprototype; ;
If your node_modules
tree is structured such that tapdate and tap exist on the same level, you can also apply to the whole framework by omitting the first argument:
var test = test;; ;
Assertions
Date values may be Date objects, moment objects, or formatted date strings. If any value is unparsable as a date, the assertion will fail.
-
dateAfter(found, wanted, [message])
- Asserts that the found date occurs after the wanted date. -
dateBefore(found, wanted, [message])
- Asserts that the found date occurs before the wanted date. -
dateSame(found, wanted, [unit], [message])
- Asserts that the found date is the same as the wanted date. A time unit (second, minute, hour, day, etc) may be passed to control how specific this assertion will test. -
dateNear(found, wanted, tolerance, [message])
- Asserts that the found date occurs withintolerance
seconds of the wanted date.