Skip to content

Commit

Permalink
Merge pull request #16 from agenda/add-ava
Browse files Browse the repository at this point in the history
switch to ava
  • Loading branch information
OmgImAlexis committed Oct 29, 2017
2 parents 4f5ef00 + 1320b02 commit 14831c2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 74 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
node_modules/
package-lock.json
5 changes: 2 additions & 3 deletions package.json
Expand Up @@ -4,7 +4,7 @@
"description": "Human readable time measurements",
"main": "index.js",
"scripts": {
"test": "mocha"
"test": "ava"
},
"repository": {
"type": "git",
Expand All @@ -21,7 +21,6 @@
"url": "https://github.com/rschmukler/human-interval/issues"
},
"devDependencies": {
"expect.js": "~0.3.1",
"mocha": "~3.4.2"
"ava": "^0.23.0"
}
}
23 changes: 23 additions & 0 deletions test.js
@@ -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);
71 changes: 0 additions & 71 deletions test/human-interval.js

This file was deleted.

0 comments on commit 14831c2

Please sign in to comment.