本文整理汇总了TypeScript中test/features/dashboard/routes/checks/authorization-check.checkAuthorizationGuards函数的典型用法代码示例。如果您正苦于以下问题:TypeScript checkAuthorizationGuards函数的具体用法?TypeScript checkAuthorizationGuards怎么用?TypeScript checkAuthorizationGuards使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkAuthorizationGuards函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('on GET', () => {
checkAuthorizationGuards(app, 'get', defendantPage)
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(defendantPage)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should render page when everything is fine', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(
{ directionsQuestionnaireDeadline: MomentFactory.currentDate() }
)
await request(app)
.get(defendantPage)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful
.withText('Claim number', claimStoreServiceMock.sampleClaimObj.referenceNumber))
})
})
})
示例2: describe
describe('on GET', () => {
checkAuthorizationGuards(app, 'get', contactThemPage)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should return 500 and render error page when cannot retrieve address', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.get(contactThemPage)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
context('when at least one claim issued', () => {
beforeEach(() => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
})
it('should render page when everything is fine', async () => {
await request(app)
.get(contactThemPage)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Address'))
})
})
})
})
示例3: describe
describe('on GET', () => {
checkAuthorizationGuards(app, 'get', claimPagePath)
checkAuthorizationGuards(app, 'get', defendantPagePath)
context('when user authorised', () => {
context('Claim Status', () => {
context('as a claimant', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
testData.forEach(data => {
it(`should render claim status: ${data.status}`, async () => {
claimStoreServiceMock.resolveRetrieveByExternalId(data.claim, data.claimOverride)
await request(app)
.get(claimPagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText(...data.claimantAssertions))
})
})
})
context('as a defendant', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('123', 'citizen')
})
testData.forEach(data => {
it(`should render dashboard: ${data.status}`, async () => {
claimStoreServiceMock.resolveRetrieveByExternalId(data.claim, data.claimOverride)
await request(app)
.get(defendantPagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText(...data.defendantAssertions))
})
})
})
})
})
})
示例4: describe
describe('on GET', () => {
checkAuthorizationGuards(app, 'get', claimPagePath)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.submitterId, 'citizen')
})
context('when claim is in draft stage', () => {
it('should render page when everything is fine', async () => {
await request(app)
.get(draftPagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Claim number', 'Draft'))
})
})
context('when claim is not in draft stage', () => {
it('should return 500 and render error page when cannot retrieve claims', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.get(claimPagePath)
.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(claimPagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Claim number', claimStoreServiceMock.sampleClaimObj.referenceNumber))
})
context('when accessor is not the claimant', () => {
it('should return forbidden', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId({
submitterId: claimStoreServiceMock.sampleClaimObj.defendantId,
defendantId: claimStoreServiceMock.sampleClaimObj.submitterId
})
await request(app)
.get(claimPagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.forbidden)
})
})
})
})
})
示例5: describe
describe('on GET', () => {
checkAuthorizationGuards(app, 'get', Paths.dashboardPage.uri)
context('when user authorised', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should return 500 and render error page when cannot retrieve claims', async () => {
draftStoreServiceMock.resolveFind('claim')
claimStoreServiceMock.rejectRetrieveByClaimantId('HTTP error')
await request(app)
.get(Paths.dashboardPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
context('when no claims issued', () => {
beforeEach(() => {
claimStoreServiceMock.resolveRetrieveByClaimantIdToEmptyList()
claimStoreServiceMock.resolveRetrieveByDefendantIdToEmptyList()
})
it('should render page with start claim button when everything is fine', async () => {
draftStoreServiceMock.resolveFindNoDraftFound()
await request(app)
.get(Paths.dashboardPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Your money claims account', 'Make a new money claim'))
})
it('should render page with continue claim button when everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
await request(app)
.get(Paths.dashboardPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Your money claims account', 'Continue with claim'))
})
})
context('Dashboard Status', () => {
context('as a claimant', () => {
beforeEach(() => {
claimStoreServiceMock.resolveRetrieveByDefendantIdToEmptyList()
})
it('should render page with start claim button when everything is fine', async () => {
draftStoreServiceMock.resolveFindNoDraftFound()
claimStoreServiceMock.resolveRetrieveByClaimantIdToEmptyList()
await request(app)
.get(Paths.dashboardPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Your money claims account', 'Make a new money claim'))
})
it('should render page with claim number and status', async () => {
draftStoreServiceMock.resolveFindNoDraftFound()
claimStoreServiceMock.resolveRetrieveByClaimantId(claimStoreServiceMock.sampleClaimIssueObj)
await request(app)
.get(Paths.dashboardPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('000MC050', 'Your claim has been sent'))
})
testData.forEach(data => {
it(`should render dashboard: ${data.status}`, async () => {
draftStoreServiceMock.resolveFindNoDraftFound()
claimStoreServiceMock.resolveRetrieveByClaimantId(data.claim, data.claimOverride)
await request(app)
.get(Paths.dashboardPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText(...data.claimantAssertions))
})
})
})
context('as a defendant', () => {
beforeEach(() => {
claimStoreServiceMock.resolveRetrieveByClaimantIdToEmptyList()
})
it('should render page with start claim button when everything is fine', async () => {
draftStoreServiceMock.resolveFindNoDraftFound()
claimStoreServiceMock.resolveRetrieveByDefendantIdToEmptyList()
await request(app)
.get(Paths.dashboardPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Your money claims account', 'Make a new money claim'))
})
it('should render page with claim number and status', async () => {
draftStoreServiceMock.resolveFindNoDraftFound()
claimStoreServiceMock.resolveRetrieveByDefendantId(claimStoreServiceMock.sampleClaimIssueObj.referenceNumber, '1', claimStoreServiceMock.sampleClaimIssueObj)
await request(app)
.get(Paths.dashboardPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('000MC050', 'Respond to claim'))
//.........这里部分代码省略.........