本文整理汇总了TypeScript中test/features/claim/routes/checks/eligibility-check.checkEligibilityGuards函数的典型用法代码示例。如果您正苦于以下问题:TypeScript checkEligibilityGuards函数的具体用法?TypeScript checkEligibilityGuards怎么用?TypeScript checkEligibilityGuards使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkEligibilityGuards函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('on POST', () => {
checkAuthorizationGuards(app, 'post', ClaimPaths.resolvingThisDisputerPage.uri)
checkEligibilityGuards(app, 'post', ClaimPaths.resolvingThisDisputerPage.uri)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should return 500 and render error page when cannot save draft', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.rejectSave()
await request(app)
.post(ClaimPaths.resolvingThisDisputerPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should redirect to task list when everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(ClaimPaths.resolvingThisDisputerPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.taskListPage.uri))
})
})
})
示例2: describe
describe('on POST', () => {
checkAuthorizationGuards(app, 'post', pagePath)
checkEligibilityGuards(app, 'post', pagePath)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should render page when form is invalid and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText(pageContent, 'div class="error-summary"'))
})
it('should return 500 and render error page when form is valid and cannot save draft', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.rejectSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ type: InterestDateType.SUBMISSION })
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should redirect to total page when form is valid, submission date selected and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ type: InterestDateType.SUBMISSION })
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.totalPage.uri))
})
it('should redirect to interest start date page when form is valid, custom date selected and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({
type: InterestDateType.CUSTOM
})
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.interestStartDatePage.uri))
})
})
})
示例3: describe
describe('on POST', () => {
checkAuthorizationGuards(app, 'post', ClaimPaths.defendantEmailPage.uri)
checkEligibilityGuards(app, 'post', ClaimPaths.defendantEmailPage.uri)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should render page when form is invalid and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
await request(app)
.post(ClaimPaths.defendantEmailPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ address: 'invalid-email-address' })
.expect(res => expect(res).to.be.successful.withText('Their email address (optional)', 'div class="error-summary"'))
})
it('should return 500 and render error page when form is valid and cannot save draft', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.rejectSave()
await request(app)
.post(ClaimPaths.defendantEmailPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ address: 'defendant@example.com' })
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should redirect to task list when form is valid and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(ClaimPaths.defendantEmailPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ address: 'defendant@example.com' })
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.taskListPage.uri))
})
it('should redirect to task list when no email address is given', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(ClaimPaths.defendantEmailPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ address: '' })
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.taskListPage.uri))
})
})
})
示例4: describe
describe('on POST', () => {
checkAuthorizationGuards(app, 'post', ClaimPaths.checkAndSendPage.uri)
checkEligibilityGuards(app, 'post', ClaimPaths.checkAndSendPage.uri)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should redirect to incomplete submission when not all tasks are completed', async () => {
draftStoreServiceMock.resolveFind('claim', { readResolveDispute: false })
await request(app)
.post(ClaimPaths.checkAndSendPage.uri)
.send({ type: SignatureType.BASIC })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.incompleteSubmissionPage.uri))
})
it('should return 500 and render error page when form is invalid and cannot calculate fee', async () => {
draftStoreServiceMock.resolveFind('claim')
feesServiceMock.rejectCalculateIssueFee('HTTP error')
await request(app)
.post(ClaimPaths.checkAndSendPage.uri)
.send({ type: SignatureType.BASIC })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should render page when form is invalid and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
feesServiceMock.resolveCalculateIssueFee()
await request(app)
.post(ClaimPaths.checkAndSendPage.uri)
.send({ type: SignatureType.BASIC })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Check your answers', 'div class="error-summary"'))
})
it('should redirect to payment page when form is valid and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
await request(app)
.post(ClaimPaths.checkAndSendPage.uri)
.send({ type: SignatureType.BASIC })
.set('Cookie', `${cookieName}=ABC`)
.send({ signed: 'true' })
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.startPaymentReceiver.uri))
})
})
})
示例5: describe
describe('on POST', () => {
checkAuthorizationGuards(app, 'post', ClaimPaths.claimantMobilePage.uri)
checkEligibilityGuards(app, 'post', ClaimPaths.claimantMobilePage.uri)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should render page when form is invalid and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
await request(app)
.post(ClaimPaths.claimantMobilePage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText(headerText, 'div class="error-summary"'))
})
it('should return 500 and render error page when form is valid and cannot save draft', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.rejectSave()
await request(app)
.post(ClaimPaths.claimantMobilePage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ number: '07000000000' })
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should redirect to task list when form is valid and nothing is submitted', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(ClaimPaths.claimantMobilePage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ number: '' })
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.taskListPage.uri))
})
it('should redirect to task list when form is valid and number is provided', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(ClaimPaths.claimantMobilePage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ number: '07000000000' })
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.taskListPage.uri))
})
})
})
示例6: describe
describe('on POST', () => {
checkAuthorizationGuards(app, 'post', ClaimPaths.claimantDateOfBirthPage.uri)
checkEligibilityGuards(app, 'post', ClaimPaths.claimantDateOfBirthPage.uri)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should render page when form is empty and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
await request(app)
.post(ClaimPaths.claimantDateOfBirthPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('What is your date of birth?', 'div class="error-summary"'))
})
it('should render page with error when DOB is less than 18', async () => {
draftStoreServiceMock.resolveFind('claim')
const date: Moment = MomentFactory.currentDate().subtract(1, 'year')
await request(app)
.post(ClaimPaths.claimantDateOfBirthPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ known: 'true', date: { day: date.date(), month: date.month() + 1, year: date.year() } })
.expect(res => expect(res).to.be.successful.withText('Please enter a date of birth before', 'div class="error-summary"'))
})
it('should return 500 and render error page when form is valid and cannot save draft', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.rejectSave()
await request(app)
.post(ClaimPaths.claimantDateOfBirthPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ known: 'true', date: { day: '31', month: '12', year: '1980' } })
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should redirect to claimant mobile page when form is valid and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(ClaimPaths.claimantDateOfBirthPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ known: 'true', date: { day: '31', month: '12', year: '1980' } })
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.claimantMobilePage.uri))
})
})
})
示例7: describe
describe('on GET', () => {
checkAuthorizationGuards(app, 'get', ClaimPaths.defendantSoleTraderOrSelfEmployedDetailsPage.uri)
checkEligibilityGuards(app, 'get', ClaimPaths.defendantSoleTraderOrSelfEmployedDetailsPage.uri)
it('should render page when everything is fine', async () => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
draftStoreServiceMock.resolveFind('claim')
await request(app)
.get(ClaimPaths.defendantSoleTraderOrSelfEmployedDetailsPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText(theirTitle, theirFirstName, theirLastName))
})
})
示例8: describe
describe('on GET', () => {
checkAuthorizationGuards(app, 'get', pagePath)
checkEligibilityGuards(app, 'get', pagePath)
it('should render page when everything is fine', async () => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
draftStoreServiceMock.resolveFind('claim')
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText(pageContent))
})
})
示例9: describe
describe('on GET', () => {
checkAuthorizationGuards(app, 'get', ClaimPaths.defendantPartyTypeSelectionPage.uri)
checkEligibilityGuards(app, 'get', ClaimPaths.defendantPartyTypeSelectionPage.uri)
it('should render page when everything is fine', async () => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
draftStoreServiceMock.resolveFind('claim')
await request(app)
.get(ClaimPaths.defendantPartyTypeSelectionPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText(expectedTextOnPage))
})
})
示例10: describe
describe('on GET', () => {
checkAuthorizationGuards(app, 'get', ClaimPaths.incompleteSubmissionPage.uri)
checkEligibilityGuards(app, 'get', ClaimPaths.incompleteSubmissionPage.uri)
it('should render page when everything is fine', async () => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
draftStoreServiceMock.resolveFind('claim')
await request(app)
.get(ClaimPaths.incompleteSubmissionPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful
.withText('You need to complete all sections before you submit your claim'))
})
})