本文整理汇总了TypeScript中test/common/checks/authorization-check.checkAuthorizationGuards函数的典型用法代码示例。如果您正苦于以下问题:TypeScript checkAuthorizationGuards函数的具体用法?TypeScript checkAuthorizationGuards怎么用?TypeScript checkAuthorizationGuards使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkAuthorizationGuards函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('on GET', () => {
const method = 'get'
checkAuthorizationGuards(app, method, pagePath)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen')
})
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('mediation')
draftStoreServiceMock.resolveFind('response:full-rejection', { defendantDetails: { partyDetails: { ...draftStoreServiceMock.sampleOrganisationDetails } } })
claimStoreServiceMock.resolveRetrieveClaimBySampleExternalId(claimStoreServiceMock.sampleClaimIssueOrgVOrgObj)
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Mary Richards the right person for the mediation service to call'))
})
})
})
示例2: describe
describe('on GET', () => {
const method = 'get'
checkAuthorizationGuards(app, method, pagePath)
context('when user 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)
.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('mediation')
draftStoreServiceMock.resolveFind('response')
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Will you try free mediation?'))
})
})
})
})
示例3: describe
describe('on POST', () => {
const method = 'post'
checkAuthorizationGuards(app, method, pagePath)
checkNotDefendantInCaseGuard(app, method, pagePath)
describe('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should redirect to task list page when court offer is accepted', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantFullAdmissionResponse)
draftStoreServiceMock.resolveFind('claimantResponse', draftOverrideForClaimantReponse)
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ accept: 'yes' })
.expect(res => expect(res).to.be.redirect.toLocation(taskListPagePath))
})
it('should redirect to rejection reason page when court offer is rejected', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantFullAdmissionResponse)
draftStoreServiceMock.resolveFind('claimantResponse', draftOverrideForClaimantReponse)
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ accept: 'no' })
.expect(res => expect(res).to.be.redirect.toLocation(rejectionReasonPagePath))
})
})
})
示例4: describe
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')
})
checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
it('should render page when everything is fine', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalIdWithResponse()
await request(app)
.get(ResponsePaths.confirmationPage.evaluateUri({ externalId: claimStoreServiceMock.sampleClaimObj.externalId }))
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Youâve submitted your response'))
})
it('should return 500 and render error page when cannot retrieve claim', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('internal service error when retrieving response')
await request(app)
.get(ResponsePaths.confirmationPage.evaluateUri({ externalId: claimStoreServiceMock.sampleClaimObj.externalId }))
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
})
})
示例5: describe
describe('on GET', () => {
const method = 'get'
checkAuthorizationGuards(app, method, pagePath)
checkNotDefendantInCaseGuard(app, method, pagePath)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen')
})
checkAlreadySubmittedGuard(app, method, pagePath)
checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
context('when response not submitted', () => {
beforeEach(() => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
})
it('should render page when everything is fine', async () => {
draftStoreServiceMock.resolveFind('response')
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.successful.withText('Do you owe the money claimed?'))
})
})
})
})
示例6: describe
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')
})
checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
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('response')
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
feesServiceMock.resolveGetIssueFeeRangeGroup()
feesServiceMock.resolveGetHearingFeeRangeGroup()
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.successful.withText('Complete and email the defence and counterclaim form by'))
})
})
})
示例7: describe
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')
})
checkAlreadySubmittedGuard(app, method, pagePath)
checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
it('should return 500 and render error page when cannot retrieve claim', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('Internal service error when retrieving response')
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('response:full-rejection')
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Youâve paid less than the total claim amount'))
})
})
})
示例8: describe
describe('on POST', () => {
const method = 'post'
checkAuthorizationGuards(app, method, pagePath)
checkNotDefendantInCaseGuard(app, method, pagePath)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen')
})
checkAlreadySubmittedGuard(app, method, pagePath)
checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
context('when response not submitted', () => {
beforeEach(() => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
})
context('when form is invalid', () => {
it('should render page when everything is fine', async () => {
draftStoreServiceMock.resolveFind('response')
await request(app)
.post(pagePath)
.send({ type: 'individual' })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Confirm your details', 'div class="error-summary"'))
})
})
context('when form is valid', () => {
it('should return 500 and render error page when cannot save draft', async () => {
draftStoreServiceMock.resolveFind('response')
draftStoreServiceMock.rejectSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ type: 'individual', name: 'John Smith', address: { line1: 'Apartment 99', line2: '', line3: '', city: 'London', postcode: 'E10AA' } })
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should redirect to your address page when everything is fine', async () => {
draftStoreServiceMock.resolveFind('response')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ type: 'individual', name: 'John Smith', address: { line1: 'Apartment 99', line2: '', line3: '', city: 'London', postcode: 'E10AA' } })
.expect(res => expect(res).to.be.redirect
.toLocation(ResponsePaths.defendantDateOfBirthPage
.evaluateUri({ externalId: claimStoreServiceMock.sampleClaimObj.externalId })))
})
})
})
})
})
示例9: describe
describe('on POST', () => {
const method = 'post'
checkAuthorizationGuards(app, method, pagePath)
checkNotDefendantInCaseGuard(app, method, pagePath)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen')
})
checkAlreadySubmittedGuard(app, method, pagePath)
checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
context('when response not submitted', () => {
beforeEach(() => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
})
context('when form is invalid', () => {
it('should render page when everything is fine', async () => {
draftStoreServiceMock.resolveFind('response')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText(headerText, 'div class="error-summary"'))
})
})
context('when form is valid', () => {
it('should return 500 and render error page when cannot save draft', async () => {
draftStoreServiceMock.resolveFind('response')
draftStoreServiceMock.rejectSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ number: '07123456789' })
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should redirect to task list page when everything is fine', async () => {
draftStoreServiceMock.resolveFind('response')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ number: '07123456789' })
.expect(res => expect(res).to.be.redirect
.toLocation(ResponsePaths.taskListPage
.evaluateUri({ externalId: claimStoreServiceMock.sampleClaimObj.externalId })))
})
})
})
})
})
示例10: describe
describe('on POST', () => {
const method = 'post'
checkAuthorizationGuards(app, method, pagePath)
checkNotDefendantInCaseGuard(app, method, pagePath)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen')
})
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('update', () => {
it('should update draft store and redirect', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
draftStoreServiceMock.resolveFind('response:full-admission', draftOverride)
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.send({ jobTitle: 'my role', annualTurnover: 10, areYouBehindOnTax: false })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect
.toLocation(StatementOfMeansPaths.onTaxPaymentsPage.evaluateUri(
{ externalId: claimStoreServiceMock.sampleClaimObj.externalId })
)
)
})
})
})
})