diff --git a/src/ussd_clinic_rapidpro.js b/src/ussd_clinic_rapidpro.js index 63180c4a..2518bd88 100644 --- a/src/ussd_clinic_rapidpro.js +++ b/src/ussd_clinic_rapidpro.js @@ -650,7 +650,7 @@ go.app = function() { "Enter the day that baby was born as a number. For example if baby was born on 12th May, type in 12" ].join("\n")); } - if (!date.isBetween(current_date.clone().add(-2, "years"), current_date)) { + if (!date.isBetween(current_date.clone().add(-2, "years"), current_date.add(1, "days")) ) { return $( "Unfortunately MomConnect doesn't send messages to children older " + "than 2 years. Please try again by entering the day the baby was " + diff --git a/test/ussd_clinic_rapidpro.test.js b/test/ussd_clinic_rapidpro.test.js index 52d412f6..f00e3f4c 100644 --- a/test/ussd_clinic_rapidpro.test.js +++ b/test/ussd_clinic_rapidpro.test.js @@ -1095,10 +1095,10 @@ describe("ussd_clinic app", function() { }) .run(); }); - it("should give an error if the date is today or newer", function() { + it("should give an error if the date is older than two years", function() { return tester .setup.user.state("state_birth_day") - .setup.user.answer("state_birth_month", "2014-04") + .setup.user.answer("state_birth_month", "2012-04") .input("4") .check.interaction({ reply: @@ -1108,17 +1108,12 @@ describe("ussd_clinic app", function() { }) .run(); }); - it("should give an error if the date is two years or older", function() { + it("should pass if the date of birth is today", function() { return tester .setup.user.state("state_birth_day") - .setup.user.answer("state_birth_month", "2012-04") + .setup.user.answer("state_birth_month", "2014-04") .input("4") - .check.interaction({ - reply: - "Unfortunately MomConnect doesn't send messages to children older than 2 " + - "years. Please try again by entering the day the baby was born as a " + - "number, e.g. 12." - }) + .check.user.state("state_id_type") .run(); }); it("should go to state_id_type if the date is valid", function() {