Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

users can now register a baby on day of birth #646

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"), 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 " +
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
Loading