2020-06-03 15:49:04 +00:00
|
|
|
/* eslint-disable no-undef */
|
|
|
|
const TypeBoolean = require('./boolean.js')
|
|
|
|
|
|
|
|
describe('test validate schema type boolean', () => {
|
|
|
|
function throwFunc (val) {
|
|
|
|
return () => {
|
|
|
|
if (val) throw new Error(val)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
it('test type boolean required', async () => {
|
|
|
|
const bool = new TypeBoolean().required()
|
|
|
|
|
2020-06-10 13:32:50 +00:00
|
|
|
throwFunc(bool.validate(true))
|
2020-06-03 15:49:04 +00:00
|
|
|
|
|
|
|
expect(throwFunc(bool.validate(undefined))).toThrow()
|
|
|
|
expect(throwFunc(bool.validate({}))).toThrow()
|
|
|
|
})
|
|
|
|
})
|