Skip to content

Commit

Permalink
Correct plural/singular for monehts. Closes waderyan#16
Browse files Browse the repository at this point in the history
  • Loading branch information
Sertion committed Jun 5, 2017
1 parent 32f59b6 commit 5ad5873
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/textdecorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class TextDecorator {
return days + ' days ago';
}
else {
return months + ' months ago';
return months + ' ' + (months === 1 ? 'month' : 'months') + ' ago';
}
}

Expand Down
7 changes: 6 additions & 1 deletion test/extension.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// Note: This example test is leveraging the Mocha test framework.
// Please refer to their documentation on https://mochajs.org/ for help.
//
Expand All @@ -15,10 +15,15 @@ suite('GitBlame Tests', () => {

test('Date Calculations', () => {
assert.equal('3 months ago', TextDecorator.toDateText(new Date(2015, 4), new Date(2015, 1)));
assert.equal('1 month ago', TextDecorator.toDateText(new Date(2015, 2, 20), new Date(2015, 1)));
assert.equal('4 days ago', TextDecorator.toDateText(new Date(2015, 1, 5), new Date(2015, 1, 1)));
assert.equal('2 hours ago', TextDecorator.toDateText(new Date(2015, 1, 1, 3, 0, 0), new Date(2015, 1, 1, 1, 0, 0)));
assert.equal('30 minutes ago', TextDecorator.toDateText(new Date(2015, 1, 1, 1, 30, 0), new Date(2015, 1, 1, 1, 0, 0)));
assert.equal('right now', TextDecorator.toDateText(new Date(2015, 1, 1, 1, 1, 0), new Date(2015, 1, 1, 1, 0, 0)));

assert.notEqual('1 days ago', TextDecorator.toDateText(new Date(2015, 1, 2), new Date(2015, 1, 1)));
assert.notEqual('1 hours ago', TextDecorator.toDateText(new Date(2015, 1, 1, 1, 0, 0), new Date(2015, 1, 1, 0, 0, 0)));
assert.notEqual('1 minutes ago', TextDecorator.toDateText(new Date(2015, 1, 1, 1, 1, 0), new Date(2015, 1, 1, 1, 0, 0)));
});

test('Token Parser', () => {
Expand Down

0 comments on commit 5ad5873

Please sign in to comment.