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

27 lines
524 B
JavaScript

/* 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()
})
})