Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to ava #16

Merged
merged 1 commit into from Oct 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.