validator/types/object.test.js
2020-06-03 15:49:04 +00:00

20 lines
459 B
JavaScript

/* eslint-disable no-undef */
const TypeObject = require('./object.js')
describe('test validate type schema object', () => {
function throwFunc (val) {
return () => {
if (val) throw new Error(val)
}
}
it('test object type with required', async () => {
const obj = new TypeObject().required()
obj.validate({})
expect(throwFunc(obj.validate(undefined))).toThrow()
expect(throwFunc(obj.validate(false))).toThrow()
})
})