-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from agenda/add-ava
switch to ava
- Loading branch information
Showing
4 changed files
with
26 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules/ | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const test = require('ava'); | ||
const humanInterval = require('.'); | ||
|
||
const macro = (t, inputs, expected) => { | ||
inputs = Array.isArray(inputs) ? inputs : [inputs]; | ||
inputs.forEach(input => t.is(humanInterval(input), expected)); | ||
}; | ||
|
||
test('returns the number when given a number', macro, 5000, 5000); | ||
test('returns undefined when given undefined', macro, undefined, undefined); | ||
test('does not require a number', macro, 'week', 7 * 86400000); | ||
test('understands seconds', macro, '1 second', 1000); | ||
test('understands minutes', macro, '1 minute', 60000); | ||
test('understands hours', macro, '1 hour', 3600000); | ||
test('understands days', macro, '1 day', 86400000); | ||
test('understands weeks', macro, '1 week', 7 * 86400000); | ||
test('understands months', macro, '1 month', 30 * 86400000); | ||
test('understands years', macro, '1 year', 31536000000); | ||
test('understands numbers', macro, '2 seconds', 2000); | ||
test('understands decimals', macro, '2.5 seconds', 2500); | ||
test('understands english numbers', macro, 'two seconds', 2000); | ||
test('works with mixed units', macro, '3 minutes and 30 seconds', 210000); | ||
test('works with mixed time expressions', macro, ['three minutes and 30 seconds', 'three minutes 30 seconds'], 210000); |
This file was deleted.
Oops, something went wrong.