本文整理汇总了TypeScript中test/features/ccj/routes/checks/authorization-check.checkAuthorizationGuards函数的典型用法代码示例。如果您正苦于以下问题:TypeScript checkAuthorizationGuards函数的具体用法?TypeScript checkAuthorizationGuards怎么用?TypeScript checkAuthorizationGuards使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkAuthorizationGuards函数的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 POST', () => {
const method = 'post'
checkAuthorizationGuards(app, method, pagePath)
checkAccessGuard(app, method)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
context('when form is valid', async () => {
it('should redirect to dashboard when click on Continue', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(claimWithDQ)
draftStoreServiceMock.resolveFind('directionsQuestionnaire')
draftStoreServiceMock.resolveFind('response')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send()
.expect(res => expect(res).to.be.redirect.toLocation(Paths.permissionForExpertPage.evaluateUri(
{ externalId: externalId })))
})
})
})
})
示例3: describe
describe('on GET', () => {
const method: string = 'get'
checkAuthorizationGuards(app, method, pagePath)
checkAccessGuards(app, method)
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 shouldBeServerError(method, 'Error')
})
it('should return 500 and render error page when cannot retrieve directions questionnaire draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(RouteHelper.createClaim(PartyType.INDIVIDUAL, PartyType.INDIVIDUAL, MadeBy.CLAIMANT))
draftStoreServiceMock.rejectFind('Error')
await shouldBeServerError(method, 'Error')
})
it('should render page when everything is fine', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(RouteHelper.createClaim(PartyType.INDIVIDUAL, PartyType.INDIVIDUAL, MadeBy.CLAIMANT))
draftStoreServiceMock.resolveFind('directionsQuestionnaire')
draftStoreServiceMock.resolveFind('response')
await shouldRenderPageWithText('The defendant chose this location', method)
})
})
})
示例4: describe
describe('on GET', () => {
const method = 'get'
checkAuthorizationGuards(app, method, pagePath)
checkAccessGuard(app, method)
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 directions questionnaire draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(claim)
draftStoreServiceMock.rejectFind('Error')
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
context('when court finder client is not functioning', () => {
it('should render fallback page when everything is fine', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(claim)
draftStoreServiceMock.resolveFind('directionsQuestionnaire')
draftStoreServiceMock.resolveFind('response')
courtFinderMock.rejectFind()
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withoutText('is the nearest to your address you gave us.'))
})
})
context('when court finder client is functioning', () => {
it('should render page when everything is fine', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(claim)
draftStoreServiceMock.resolveFind('directionsQuestionnaire')
draftStoreServiceMock.resolveFind('response')
courtFinderMock.resolveFind()
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Choose a hearing location', `${courtFinderMock.searchResponse[0].name} is the nearest to your home address you gave us.`))
})
})
})
})
示例5: 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'))
})
})
})
})
示例6: describe
describe('on GET', () => {
const method = 'get'
checkAuthorizationGuards(app, method, pagePath)
checkAccessGuard(app, method)
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 directions questionnaire draft', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(claimWithDQ)
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(claimWithDQ)
draftStoreServiceMock.resolveFind('directionsQuestionnaire')
draftStoreServiceMock.resolveFind('response')
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText(
'Using an expert',
'It’s rare for a judge to allow you to use an expert in a small claim. Most small claims don’t need an expert.'
))
})
})
})
示例7: 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'))
})
})
})
})
示例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 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))
})
})
})