本文整理汇总了TypeScript中test/features/claimant-response/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)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.submitterId, 'citizen')
})
context('when claimant response submitted', () => {
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 () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(claimStoreServiceMock.samplePartialAdmissionWithPaymentBySetDateResponseObj)
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Your claim number:'))
})
})
})
})
示例2: describe
describe('on GET', () => {
const method = 'get'
checkAuthorizationGuards(app, method, pagePath)
checkNotClaimantInCaseGuard(app, method, pagePath)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.submitterId, 'citizen')
})
context('when service is unhealthy', () => {
it('should return 500 and render error page when cannot retrieve claim by external id', 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(claimStoreServiceMock.sampleFullAdmissionWithPaymentBySetDateResponseObj)
draftStoreServiceMock.rejectFind('Error')
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
context('when service is healthy', () => {
beforeEach(() => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(claimStoreServiceMock.sampleFullAdmissionWithPaymentBySetDateResponseObj)
draftStoreServiceMock.resolveFind('claimantResponse', claimantResponseDraftOverrideWithDisposableIncome)
})
it(`should render page with heading '${heading}'`, async () => {
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText(heading))
})
it('should show the claimant response notice', async () => {
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('The court will review your suggestion and may reject it if it’s sooner than the defendant can afford to repay the money.'))
})
})
})
})
示例3: describe
describe('on GET', () => {
const method = 'get'
checkAuthorizationGuards(app, method, pagePath)
checkNotClaimantInCaseGuard(app, method, pagePath)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.submitterId, 'citizen')
})
context('when service is unhealthy', () => {
it('should return 500 and render error page when cannot retrieve claim by external id', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
context('when claimant has been paid in full', () => {
it('should display form asking when money was received', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('claim')
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('When did you settle the claim?'))
})
})
context('when claimant has already been paid in full', () => {
it('should display forbidden page', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId({ moneyReceivedOn: MomentFactory.currentDate().subtract(1, 'day') })
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.forbidden.withText('Forbidden'))
})
})
})
})
示例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 render page when everything is fine', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantPartialAdmissionResponse)
draftStoreServiceMock.resolveFind('claimantResponse')
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Repayment plan accepted'))
})
})
})
示例5: describe
describe('on GET', () => {
const method = 'get'
checkAuthorizationGuards(app, method, pagePath)
checkNotClaimantInCaseGuard(app, method, pagePath)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.submitterId, 'citizen')
})
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)
.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(defendantPartialAdmissionResponse)
draftStoreServiceMock.resolveFind('claimantResponse', {
freeMediation: {
option: FreeMediationOption.NO
}
})
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Free mediation'))
})
})
})
})
示例6: describe
describe('on POST', () => {
const method = 'post'
checkAuthorizationGuards(app, method, pagePath)
checkNotClaimantInCaseGuard(app, method, pagePath)
const validFormData: object = {
totalAmount: 160,
instalmentAmount: 30,
firstPaymentDate: {
day: 31,
month: 12,
year: 2050
},
paymentSchedule: 'EVERY_MONTH'
}
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.submitterId, 'citizen')
})
context('when service is unhealthy', () => {
it('should return 500 and render error page 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 and render error page when cannot retrieve draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(claimStoreServiceMock.sampleFullAdmissionWithPaymentByInstalmentsResponseObj)
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 and render error page when cannot save draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(claimStoreServiceMock.sampleFullAdmissionWithPaymentByInstalmentsResponseObj)
draftStoreServiceMock.resolveFind('claimantResponse', draftOverride)
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', () => {
function setFirstPaymentDate (firstPaymentDate: Moment): object {
return {
day: firstPaymentDate.date(),
month: firstPaymentDate.month() + 1,
year: firstPaymentDate.year()
}
}
function dataToSend (firstPaymentDate: Moment): object {
return {
totalAmount: 100,
instalmentAmount: 50,
firstPaymentDate: {
day: firstPaymentDate.date(),
month: firstPaymentDate.month() + 1,
year: firstPaymentDate.year()
},
paymentSchedule: 'EVERY_MONTH'
}
}
context('when form is valid', async () => {
beforeEach(() => {
draftStoreServiceMock.resolveSave()
})
it('should redirect to counter offer accepted page when decision type is CLAIMANT', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(claimStoreServiceMock.sampleFullAdmissionWithPaymentByInstalmentsResponseObj)
draftStoreServiceMock.resolveFind('claimantResponse', draftOverride)
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validFormData)
.expect(res => expect(res).to.be.redirect.toLocation(Paths.counterOfferAcceptedPage.evaluateUri({ externalId: externalId })))
})
it('should redirect to counter offer accepted page when decision type is CLAIMANT_IN_FAVOUR_OF_DEFENDANT', async () => {
const firstPaymentDate: Moment = MomentFactory.currentDate().add(100, 'years')
claimStoreServiceMock.resolveRetrieveClaimByExternalId(claimStoreServiceMock.sampleFullAdmissionWithPaymentByInstalmentsResponseObj)
draftStoreServiceMock.resolveFind('claimantResponse', draftOverride)
//.........这里部分代码省略.........
示例7: 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 claimantResponse draft', async () => {
draftStoreServiceMock.rejectFind('Error')
claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantPartialAdmissionResponse)
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 task list page', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantPartialAdmissionResponse)
draftStoreServiceMock.resolveFind('claimantResponse')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validFormData)
.expect(res => expect(res).to.be.redirect.toLocation(taskListPagePath))
})
it('should return 500 and render error page when cannot save claimantResponse draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantPartialAdmissionResponse)
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(defendantPartialAdmissionResponse)
draftStoreServiceMock.resolveFind('claimantResponse')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ option: undefined })
.expect(res => expect(res).to.be.successful.withText('Do you want to settle the claim', 'div class="error-summary"'))
})
})
})
})
示例8: 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 claimantResponse draft', async () => {
draftStoreServiceMock.rejectFind('Error')
claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantPartialAdmissionResponse)
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(defendantPartialAdmissionResponse)
draftStoreServiceMock.resolveFind('claimantResponse', {
courtDetermination: {
decisionType: 'DEFENDANT',
courtDecision: {
paymentOption: 'BY_SPECIFIED_DATE',
paymentDate: MomentFactory.parse('2018-11-01'),
repaymentPlan: undefined }
}
})
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('The defendant can’t pay by your proposed date'))
})
it('should render page when everything is fine and COURT date is accepted', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantPartialAdmissionResponse)
draftStoreServiceMock.resolveFind('claimantResponse', {
courtDetermination: {
decisionType: 'COURT',
courtDecision: {
paymentOption: 'BY_SPECIFIED_DATE',
paymentDate: MomentFactory.parse('2018-11-01'),
repaymentPlan: undefined }
}
})
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('The defendant can’t pay by your proposed date'))
})
it('should render page when everything is fine and CLAIMANT date is accepted', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantFullAdmissionResponse)
draftStoreServiceMock.resolveFind('claimantResponse', {
courtDetermination: {
decisionType: 'CLAIMANT',
courtDecision: {
paymentOption: 'BY_SPECIFIED_DATE',
paymentDate: MomentFactory.parse('2018-11-01'),
repaymentPlan: undefined }
},
alternatePaymentMethod: {
paymentOption: {
option: {
value: 'BY_SPECIFIED_DATE',
displayValue: 'By set date'
}
},
paymentDate: new PaymentDate(new LocalDate(2018,11,1)),
paymentPlan: undefined
}
})
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('The defendant can’t pay by your proposed date'))
})
})
})