validator/validator.test.js

27 lines
524 B
JavaScript
Raw Normal View History

2020-06-03 15:49:04 +00:00
/* eslint-disable no-undef */
const validator = require('./index.js')
describe('test validator validate', () => {
test('validate test 1', () => {
const data = {
field: 'string'
}
const schema = {
field: validator.string().required()
}
validator.validate(data, schema)
})
test('validate test 2', () => {
const data = {
wrong: 1
}
const schema = {
wrong: validator.string().required()
}
expect(() => validator.validate(data, schema)).toThrow()
})
})