本文整理汇总了TypeScript中test/localDateUtils.daysFromNow函数的典型用法代码示例。如果您正苦于以下问题:TypeScript daysFromNow函数的具体用法?TypeScript daysFromNow怎么用?TypeScript daysFromNow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了daysFromNow函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: context
context('with the JavaScript-disabled API', () => {
const validFormData = { addDate: 'Add', hasUnavailableDates: true, newDate: daysFromNow(1) }
const invalidFormDataWithYes = {
noJS: true,
addDate: 'Add',
hasUnavailableDates: true,
newDate: { year: 2000, month: 2, day: 30 }
}
const invalidFormDataWithNo = {
noJS: true,
hasUnavailableDates: false,
unavailableDates: [daysFromNow(1)]
}
context('when form is valid', () => {
it('should return 500 and render error page when cannot save DQ draft', async () => {
draftStoreServiceMock.resolveFind('directionsQuestionnaire')
draftStoreServiceMock.resolveFind('response')
draftStoreServiceMock.rejectSave()
claimStoreServiceMock.resolveRetrieveClaimByExternalId(claimWithDQ)
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validFormData)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should return to the same page', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(claimWithDQ)
draftStoreServiceMock.resolveFind('directionsQuestionnaire')
draftStoreServiceMock.resolveFind('response')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(validFormData)
.expect(res => expect(res).to.be.successful.withText('Select the dates you can’t go to a hearing'))
})
})
context('when form is invalid', () => {
[invalidFormDataWithNo, invalidFormDataWithYes].forEach(invalidFormData => {
it(`should render page when everything is fine and has dates ${invalidFormData.hasUnavailableDates ? '' : 'not '}selected`, async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId(claimWithDQ)
draftStoreServiceMock.resolveFind('directionsQuestionnaire')
draftStoreServiceMock.resolveFind('response')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send(invalidFormData)
.expect(res => expect(res).to.be.successful.withText('Select the dates you can’t go to a hearing', 'div class="error-summary"'))
})
})
})
})
示例2: it
it('Should be marked complete when affirmed having unavailable dates and dates given', () => {
const availability: Availability = new Availability(true, [daysFromNow(2)])
expect(availability.isCompleted()).to.be.true
})
示例3: createClaim
import { MadeBy } from 'offer/form/models/madeBy'
import { LocalDate } from 'forms/models/localDate'
import { daysFromNow } from 'test/localDateUtils'
const claimWithDQ = {
...claimStoreServiceMock.sampleClaimObj,
...{ features: ['directionsQuestionnaire'] }
}
const externalId = claimStoreServiceMock.sampleClaimObj.externalId
const claim = createClaim(PartyType.INDIVIDUAL, PartyType.ORGANISATION, MadeBy.CLAIMANT)
const cookieName: string = config.get<string>('session.cookieName')
const hearingDatesPath = Paths.hearingDatesPage.evaluateUri({ externalId: externalId })
const unavailableDates: LocalDate[] = [
daysFromNow(1),
daysFromNow(10),
daysFromNow(100)
]
function checkAccessGuard (app: any, method: string, path: string) {
it('should redirect to dashboard page when DQ is not enabled for claim', async () => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
await request(app)[method](path)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect.toLocation(DashboardPaths.dashboardPage.uri))
})
}
describe('Directions Questionnaire - hearing dates picker widget', () => {