Skip to content

Commit

Permalink
Added unit tests for calculate age function
Browse files Browse the repository at this point in the history
  • Loading branch information
nitro404 committed May 19, 2018
1 parent 4e99b98 commit 41461b6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1454,9 +1454,23 @@ describe("Utilities", function() {
});

describe("calculateAge", function() {
var newTestData = testData.concat(
new Date().setFullYear(new Date().getFullYear() + 1),
new Date().setFullYear(new Date().getFullYear() - 19)
);

it("should be a function", function() {
expect(utilities.calculateAge instanceof Function).to.equal(true);
});

it("should produce the correct result for each test value", function() {
var start = new Date().getFullYear() - 1970;
var results = [-1, -1, -1, -1, -1, -1, start, start, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, 19];

for(var i = 0; i < newTestData.length; i++) {
expect(utilities.calculateAge(newTestData[i])).to.equal(results[i]);
}
});
});

describe("prependSlash", function() {
Expand Down

0 comments on commit 41461b6

Please sign in to comment.