本文整理匯總了TypeScript中forms/validation/validators/notInFuture.DateNotInFutureConstraint類的典型用法代碼示例。如果您正苦於以下問題:TypeScript DateNotInFutureConstraint類的具體用法?TypeScript DateNotInFutureConstraint怎麽用?TypeScript DateNotInFutureConstraint使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了DateNotInFutureConstraint類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: describe
describe('DateNotInFutureConstraint', () => {
const constraint: DateNotInFutureConstraint = new DateNotInFutureConstraint()
describe('validate', () => {
describe('should return true when ', () => {
it('given a date is undefined', () => {
expect(constraint.validate(undefined)).to.equal(true)
})
it('given a valid date in the past', () => {
expect(constraint.validate(new LocalDate(2000, 1, 1))).to.equal(true)
})
it('given an empty values', () => {
expect(constraint.validate(new LocalDate())).to.equal(true)
expect(constraint.validate(new LocalDate(undefined, undefined, undefined))).to.equal(true)
})
it('given today date', () => {
let now = moment()
expect(constraint.validate(new LocalDate(now.year(), now.month() + 1, now.date()))).to.equal(true)
})
})
describe('should return false when ', () => {
it('given an invalid structure', () => {
expect(constraint.validate({ a: 1, b: 1, c: 2000 })).to.equal(false)
})
it('given a valid date in the future', () => {
let inFuture = moment().add(10, 'years')
expect(constraint.validate(new LocalDate(inFuture.year(), 1, 1))).to.equal(false)
})
})
})
})
示例2: it
it('given a valid date in the future', () => {
let inFuture = moment().add(10, 'years')
expect(constraint.validate(new LocalDate(inFuture.year(), 1, 1))).to.equal(false)
})