本文整理匯總了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))
})
})
})