27 lines
524 B
JavaScript
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()
|
||
|
})
|
||
|
})
|