Skip to content

Commit

Permalink
clean up, add last tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyKennedy committed Jan 26, 2022
1 parent 787fd39 commit 0fa3390
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 11 deletions.
97 changes: 92 additions & 5 deletions __tests__/pages/api/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3041,11 +3041,11 @@ describe('Help Me Find Out scenarios', () => {
expect(res.body.results.oas.eligibility.reason).toEqual(ResultReason.NONE)
expect(res.body.results.gis.eligibility.result).toEqual(ResultKey.ELIGIBLE)
expect(res.body.results.gis.eligibility.reason).toEqual(ResultReason.NONE)
expect(res.body.results.gis.entitlement.result).toEqual(0.68)
expect(res.body.results.gis.entitlement.result).toEqual(0.68) // table 3
})
it('works when client old, partner old (partner=partialOas, therefore gis income limit 46656, gis table unavailable)', async () => {
it(`works when client old, partner old (partner=partialOas, therefore gis income limit ${MAX_GIS_INCOME_PARTNER_NO_OAS_NO_ALW}, gis table unavailable)`, async () => {
const input = {
income: 46656,
income: MAX_GIS_INCOME_PARTNER_NO_OAS_NO_ALW,
age: 65,
maritalStatus: MaritalStatus.MARRIED,
livingCountry: LivingCountry.CANADA,
Expand Down Expand Up @@ -3075,7 +3075,7 @@ describe('Help Me Find Out scenarios', () => {
expect(res.body.results.gis.eligibility.reason).toEqual(ResultReason.INCOME)
res = await mockGetRequest({
...input,
income: 46655,
income: MAX_GIS_INCOME_PARTNER_NO_OAS_NO_ALW - 1,
})
expect(res.body.results.oas.eligibility.result).toEqual(ResultKey.ELIGIBLE)
expect(res.body.results.oas.eligibility.reason).toEqual(ResultReason.NONE)
Expand Down Expand Up @@ -3121,7 +3121,7 @@ describe('Help Me Find Out scenarios', () => {
expect(res.body.results.oas.eligibility.reason).toEqual(ResultReason.NONE)
expect(res.body.results.gis.eligibility.result).toEqual(ResultKey.ELIGIBLE)
expect(res.body.results.gis.eligibility.reason).toEqual(ResultReason.NONE)
expect(res.body.results.gis.entitlement.result).toEqual(0.33)
expect(res.body.results.gis.entitlement.result).toEqual(0.33) // table 2
})
it(`works when client old, partner young (partner=noAllowance, therefore gis table 3)`, async () => {
const input = {
Expand Down Expand Up @@ -3228,4 +3228,91 @@ describe('Help Me Find Out scenarios', () => {
ResultReason.MARITAL
)
})
it('works when client young, partner old (partner=gis, therefore client alw eligible)', async () => {
const input = {
income: 0,
age: 60,
maritalStatus: MaritalStatus.MARRIED,
livingCountry: LivingCountry.CANADA,
legalStatus: LegalStatus.CANADIAN_CITIZEN,
legalStatusOther: undefined,
canadaWholeLife: true,
yearsInCanadaSince18: undefined,
everLivedSocialCountry: undefined,
partnerBenefitStatus: PartnerBenefitStatus.HELP_ME,
partnerIncome: 0,
partnerAge: 65,
partnerLivingCountry: LivingCountry.CANADA,
partnerLegalStatus: LegalStatus.CANADIAN_CITIZEN,
partnerCanadaWholeLife: false,
partnerYearsInCanadaSince18: 40,
partnerEverLivedSocialCountry: undefined,
}
let res = await mockGetRequest(input)
expect(res.body.summary.state).toEqual(
EstimationSummaryState.AVAILABLE_ELIGIBLE
)
expect(res.body.results.oas.eligibility.result).toEqual(
ResultKey.INELIGIBLE
)
expect(res.body.results.oas.eligibility.reason).toEqual(ResultReason.AGE)
expect(res.body.results.gis.eligibility.result).toEqual(
ResultKey.INELIGIBLE
)
expect(res.body.results.gis.eligibility.reason).toEqual(ResultReason.OAS)
expect(res.body.results.alw.eligibility.result).toEqual(ResultKey.ELIGIBLE)
expect(res.body.results.alw.eligibility.reason).toEqual(ResultReason.NONE)
expect(res.body.results.alw.entitlement.result).toEqual(1219.68) // table 4
expect(res.body.results.afs.eligibility.result).toEqual(
ResultKey.INELIGIBLE
)
expect(res.body.results.afs.eligibility.reason).toEqual(
ResultReason.MARITAL
)
})
it('works when client young, partner old (partner=noGis, therefore client alw ineligible)', async () => {
const input = {
income: 0,
age: 60,
maritalStatus: MaritalStatus.MARRIED,
livingCountry: LivingCountry.CANADA,
legalStatus: LegalStatus.CANADIAN_CITIZEN,
legalStatusOther: undefined,
canadaWholeLife: true,
yearsInCanadaSince18: undefined,
everLivedSocialCountry: undefined,
partnerBenefitStatus: PartnerBenefitStatus.HELP_ME,
partnerIncome: 0,
partnerAge: 65,
partnerLivingCountry: LivingCountry.NO_AGREEMENT, // gis ineligible
partnerLegalStatus: LegalStatus.CANADIAN_CITIZEN,
partnerCanadaWholeLife: false,
partnerYearsInCanadaSince18: 40,
partnerEverLivedSocialCountry: undefined,
}
let res = await mockGetRequest(input)
expect(res.body.summary.state).toEqual(
EstimationSummaryState.AVAILABLE_INELIGIBLE
)
expect(res.body.results.oas.eligibility.result).toEqual(
ResultKey.INELIGIBLE
)
expect(res.body.results.oas.eligibility.reason).toEqual(ResultReason.AGE)
expect(res.body.results.gis.eligibility.result).toEqual(
ResultKey.INELIGIBLE
)
expect(res.body.results.gis.eligibility.reason).toEqual(ResultReason.OAS)
expect(res.body.results.alw.eligibility.result).toEqual(
ResultKey.INELIGIBLE
)
expect(res.body.results.alw.eligibility.reason).toEqual(
ResultReason.PARTNER
)
expect(res.body.results.afs.eligibility.result).toEqual(
ResultKey.INELIGIBLE
)
expect(res.body.results.afs.eligibility.reason).toEqual(
ResultReason.MARITAL
)
})
})
1 change: 0 additions & 1 deletion utils/api/benefits/gisBenefit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export class GisBenefit extends BaseBenefit {
? MAX_GIS_INCOME_PARTNER_OAS
: MAX_GIS_INCOME_PARTNER_NO_OAS_NO_ALW
: MAX_GIS_INCOME_SINGLE
console.log('using max income ', maxIncome)
const meetsReqIncome = this.income < maxIncome

// main checks
Expand Down
15 changes: 10 additions & 5 deletions utils/api/helpers/requestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,12 @@ export class RequestHandler {
allResults.partner.oas.eligibility = partnerOas.eligibility
allResults.partner.oas.entitlement = partnerOas.entitlement

// Save the result to the client's partnerBenefitStatus field, which is used TBD
// Save the partner result to the client's partnerBenefitStatus field, which is used for client's GIS
input.client.partnerBenefitStatus.oasResultEntitlement =
partnerOas.entitlement
// Save the client result to the partner's partnerBenefitStatus field, which is not yet used for anything
input.partner.partnerBenefitStatus.oasResultEntitlement =
clientOas.entitlement
}

// All done with OAS, move onto GIS, but only do GIS eligibility for now.
Expand All @@ -268,10 +271,10 @@ export class RequestHandler {
)
allResults.partner.gis.eligibility = partnerGis.eligibility

// Save the result to the client's partnerBenefitStatus field, which is used TBD
// Save the partner result to the client's partnerBenefitStatus field, which is used for client's ALW
input.client.partnerBenefitStatus.gisResultEligibility =
partnerGis.eligibility
// Save the result to the partner's partnerBenefitStatus field, which is used for partner's alw eligibility
// Save the client result to the partner's partnerBenefitStatus field, which is used for partner's ALW, and therefore client's GIS
input.partner.partnerBenefitStatus.gisResultEligibility =
clientGis.eligibility
}
Expand All @@ -283,12 +286,14 @@ export class RequestHandler {
// If the client needs help, check their partner's ALW eligibility.
if (input.client.partnerBenefitStatus.helpMe) {
const partnerAlw = new AlwBenefit(input.partner, translations)

allResults.partner.alw.eligibility = partnerAlw.eligibility

// Save the result to the client's partnerBenefitStatus field, which is used TBD
// Save the partner result to the client's partnerBenefitStatus field, which is used for client's GIS
input.client.partnerBenefitStatus.alwResultEligibility =
partnerAlw.eligibility
// Save the client result to the partner's partnerBenefitStatus field, which is not yet used for anything
input.partner.partnerBenefitStatus.alwResultEligibility =
clientAlw.eligibility
}

// Moving onto AFS, again only doing eligibility.
Expand Down

0 comments on commit 0fa3390

Please sign in to comment.