Skip to content

Commit

Permalink
support old node versions in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiansandqvist committed Jan 24, 2018
1 parent ccbe459 commit 0b287d5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
1 change: 1 addition & 0 deletions .nyc_output/33f700761be86b049d03b940d62e63e5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/a717db2daaec45050d0d6d8b93ffd4b3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"/home/seb/Code/s-ago/index.js":{"path":"/home/seb/Code/s-ago/index.js","statementMap":{"0":{"start":{"line":18,"column":12},"end":{"line":18,"column":38}},"1":{"start":{"line":19,"column":2},"end":{"line":19,"column":54}},"2":{"start":{"line":24,"column":13},"end":{"line":24,"column":50}},"3":{"start":{"line":25,"column":14},"end":{"line":25,"column":23}},"4":{"start":{"line":27,"column":2},"end":{"line":29,"column":3}},"5":{"start":{"line":28,"column":4},"end":{"line":28,"column":22}},"6":{"start":{"line":31,"column":2},"end":{"line":35,"column":3}},"7":{"start":{"line":32,"column":4},"end":{"line":34,"column":5}},"8":{"start":{"line":33,"column":6},"end":{"line":33,"column":72}},"9":{"start":{"line":39,"column":0},"end":{"line":46,"column":2}},"10":{"start":{"line":48,"column":0},"end":{"line":48,"column":21}}},"fnMap":{"0":{"name":"format","decl":{"start":{"line":17,"column":9},"end":{"line":17,"column":15}},"loc":{"start":{"line":17,"column":43},"end":{"line":20,"column":1}},"line":17},"1":{"name":"ago","decl":{"start":{"line":22,"column":9},"end":{"line":22,"column":12}},"loc":{"start":{"line":22,"column":19},"end":{"line":37,"column":1}},"line":22}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":9},"end":{"line":19,"column":53}},"type":"cond-expr","locations":[{"start":{"line":19,"column":20},"end":{"line":19,"column":24}},{"start":{"line":19,"column":27},"end":{"line":19,"column":53}}],"line":19},"1":{"loc":{"start":{"line":27,"column":2},"end":{"line":29,"column":3}},"type":"if","locations":[{"start":{"line":27,"column":2},"end":{"line":29,"column":3}},{"start":{"line":27,"column":2},"end":{"line":29,"column":3}}],"line":27},"2":{"loc":{"start":{"line":32,"column":4},"end":{"line":34,"column":5}},"type":"if","locations":[{"start":{"line":32,"column":4},"end":{"line":34,"column":5}},{"start":{"line":32,"column":4},"end":{"line":34,"column":5}}],"line":32}},"s":{"0":31,"1":31,"2":32,"3":32,"4":32,"5":1,"6":31,"7":109,"8":31,"9":1,"10":1},"f":{"0":31,"1":32},"b":{"0":[15,16],"1":[1,31],"2":[31,78]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"d09cc7963c40d24e16684f358ce00502bfef20c4","contentHash":"e544641a98add0e5cf09a920715aebc7_11.4.1"}}
2 changes: 1 addition & 1 deletion coverage/lcov-report/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Wed Jan 24 2018 10:21:52 GMT-0800 (PST)
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Wed Jan 24 2018 10:43:41 GMT-0800 (PST)
</div>
</div>
<script src="prettify.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion coverage/lcov-report/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Wed Jan 24 2018 10:21:52 GMT-0800 (PST)
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Wed Jan 24 2018 10:43:41 GMT-0800 (PST)
</div>
</div>
<script src="prettify.js"></script>
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
},
"scripts": {
"coverage": "nyc --reporter=lcov --reporter=text ava",
"lint": "eslint index.js -c etc/.eslint.json",
"postlint": "npm run coverage",
"test": "ava",
"posttest": "npm run lint"
"test": "ava"
},
"repository": {
"type": "git",
Expand Down
26 changes: 13 additions & 13 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import ago from '../';

const timestamp = new Date();

test('just now', (t) => {
test('just now', function(t) {
t.is(ago(timestamp), 'just now');
});

test('minute', (t) => {
test('minute', function(t) {
const minute = new Date(timestamp - (60 * 1000));
const minute2 = new Date(timestamp - ((60 * 1000) + 5000));
t.is(ago(minute), 'a minute ago');
t.is(ago(minute2), 'a minute ago');
});

test('minutes', (t) => {
test('minutes', function(t) {
const minutes = new Date(timestamp - (2 * 60 * 1000));
const minutes2 = new Date(timestamp - (20 * 60 * 1000));
const minutes3 = new Date(timestamp - (45 * 60 * 1000));
Expand All @@ -23,7 +23,7 @@ test('minutes', (t) => {
t.is(ago(minutes3), '45 minutes ago');
});

test('hour', (t) => {
test('hour', function(t) {
const underHour = new Date(timestamp - (50 * 60 * 1000));
const hour = new Date(timestamp - (60 * 60 * 1000));
const hourPlus = new Date(timestamp - (90 * 60 * 1000));
Expand All @@ -32,7 +32,7 @@ test('hour', (t) => {
t.is(ago(hourPlus), 'an hour ago');
});

test('hours', (t) => {
test('hours', function(t) {
const hours = new Date(timestamp - (2 * 60 * 60 * 1000));
const hours2 = new Date(timestamp - (3.5 * 60 * 60 * 1000));
const hours3 = new Date(timestamp - (19 * 60 * 60 * 1000));
Expand All @@ -41,7 +41,7 @@ test('hours', (t) => {
t.is(ago(hours3), '19 hours ago');
});

test('yesterday', (t) => {
test('yesterday', function(t) {
const yesterday = new Date(timestamp - (20 * 60 * 60 * 1000));
const yesterday2 = new Date(timestamp - (40 * 60 * 60 * 1000));
const yesterday3 = new Date(timestamp - (47 * 60 * 60 * 1000));
Expand All @@ -50,28 +50,28 @@ test('yesterday', (t) => {
t.is(ago(yesterday3), 'yesterday');
});

test('days', (t) => {
test('days', function(t) {
const days = new Date(timestamp - (2 * 24 * 60 * 60 * 1000));
const days2 = new Date(timestamp - (5 * 24 * 60 * 60 * 1000));
t.is(ago(days), '2 days ago');
t.is(ago(days2), '5 days ago');
});

test('week', (t) => {
test('week', function(t) {
const week = new Date(timestamp - (6 * 24 * 60 * 60 * 1000));
const week2 = new Date(timestamp - (13 * 24 * 60 * 60 * 1000));
t.is(ago(week), 'last week');
t.is(ago(week2), 'last week');
});

test('weeks', (t) => {
test('weeks', function(t) {
const weeks = new Date(timestamp - (2 * 7 * 24 * 60 * 60 * 1000));
const weeks2 = new Date(timestamp - (3 * 7 * 24 * 60 * 60 * 1000));
t.is(ago(weeks), '2 weeks ago');
t.is(ago(weeks2), '3 weeks ago');
});

test('month', (t) => {
test('month', function(t) {
const month = new Date(timestamp - (4 * 7 * 24 * 60 * 60 * 1000));
const month2 = new Date(timestamp - (30 * 24 * 60 * 60 * 1000));
const month3 = new Date(timestamp - (50 * 24 * 60 * 60 * 1000));
Expand All @@ -80,21 +80,21 @@ test('month', (t) => {
t.is(ago(month3), 'last month');
});

test('months', (t) => {
test('months', function(t) {
const months = new Date(timestamp - (2 * 30 * 24 * 60 * 60 * 1000));
const months2 = new Date(timestamp - (10 * 30 * 24 * 60 * 60 * 1000));
t.is(ago(months), '2 months ago');
t.is(ago(months2), '10 months ago');
});

test('year', (t) => {
test('year', function(t) {
const year = new Date(timestamp - (350 * 24 * 60 * 60 * 1000));
const year2 = new Date(timestamp - (1.5 * 360 * 24 * 60 * 60 * 1000));
t.is(ago(year), 'last year');
t.is(ago(year2), 'last year');
});

test('years', (t) => {
test('years', function(t) {
const years = new Date(timestamp - (2 * 365 * 24 * 60 * 60 * 1000));
const years2 = new Date(timestamp - (20 * 365 * 24 * 60 * 60 * 1000));
const years3 = new Date(timestamp - (100 * 365 * 24 * 60 * 60 * 1000));
Expand Down

0 comments on commit 0b287d5

Please sign in to comment.