本文整理汇总了TypeScript中test/features/offer/routes/checks/authorization-check.checkAuthorizationGuards函数的典型用法代码示例。如果您正苦于以下问题:TypeScript checkAuthorizationGuards函数的具体用法?TypeScript checkAuthorizationGuards怎么用?TypeScript checkAuthorizationGuards使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkAuthorizationGuards函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('on GET', () => {
checkAuthorizationGuards(app, 'get', confirmationPage)
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(confirmationPage)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should render page when everything is fine', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
await request(app)
.get(confirmationPage)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Weâve sent your offer'))
})
})
})
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:26,代码来源:offer-confirmation.ts
示例2: describe
describe('on GET', () => {
checkAuthorizationGuards(app, 'get', Paths.agreementReceiver.evaluateUri({ externalId: externalId }))
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should return 500 and render error page when cannot retrieve claim by external id', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.get(Paths.agreementReceiver.evaluateUri({ externalId: externalId }))
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should return 500 and render error page when cannot generate PDF', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
claimStoreServiceMock.rejectRetrieveDocument('Something went wrong')
await request(app)
.get(Paths.agreementReceiver.evaluateUri({ externalId: externalId }))
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should return receipt when everything is fine', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
claimStoreServiceMock.resolveRetrieveDocument()
await request(app)
.get(Paths.agreementReceiver.evaluateUri({ externalId: externalId }))
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful)
})
})
})
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:38,代码来源:agreement.ts
示例3: describe
describe('on POST', () => {
checkAuthorizationGuards(app, 'post', responsePage)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen', 'defendant')
})
context('when middleware failure', () => {
it('should return 500 when cannot retrieve claim by external id', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.post(responsePage)
.set('Cookie', `${cookieName}=ABC`)
.send({})
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
context('when form is valid', async () => {
it('should redirect to make a legal agreement page when offer is accepted', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
const formData = {
option: StatementType.ACCEPTATION.value
}
await request(app)
.post(responsePage)
.set('Cookie', `${cookieName}=ABC`)
.send(formData)
.expect(res => expect(res).to.be.redirect.toLocation(makeLegalAgreementPage))
})
it('should submit rejection and redirect to confirmation page', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
claimStoreServiceMock.resolveRejectOffer()
const formData = {
option: StatementType.REJECTION.value
}
await request(app)
.post(responsePage)
.set('Cookie', `${cookieName}=ABC`)
.send(formData)
.expect(res => expect(res).to.be.redirect.toLocation(rejectedOfferPage))
})
})
context('when form is invalid', async () => {
it('should render page with errors', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
const formData = {
option: undefined
}
await request(app)
.post(responsePage)
.set('Cookie', `${cookieName}=ABC`)
.send(formData)
.expect(res => expect(res).to.be.successful.withText('Choose option: yes or no or make an offer', 'div class="error-summary"'))
})
})
})
})
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:65,代码来源:response.ts
示例4: describe
describe('on POST', () => {
checkAuthorizationGuards(app, 'post', declarationPage)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen', 'defendant')
})
context('when middleware failure', () => {
it('should return 500 when cannot retrieve claim by external id', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.post(declarationPage)
.set('Cookie', `${cookieName}=ABC`)
.send({})
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
context('when form is valid', () => {
context('when accepting offer as claimant', () => {
it('should accepted offer and redirect to confirmation page', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
claimStoreServiceMock.resolveAcceptOffer()
const formData = {
signed: 'true'
}
await request(app)
.post(declarationPage)
.set('Cookie', `${cookieName}=ABC`)
.send(formData)
.expect(res => expect(res).to.be.redirect.toLocation(acceptedPage))
})
})
context('when countersigning offer as defendant', () => {
const override: object = {
submitterId: '123',
defendantId: '1',
settlement: {
partyStatements: [
{
type: StatementType.OFFER.value,
madeBy: MadeBy.DEFENDANT.value,
offer: { content: 'offer text', completionDate: '2017-08-08' }
},
{
type: StatementType.ACCEPTATION.value,
madeBy: MadeBy.CLAIMANT.value
}
]
}
}
it('should countersign offer and redirect to confirmation page when offer accepted by claimant', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(override)
claimStoreServiceMock.resolveCountersignOffer()
await request(app)
.post(declarationPage)
.set('Cookie', `${cookieName}=ABC`)
.send({ signed: 'true' })
.expect(res => expect(res).to.be.redirect.toLocation(settledPage))
})
})
})
context('when form is invalid', async () => {
it('should render page with errors', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
const formData = {
signed: undefined
}
await request(app)
.post(declarationPage)
.set('Cookie', `${cookieName}=ABC`)
.send(formData)
.expect(res => expect(res).to.be.successful.withText('Please select I confirm Iâve read and accept the terms of the agreement.', 'div class="error-summary"'))
})
})
})
})
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:81,代码来源:declaration.ts
示例5: describe
describe('on POST', () => {
checkAuthorizationGuards(app, 'post', offerPage)
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(offerPage)
.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 offer confirmation page', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
claimStoreServiceMock.resolveSaveOffer()
const futureDate = moment().add(1, 'day')
const formData = {
offerText: 'Offer Text',
completionDate: new LocalDate(futureDate.year(), futureDate.month() + 1, futureDate.date())
}
await request(app)
.post(offerPage)
.set('Cookie', `${cookieName}=ABC`)
.send(formData)
.expect(res => expect(res).to.be.redirect.toLocation(confirmationPage))
})
it('should return 500 and render error page when cannot save offer', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
claimStoreServiceMock.rejectSaveOfferForDefendant()
await request(app)
.post(offerPage)
.set('Cookie', `${cookieName}=ABC`)
.send(validFormData)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
context('when provided date is in past', async () => {
it('should render page with error', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
await request(app)
.post(offerPage)
.set('Cookie', `${cookieName}=ABC`)
.send({
offerText: 'Offer Text',
completionDate: new LocalDate(1980, 1, 1)
})
.expect(res => expect(res).to.be.successful.withText('Enter an offer date in the future', 'div class="error-summary"'))
})
})
})
})
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:63,代码来源:your-offer.ts
注:本文中的test/features/offer/routes/checks/authorization-check.checkAuthorizationGuards函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论