本文整理汇总了TypeScript中response/paths.Paths.sendYourResponseByEmailPage.evaluateUri方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Paths.sendYourResponseByEmailPage.evaluateUri方法的具体用法?TypeScript Paths.sendYourResponseByEmailPage.evaluateUri怎么用?TypeScript Paths.sendYourResponseByEmailPage.evaluateUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类response/paths.Paths.sendYourResponseByEmailPage
的用法示例。
在下文中一共展示了Paths.sendYourResponseByEmailPage.evaluateUri方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: renderView
ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> => {
const { externalId } = req.params
const form: Form<Response> = req.body
if (form.hasErrors()) {
renderView(form, res)
} else {
const claim: Claim = res.locals.claim
const draft: Draft<ResponseDraft> = res.locals.responseDraft
const user: User = res.locals.user
draft.document.response = form.model
if (draft.document.response.type === ResponseType.FULL_ADMISSION) {
if (!draft.document.fullAdmission) {
draft.document.fullAdmission = new FullAdmission()
}
delete draft.document.partialAdmission
delete draft.document.freeMediation
} else if (draft.document.response.type === ResponseType.PART_ADMISSION) {
if (!draft.document.partialAdmission) {
draft.document.partialAdmission = new PartialAdmission()
}
delete draft.document.fullAdmission
delete draft.document.rejectAllOfClaim
delete draft.document.freeMediation
} else {
delete draft.document.fullAdmission
delete draft.document.partialAdmission
delete draft.document.statementOfMeans
}
await new DraftService().save(draft, user.bearerToken)
switch (draft.document.response.type) {
case ResponseType.DEFENCE:
res.redirect(Paths.defenceRejectAllOfClaimPage.evaluateUri({ externalId: externalId }))
break
case ResponseType.PART_ADMISSION:
if (FeatureToggles.hasAnyAuthorisedFeature(claim.features, 'admissions')) {
res.redirect(PartAdmissionPaths.alreadyPaidPage.evaluateUri({ externalId: externalId }))
} else {
res.redirect(Paths.sendYourResponseByEmailPage.evaluateUri({ externalId: externalId }))
}
break
case ResponseType.FULL_ADMISSION:
if (FeatureToggles.hasAnyAuthorisedFeature(claim.features, 'admissions')) {
res.redirect(Paths.taskListPage.evaluateUri({ externalId: claim.externalId }))
} else {
res.redirect(Paths.sendYourResponseByEmailPage.evaluateUri({ externalId: externalId }))
}
break
default:
next(new Error(`Unknown response type: ${draft.document.response.type}`))
}
}
}))
示例2: context
context('when service is healthy', () => {
it('when form is invalid should render page', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId({ totalAmountTillToday: validFormData.amount + 1 })
draftStoreServiceMock.resolveFind('response:full-rejection')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({})
.expect(res => expect(res).to.be.successful.withText(header, 'div class="error-summary"'))
})
testValidPost(-1, true,
FullRejectionPaths.youHavePaidLessPage.evaluateUri({ externalId: externalId }))
testValidPost(-1, false,
Paths.sendYourResponseByEmailPage.evaluateUri({ externalId: externalId }))
testValidPost(0, true,
Paths.taskListPage.evaluateUri({ externalId: externalId }))
testValidPost(0, false,
Paths.sendYourResponseByEmailPage.evaluateUri({ externalId: externalId }))
testValidPost(1, true,
Paths.taskListPage.evaluateUri({ externalId: externalId }))
testValidPost(1, false,
Paths.sendYourResponseByEmailPage.evaluateUri({ externalId: externalId }))
})
示例3: renderView
ErrorHandling.apply(async (req: express.Request, res: express.Response): Promise<void> => {
const form: Form<RejectAllOfClaim> = req.body
if (form.hasErrors()) {
renderView(form, res)
} else {
const draft: Draft<ResponseDraft> = res.locals.responseDraft
const user: User = res.locals.user
draft.document.rejectAllOfClaim = form.model
await new DraftService().save(draft, user.bearerToken)
const { externalId } = req.params
switch (draft.document.rejectAllOfClaim.option) {
case RejectAllOfClaimOption.COUNTER_CLAIM:
res.redirect(Paths.sendYourResponseByEmailPage.evaluateUri({ externalId: externalId }))
break
case RejectAllOfClaimOption.ALREADY_PAID:
case RejectAllOfClaimOption.DISPUTE:
res.redirect(Paths.taskListPage.evaluateUri({ externalId: externalId }))
break
default:
throw new Error(`Unknown rejection option: ${draft.document.rejectAllOfClaim.option}`)
}
}
}))
示例4: renderView
ErrorHandling.apply(async (req: express.Request, res: express.Response): Promise<void> => {
const form: Form<HowMuchHaveYouPaid> = req.body
if (form.hasErrors()) {
renderView(form, res)
} else {
const claim: Claim = res.locals.claim
const draft: Draft<ResponseDraft> = res.locals.responseDraft
const user: User = res.locals.user
draft.document.rejectAllOfClaim.howMuchHaveYouPaid = form.model
const { externalId } = req.params
const paidLessThanClaimed = form.model.amount < claim.totalAmountTillToday
const admissionsEnabled = ClaimFeatureToggles.isFeatureEnabledOnClaim(claim)
if (!paidLessThanClaimed) {
delete draft.document.rejectAllOfClaim.whyDoYouDisagree
delete draft.document.timeline
delete draft.document.evidence
delete draft.document.freeMediation
}
await new DraftService().save(draft, user.bearerToken)
if (paidLessThanClaimed) {
if (admissionsEnabled) {
res.redirect(FullRejectionPaths.youHavePaidLessPage.evaluateUri({ externalId: externalId }))
} else {
res.redirect(Paths.sendYourResponseByEmailPage.evaluateUri({ externalId: externalId }))
}
} else if (admissionsEnabled) {
res.redirect(Paths.taskListPage.evaluateUri({ externalId: externalId }))
} else {
res.redirect(Paths.sendYourResponseByEmailPage.evaluateUri({ externalId: externalId }))
}
}
}))
示例5: expect
.expect(res => expect(res).to.be.redirect
.toLocation(ResponsePaths.sendYourResponseByEmailPage
.evaluateUri({ externalId: claimStoreServiceMock.sampleClaimObj.externalId })))
示例6: attachDefaultHooks
import { attachDefaultHooks } from 'test/routes/hooks'
import 'test/routes/expectations'
import { checkAuthorizationGuards } from 'test/common/checks/authorization-check'
import { Paths as ResponsePaths } from 'response/paths'
import { app } from 'main/app'
import * as idamServiceMock from 'test/http-mocks/idam'
import * as draftStoreServiceMock from 'test/http-mocks/draft-store'
import * as claimStoreServiceMock from 'test/http-mocks/claim-store'
import * as feesServiceMock from 'test/http-mocks/fees'
import { checkNotDefendantInCaseGuard } from 'test/common/checks/not-defendant-in-case-check'
const cookieName: string = config.get<string>('session.cookieName')
const pagePath = ResponsePaths.sendYourResponseByEmailPage.evaluateUri({ externalId: claimStoreServiceMock.sampleClaimObj.externalId })
describe('Defendant response: send your response by email', () => {
attachDefaultHooks(app)
describe('on GET', () => {
const method = 'get'
checkAuthorizationGuards(app, method, pagePath)
checkNotDefendantInCaseGuard(app, method, pagePath)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen')
})
it('should return 500 and render error page when retrieving issue fee range group failed', async () => {