Skip to content

Commit

Permalink
users can now register a baby on day of birth
Browse files Browse the repository at this point in the history
  • Loading branch information
Mudiwa Matanda authored and Mudiwa Matanda committed Oct 28, 2024
1 parent b035d41 commit 2006104
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/ussd_clinic_rapidpro.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")) && (!date.isSame(current_date, date)) ) {
return $(
"Unfortunately MomConnect doesn't send messages to children older " +
"than 2 years. Please try again by entering the day the baby was " +
Expand Down
15 changes: 5 additions & 10 deletions test/ussd_clinic_rapidpro.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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() {
Expand Down

0 comments on commit 2006104

Please sign in to comment.