本文整理汇总了TypeScript中test/features/ccj/routes/checks/not-claimant-in-case-check.checkNotClaimantInCaseGuard函数的典型用法代码示例。如果您正苦于以下问题:TypeScript checkNotClaimantInCaseGuard函数的具体用法?TypeScript checkNotClaimantInCaseGuard怎么用?TypeScript checkNotClaimantInCaseGuard使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkNotClaimantInCaseGuard函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('on GET', () => {
const method = 'get'
checkAuthorizationGuards(app, method, pagePath)
checkNotClaimantInCaseGuard(app, method, pagePath)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
context('when user authorised', () => {
it('should return 500 and render error page when cannot retrieve claims', 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 () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(
{ countyCourtJudgmentRequestedAt: '2017-10-10T22:45:51.785' }
)
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('County Court Judgment requested'))
})
})
})
})
示例2: describe
describe('on GET', () => {
const method = 'get'
checkAuthorizationGuards(app, method, pagePath)
checkNotClaimantInCaseGuard(app, method, pagePath)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
context('when user authorised', () => {
it('should return 500 and render error page when cannot retrieve claims', 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 () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId({
respondedAt: MomentFactory.currentDateTime(),
countyCourtJudgmentRequestedAt: '2017-10-10T22:45:51.785',
countyCourtJudgment: {
defendantDateOfBirth: '1990-11-01',
paidAmount: 2,
paymentOption: 'INSTALMENTS',
repaymentPlan: {
instalmentAmount: 30,
firstPaymentDate: '2018-11-11',
paymentSchedule: 'EVERY_MONTH',
completionDate: '2019-11-11',
paymentLength: '12 months'
},
ccjType: CountyCourtJudgmentType.DETERMINATION
},
reDetermination: {
explanation: 'I feel Defendant can pay earlier and I need money sooner',
partyType: MadeBy.CLAIMANT.value
},
reDeterminationRequestedAt: '2017-10-11T22:45:51.785'
})
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Youâve asked for a judge to decide a repayment plan'))
})
})
})
})
示例3: describe
describe('on GET', () => {
const method = 'get'
checkAuthorizationGuards(app, method, pagePath)
checkNotClaimantInCaseGuard(app, method, pagePath)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
context('when user authorised', () => {
it('should return 500 and render error page when cannot retrieve claims', 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 return 500 and render error page when cannot retrieve CCJ draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.rejectFind('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 () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('ccj')
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Suggest instalments for the defendant'))
})
})
})
})
示例4: describe
describe('on GET', () => {
const method = 'get'
checkAuthorizationGuards(app, method, pagePath)
checkNotClaimantInCaseGuard(app, method, pagePath)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should return 500 and render error page when cannot retrieve claims', 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 return 500 and render error page when cannot retrieve draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(sampleFullAdmissionWithPaymentBySetDateResponseObj)
draftStoreServiceMock.rejectFind('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 () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(sampleFullAdmissionWithPaymentBySetDateResponseObj)
draftStoreServiceMock.resolveFind('claimantResponse')
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText(heading))
})
})
})
示例5: describe
describe('on POST', () => {
const method = 'post'
checkAuthorizationGuards(app, method, pagePath)
checkNotClaimantInCaseGuard(app, method, pagePath)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
context('when middleware failure', () => {
it('should return 500 when cannot retrieve claim by external id', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validFormData)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should return 500 when cannot retrieve draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(sampleFullAdmissionWithPaymentBySetDateResponseObj)
draftStoreServiceMock.rejectFind('Error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validFormData)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
context('when form is valid', async () => {
it('should redirect to claim amount summary page', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(sampleFullAdmissionWithPaymentBySetDateResponseObj)
draftStoreServiceMock.resolveFind('claimantResponse')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validFormData)
.expect(res => expect(res).to.be.redirect.toLocation(paidAmountSummaryPage))
})
it('should return 500 and render error page when cannot save draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(sampleFullAdmissionWithPaymentBySetDateResponseObj)
draftStoreServiceMock.resolveFind('claimantResponse')
draftStoreServiceMock.rejectSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validFormData)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
context('when form is invalid', async () => {
it('should render page', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(sampleFullAdmissionWithPaymentBySetDateResponseObj)
draftStoreServiceMock.resolveFind('claimantResponse')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({})
.expect(res => expect(res).to.be.successful.withText(heading, 'div class="error-summary"'))
})
})
context('when provided paid amount is greater than total amount', async () => {
it('should render page', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(sampleFullAdmissionWithPaymentBySetDateResponseObj)
draftStoreServiceMock.resolveFind('claimantResponse')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({
option: PaidAmountOption.YES.value,
amount: 101,
claimedAmount: 100
})
.expect(res => expect(res).to.be.successful.withText(heading, 'div class="error-summary"'))
})
})
})
})
示例6: describe
describe('on POST', () => {
const method = 'post'
checkAuthorizationGuards(app, method, pagePath)
checkNotClaimantInCaseGuard(app, method, pagePath)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
context('when service is unhealthy', () => {
it('should return 500 when cannot retrieve claim by external id', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validFormData)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should return 500 when cannot retrieve CCJ draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.rejectFind('Error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validFormData)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should return 500 when cannot save CCJ draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('ccj')
draftStoreServiceMock.rejectSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validFormData)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
context('when service is healthy', () => {
beforeEach(() => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('ccj')
})
context('when form is valid', async () => {
beforeEach(() => {
draftStoreServiceMock.resolveSave()
})
async function checkThatSelectedPaymentOptionRedirectsToPage (data: object, expectedToRedirect: string) {
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(data)
.expect(res => expect(res).to.be.redirect.toLocation(expectedToRedirect))
}
it('should redirect to check and send page for "IMMEDIATELY" option selected', async () => {
await checkThatSelectedPaymentOptionRedirectsToPage({ option: PaymentType.IMMEDIATELY.value }, Paths.checkAndSendPage.evaluateUri({ externalId: externalId }))
})
it('should redirect to repayment plan page for "INSTALMENTS" option selected', async () => {
await checkThatSelectedPaymentOptionRedirectsToPage({ option: PaymentType.INSTALMENTS.value }, Paths.repaymentPlanPage.evaluateUri({ externalId: externalId }))
})
it('should redirect to pay by set date page for "BY_SPECIFIED_DATE" option selected', async () => {
await checkThatSelectedPaymentOptionRedirectsToPage({ option: PaymentType.BY_SPECIFIED_DATE.value }, Paths.payBySetDatePage.evaluateUri({ externalId: externalId }))
})
})
context('when form is invalid', async () => {
it('should render page', async () => {
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ name: 'John Smith' })
.expect(res => expect(res).to.be.successful.withText('Payment options', 'div class="error-summary"'))
})
})
})
})
})
示例7: describe
describe('on POST', () => {
const validBasicFormData = { signed: 'true', type: SignatureType.BASIC }
const validQualifiedFormData = {
signed: 'true',
type: SignatureType.QUALIFIED,
signerName: 'Jonny',
signerRole: 'Director'
}
const method = 'post'
checkAuthorizationGuards(app, method, pagePath)
checkNotClaimantInCaseGuard(app, method, pagePath)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
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`)
.send(validBasicFormData)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should return 500 when cannot retrieve CCJ draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.rejectFind('Error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validBasicFormData)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
context('when form is valid', async () => {
it('should redirect to confirmation page when signature is basic', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('ccj')
claimStoreServiceMock.resolveSaveCcjForExternalId()
draftStoreServiceMock.resolveDelete()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validBasicFormData)
.expect(res => expect(res).to.be.redirect.toLocation(confirmationPage))
})
it('should redirect to confirmation page when signature is qualified', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('ccj')
draftStoreServiceMock.resolveSave()
claimStoreServiceMock.resolveSaveCcjForExternalId()
draftStoreServiceMock.resolveDelete()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validQualifiedFormData)
.expect(res => expect(res).to.be.redirect.toLocation(confirmationPage))
})
it('should return 500 when cannot save CCJ', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('ccj')
claimStoreServiceMock.rejectSaveCcjForExternalId()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validBasicFormData)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
context('when form is invalid', async () => {
it('should render page with error messages when signature is basic', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('ccj')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ signed: undefined, type: SignatureType.BASIC })
.expect(res => expect(res).to.be.successful.withText(BasicValidationErrors.DECLARATION_REQUIRED,
'div class="error-summary"'))
})
it('should render page with error messages when signature is qualified', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('ccj')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ signed: 'true', type: SignatureType.QUALIFIED, signerName: '', signerRole: '' })
.expect(res => expect(res).to.be.successful.withText(QualifiedValidationErrors.SIGNER_NAME_REQUIRED,
//.........这里部分代码省略.........
示例8: describe
describe('on POST', () => {
const validFormData = { known: 'true', date: { day: '31', month: '12', year: '1900' } }
const method = 'post'
checkAuthorizationGuards(app, method, pagePath)
checkNotClaimantInCaseGuard(app, method, pagePath)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
checkAccessGuard(app, method)
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`)
.send(validFormData)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should return 500 when cannot retrieve CCJ draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.rejectFind('Error')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validFormData)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
context('when form is valid', async () => {
it('should return 500 and render error page when cannot save ccj draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('ccj')
draftStoreServiceMock.rejectSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validFormData)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should redirect to paid amount page', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('ccj')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validFormData)
.expect(res => expect(res).to.be.redirect.toLocation(paidAmountPage))
})
})
context('when form is invalid', async () => {
it('should render page when everything is fine', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('ccj')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ known: undefined })
.expect(res => expect(res).to.be.successful.withText('Do you know the defendantâs date of birth?', 'div class="error-summary"'))
})
})
})
})