本文整理汇总了TypeScript中test/common/checks/ccj-requested-check.checkCountyCourtJudgmentRequestedGuard函数的典型用法代码示例。如果您正苦于以下问题:TypeScript checkCountyCourtJudgmentRequestedGuard函数的具体用法?TypeScript checkCountyCourtJudgmentRequestedGuard怎么用?TypeScript checkCountyCourtJudgmentRequestedGuard使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkCountyCourtJudgmentRequestedGuard函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen', 'defendant')
})
checkAlreadySubmittedGuard(app, method, pagePath)
checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
describe('errors are handled properly', () => {
it('should return 500 and render error page when cannot retrieve claim', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should return 500 and render error page when cannot retrieve draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.rejectFind('Error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
context('should redirect to Employment page when', () => {
it('"no" selected', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.send({ declared: 'false' })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect
.toLocation(StatementOfMeansPaths.carerPage.evaluateUri(
{ externalId: claimStoreServiceMock.sampleClaimObj.externalId })
)
)
})
it('"yes" selected', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.send({
declared: 'false',
numberOfPeople: { value: 1, details: 'It is my story' }
})
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect
.toLocation(StatementOfMeansPaths.carerPage.evaluateUri(
{ externalId: claimStoreServiceMock.sampleClaimObj.externalId })
)
)
})
})
})
示例2: describe
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen', 'defendant')
})
checkAlreadySubmittedGuard(app, method, pagePath)
checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
describe('errors are handled properly', () => {
it('should return 500 and render error page when cannot retrieve claim', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should return 500 and render error page when cannot retrieve draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.rejectFind('Error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
describe('save and continue', () => {
it('should update draft store and redirect', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.send({ rows: [{ typeOfAccount: BankAccountType.ISA.value, joint: false, balance: 10 }] })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect
.toLocation(StatementOfMeansPaths.disabilityPage.evaluateUri(
{ externalId: claimStoreServiceMock.sampleClaimObj.externalId })
)
)
})
})
describe('add a new row', () => {
it('should update draft store and redirect', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission')
await request(app)
.post(pagePath)
.send({ action: { addRow: 'Add row' } })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('List your bank and savings accounts'))
})
})
})
示例3: describe
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen', 'defendant')
})
checkAlreadySubmittedGuard(app, method, pagePath)
checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
describe('errors are handled properly', () => {
it('should return 500 and render error page when cannot retrieve claim', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should return 500 and render error page when cannot retrieve draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.rejectFind('Error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
describe('save and continue', () => {
it('should update draft store and redirect', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission', draftOverride)
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.send({ rows: [{ employerName: 'Comp1', jobTitle: 'BA' }, { employerName: 'Comp2', jobTitle: 'UX' }] })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect
.toLocation(StatementOfMeansPaths.courtOrdersPage.evaluateUri(
{ externalId: claimStoreServiceMock.sampleClaimObj.externalId })
)
)
})
})
describe('add a new row', () => {
it('should update draft store and redirect', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission', draftOverride)
await request(app)
.post(pagePath)
.send({ action: { addRow: 'Add row' } })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Who employs you?'))
})
})
})
示例4: describe
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen', 'defendant')
})
checkAlreadySubmittedGuard(app, method, pagePath)
checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
describe('errors are handled properly', () => {
it('should return 500 and render error page when cannot retrieve claim', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should return 500 and render error page when cannot retrieve draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.rejectFind('Error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should trigger validation when negative amount is given', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission')
await request(app)
.post(pagePath)
.send({
salarySource: {
amount: -100,
schedule: IncomeExpenseSchedule.MONTH.value
},
pensionSource: {
amount: -200,
schedule: IncomeExpenseSchedule.TWO_WEEKS.value
}})
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Enter a valid income from your job amount, maximum two decimal places'))
.expect(res => expect(res).to.be.successful.withText('Enter a valid pension amount, maximum two decimal places'))
})
it('should trigger validation when invalid decimal amount is given', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission')
await request(app)
.post(pagePath)
.send({
salarySource: {
amount: 100.123,
schedule: IncomeExpenseSchedule.MONTH.value
},
jobseekerAllowanceIncomeSource: {
amount: 200.345,
schedule: IncomeExpenseSchedule.TWO_WEEKS.value
} })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Enter a valid income from your job amount, maximum two decimal places'))
.expect(res => expect(res).to.be.successful.withText('Enter a valid Jobseeker’s Allowance (income based) amount, maximum two decimal places'))
})
it('should trigger validation when no amount is given', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission')
await request(app)
.post(pagePath)
.send({
salarySource: {
schedule: IncomeExpenseSchedule.MONTH.value
},
incomeSupportSource: {
schedule: IncomeExpenseSchedule.MONTH.value
} })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Enter how much income from your job you receive'))
.expect(res => expect(res).to.be.successful.withText('Enter how much Income Support you receive'))
})
it('should trigger validation when no schedule is given', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission')
await request(app)
.post(pagePath)
.send({
salarySource: {
amount: 100
},
childTaxCreditSource: {
amount: 700
//.........这里部分代码省略.........
示例5: context
context('when defendant authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen')
})
checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
context('when response not submitted', () => {
it('should return 500 and render error page when cannot retrieve claim', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
context('when form is valid', () => {
it('should redirect to defendant task list when defendant says yes', async () => {
draftStoreServiceMock.resolveFind('mediation')
draftStoreServiceMock.resolveFind('response:full-rejection', { defendantDetails: { partyDetails: { ...draftStoreServiceMock.sampleOrganisationDetails } } })
draftStoreServiceMock.resolveSave()
claimStoreServiceMock.resolveRetrieveClaimBySampleExternalId(claimStoreServiceMock.sampleClaimIssueOrgVOrgObj)
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ option: FreeMediationOption.YES, mediationPhoneNumberConfirmation: '07777777777' })
.expect(res => expect(res).to.be.redirect
.toLocation(ResponsePaths.taskListPage
.evaluateUri({ externalId: claimStoreServiceMock.sampleClaimObj.externalId })))
})
it('should show validation error when defendant says yes with no phone number', async () => {
draftStoreServiceMock.resolveFind('mediation')
draftStoreServiceMock.resolveFind('response:full-rejection', { defendantDetails: { partyDetails: { ...draftStoreServiceMock.sampleOrganisationDetails } } })
claimStoreServiceMock.resolveRetrieveClaimBySampleExternalId(claimStoreServiceMock.sampleClaimIssueOrgVOrgObj)
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ option: FreeMediationOption.YES, mediationPhoneNumberConfirmation: undefined })
.expect(res => expect(res).to.be.successful.withText('div class="error-summary"'))
})
it('should redirect to response task list when no was chosen and a phone number and a contact is given', async () => {
draftStoreServiceMock.resolveFind('mediation')
draftStoreServiceMock.resolveFind('response:full-rejection', { defendantDetails: { partyDetails: { ...draftStoreServiceMock.sampleOrganisationDetails } } })
draftStoreServiceMock.resolveSave()
claimStoreServiceMock.resolveRetrieveClaimBySampleExternalId(claimStoreServiceMock.sampleClaimIssueOrgVOrgObj)
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({
option: FreeMediationOption.NO,
mediationPhoneNumber: '07777777777',
mediationContactPerson: 'Mary Richards'
})
.expect(res => expect(res).to.be.redirect
.toLocation(ResponsePaths.taskListPage
.evaluateUri({ externalId: claimStoreServiceMock.sampleClaimObj.externalId })))
})
it('should show validation error when defendant says no with no phone number', async () => {
draftStoreServiceMock.resolveFind('mediation')
draftStoreServiceMock.resolveFind('response:full-rejection', { defendantDetails: { partyDetails: { ...draftStoreServiceMock.sampleOrganisationDetails } } })
claimStoreServiceMock.resolveRetrieveClaimBySampleExternalId(claimStoreServiceMock.sampleClaimIssueOrgVOrgObj)
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ option: FreeMediationOption.NO, mediationPhoneNumber: undefined })
.expect(res => expect(res).to.be.successful.withText('div class="error-summary"'))
})
it('should show validation error when defendant says no with no contact name', async () => {
draftStoreServiceMock.resolveFind('mediation')
draftStoreServiceMock.resolveFind('response:full-rejection', { defendantDetails: { partyDetails: { ...draftStoreServiceMock.sampleOrganisationDetails } } })
claimStoreServiceMock.resolveRetrieveClaimBySampleExternalId(claimStoreServiceMock.sampleClaimIssueOrgVOrgObj)
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({
option: FreeMediationOption.NO,
mediationPhoneNumber: '07777777777',
mediationContactPerson: undefined
})
.expect(res => expect(res).to.be.successful.withText('div class="error-summary"'))
})
})
})
示例6: context
context('when defendant authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen')
})
checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
context('when response not submitted', () => {
context('when form is invalid', () => {
it('should return 500 and render error page when cannot retrieve claim', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
context('when form is valid', () => {
it('should return 500 and render error page when cannot save draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('mediation')
draftStoreServiceMock.resolveFind('response')
draftStoreServiceMock.rejectSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ option: FreeMediationOption.YES })
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should redirect to can we use page when everything is fine', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('mediation')
draftStoreServiceMock.resolveFind('response')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ option: FreeMediationOption.YES })
.expect(res => expect(res).to.be.redirect
.toLocation(MediationPaths.mediationAgreementPage
.evaluateUri({ externalId: claimStoreServiceMock.sampleClaimObj.externalId })))
})
it('should redirect to response task list when No was chosen and no response is available', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('mediation')
draftStoreServiceMock.resolveFind('response')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ option: FreeMediationOption.NO })
.expect(res => expect(res).to.be.redirect
.toLocation(ResponsePaths.taskListPage
.evaluateUri({ externalId: claimStoreServiceMock.sampleClaimObj.externalId })))
})
})
})
})
示例7: describe
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen', 'defendant')
})
checkAlreadySubmittedGuard(app, method, pagePath)
checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
describe('errors are handled properly', () => {
it('should return 500 and render error page when cannot retrieve claim', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should return 500 and render error page when cannot retrieve draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.rejectFind('Error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
describe('should update draft store and redirect', () => {
it('to unemployed page', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.send({ declared: false })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect
.toLocation(StatementOfMeansPaths.unemployedPage.evaluateUri(
{ externalId: claimStoreServiceMock.sampleClaimObj.externalId })
)
)
})
it('to employers page', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.send({ declared: true, selfEmployed: true, employed: true })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect
.toLocation(StatementOfMeansPaths.employersPage.evaluateUri(
{ externalId: claimStoreServiceMock.sampleClaimObj.externalId })
)
)
})
it('to self-employment page', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.send({ declared: true, selfEmployed: true, employed: false })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect
.toLocation(StatementOfMeansPaths.selfEmploymentPage.evaluateUri(
{ externalId: claimStoreServiceMock.sampleClaimObj.externalId })
)
)
})
})
})
示例8: describe
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen', 'defendant')
})
checkAlreadySubmittedGuard(app, method, pagePath)
checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
describe('errors are handled properly', () => {
it('should return 500 and render error page when cannot retrieve claim', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should return 500 and render error page when cannot retrieve draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.rejectFind('Error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
describe('should update draft store and redirect to ', () => {
it('other dependants page when no children', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.send({ declared: 'false' })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect
.toLocation(StatementOfMeansPaths.otherDependantsPage.evaluateUri(
{ externalId: claimStoreServiceMock.sampleClaimObj.externalId })
)
)
})
it('dependants disability page when some children but 0 between 16 and 19', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.send({
declared: 'true',
numberOfChildren: { under11: '1', between11and15: '2', between16and19: '0' }
})
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect
.toLocation(StatementOfMeansPaths.dependantsDisabilityPage.evaluateUri(
{ externalId: claimStoreServiceMock.sampleClaimObj.externalId })
)
)
})
it('education page when > 0 children between 16 and 19', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.send({
declared: 'true',
numberOfChildren: { under11: '0', between11and15: '0', between16and19: '3' }
})
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect
.toLocation(StatementOfMeansPaths.educationPage.evaluateUri(
{ externalId: claimStoreServiceMock.sampleClaimObj.externalId })
)
)
})
})
})
示例9: context
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen')
})
checkAlreadySubmittedGuard(app, method, pagePath)
checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
context('when response not submitted', () => {
context('when form is invalid', () => {
it('should render page when everything is fine', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Do you owe the money claimed?', 'div class="error-summary"'))
})
})
context('when form is valid', () => {
it('should return 500 and render error page when cannot save draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response')
draftStoreServiceMock.rejectSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ type: ResponseType.DEFENCE })
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should redirect to task list page when everything is fine', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ type: ResponseType.FULL_ADMISSION })
.expect(res => expect(res).to.be.redirect
.toLocation(ResponsePaths.taskListPage.evaluateUri({ externalId: externalId })))
})
it('should redirect to send your response by email page when everything is fine and PART_ADMISSION is selected', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ type: ResponseType.PART_ADMISSION })
.expect(res => expect(res).to.be.redirect
.toLocation(PartAdmissionPaths.alreadyPaidPage.evaluateUri({ externalId: externalId })))
})
it('should redirect to reject all of claim page when everything is fine and DEFENCE is selected', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ type: ResponseType.DEFENCE })
.expect(res => expect(res).to.be.redirect
.toLocation(ResponsePaths.defenceRejectAllOfClaimPage.evaluateUri({ externalId: externalId })))
})
})
})
})
示例10: context
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen')
})
checkAlreadySubmittedGuard(app, method, pagePath)
checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
context('when response not submitted', () => {
it('should redirect to incomplete submission when not all tasks are completed', async () => {
draftStoreServiceMock.resolveFind(draftType, { defendantDetails: undefined })
draftStoreServiceMock.resolveFind('mediation')
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect
.toLocation(ResponsePaths.incompleteSubmissionPage.evaluateUri({ externalId: claimStoreServiceMock.sampleClaimObj.externalId })))
})
it('should return 500 and render error page when cannot retrieve claim', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should render page when everything is fine', async () => {
draftStoreServiceMock.resolveFind(draftType)
draftStoreServiceMock.resolveFind('mediation')
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Check your answers'))
})
context('for individual and sole traders', () => {
it('should return statement of truth with a tick box', async () => {
draftStoreServiceMock.resolveFind(draftType)
draftStoreServiceMock.resolveFind('mediation')
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Statement of truth'))
.expect(res => expect(res).to.be.successful.withText('I believe that the facts stated in this response are true.'))
.expect(res => expect(res).to.be.successful.withText('<input id="signedtrue" type="checkbox" name="signed" value="true"'))
})
})
context('for company and organisation', () => {
it('should return statement of truth with a tick box', async () => {
draftStoreServiceMock.resolveFind('response:company')
draftStoreServiceMock.resolveFind('mediation')
const claimStoreOverride = {
claim: {
claimants: [
{
type: 'company',
name: 'John Smith Ltd',
contactPerson: 'John Smith',
address: {
line1: 'line1',
line2: 'line2',
city: 'city',
postcode: 'bb127nq'
}
}
],
defendants: [
{
type: 'company',
name: 'John Doe Ltd',
contactPerson: 'John Doe',
address: {
line1: 'line1',
line2: 'line2',
city: 'city',
postcode: 'bb127nq'
}
}
],
payment: {
id: '12',
amount: 2500,
state: { status: 'failed' }
},
amount: {
type: 'breakdown',
rows: [{ reason: 'Reason', amount: 200 }]
},
interest: {
type: ClaimInterestType.STANDARD,
rate: 10,
//.........这里部分代码省略.........