Skip to content

Commit

Permalink
Fix date of month to 1 to avoid edge cases with inconsistent month le…
Browse files Browse the repository at this point in the history
…ngths
  • Loading branch information
garethbowen committed Aug 31, 2016
1 parent 2f980ad commit db0308c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/karma/unit/services/xml-forms-context-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ describe('XmlFormsContextUtils service', function() {
chai.expect(actual).to.equal(0);
});

it('returns 11 when exactly 11 months old', function() {
it('returns 11 when 11 months old', function() {
var dob = new Date();
dob.setMonth(dob.getMonth() - 11);
dob.setMonth(dob.getMonth() - 11, 1);
var actual = service.ageInMonths({ date_of_birth: dob });
chai.expect(actual).to.equal(11);
});

it('returns 13 when exactly 13 months old', function() {
it('returns 13 when 13 months old', function() {
var dob = new Date();
dob.setMonth(dob.getMonth() - 13);
dob.setMonth(dob.getMonth() - 13, 1);
var actual = service.ageInMonths({ date_of_birth: dob });
chai.expect(actual).to.equal(13);
});
Expand All @@ -100,7 +100,7 @@ describe('XmlFormsContextUtils service', function() {

it('returns 0 when less than 1 year old', function() {
var dob = new Date();
dob.setMonth(dob.getMonth() - 11);
dob.setMonth(dob.getMonth() - 11, 1);
var actual = service.ageInYears({ date_of_birth: dob });
chai.expect(actual).to.equal(0);
});
Expand Down

0 comments on commit db0308c

Please sign in to comment.