
HOW TO USE ?
npm install --save easily-expect
const { checkType, checkMatch, checkEqual, checkObject, init } = require('easily-expect')
describe (...)
init({
test1: {
test2: /^\d*$/
},
test3: /^[a-z]{1,10}$/,
test4: [/^[a-z]{1,10}$/, /^\d*$/, {
test5: /^\d*$/
}]
})
it (...)
checkType('string', '123', '0')
it (...)
checkMatch(/\d/, '1', '123', '1234')
it (...)
checkEqual('abc', 'abc', 'aaa') // aaa is false
it (...)
checkObject({ test1: { test2: '123123123' } })
it(...)
checkObject({ test4: ['aaa', '123', { test5: '123' }, 'aaa', '123', { test5: '123' }] })
it(...)
checkArray([/^\d*$/, /[a-z]{1,10}/, { test1: /^\d*$/ }], ['123', 'a', { test1: '123' }, '123','a', { test1: '123' }], ['123', 'a', { test1: '123' }])
Example