it('should accept valid type', () => { PartyType.all().forEach(type => { const errors = validator.validateSync(new PartyTypeResponse(type)) expect(errors.length).to.equal(0) }) })
function checkAccessGuard (app: any, method: string) { PartyType.except(PartyType.INDIVIDUAL).forEach(partyType => { it(`should redirect to dashboard page when defendant type is ${partyType.name.toLocaleLowerCase()}`, async () => { claimStoreServiceMock.resolveRetrieveClaimByExternalId({ claim: { ...sampleClaimObj.claim, defendants: [{ ...sampleClaimObj.claim.defendants[0], type: partyType.value }] } }) draftStoreServiceMock.resolveFind('ccj') await request(app)[method](pagePath) .set('Cookie', `${cookieName}=ABC`) .expect(res => expect(res).to.be.redirect.toLocation(DashboardPaths.dashboardPage.uri)) }) }) }
it('should return undefined for unknown type', () => { expect(PartyType.valueOf('unknown-type')).to.be.undefined })
PartyType.all().forEach(type => { expect(PartyType.valueOf(type.value)).to.be.equal(type) })
it('should return type for known types', () => { PartyType.all().forEach(type => { expect(PartyType.valueOf(type.value)).to.be.equal(type) }) })
.get(Paths.claimantPartyTypeSelectionPage.uri, async (req: express.Request, res: express.Response, next: express.NextFunction) => { const draft: Draft<DraftClaim> = res.locals.claimDraft renderView(new Form(new PartyTypeResponse(draft.document.claimant.partyDetails ? PartyType.valueOf(draft.document.claimant.partyDetails.type) : undefined)), res, next) })