20 lines
459 B
JavaScript
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()
|
||
|
})
|
||
|
})
|