first commit

This commit is contained in:
2020-02-02 15:24:30 +07:00
commit 61dfa00b20
2410 changed files with 152621 additions and 0 deletions

83
node_modules/ow-lite/test/number.js generated vendored Normal file
View File

@@ -0,0 +1,83 @@
import test from 'ava'
import m from '..'
test('number', t => {
t.notThrows(() => m(1, m.number))
t.notThrows(() => m(1, m.number))
t.throws(() => m('12', m.number))
t.throws(() => m('12', m.number, 'foo'))
})
test('number.gt', t => {
t.notThrows(() => m(10, m.number.gt(5)))
t.notThrows(() => m(10, m.number.gt(9)))
t.throws(() => m(10, m.number.gt(10)))
t.throws(() => m(10, m.number.gt(11)))
t.throws(() => m(10, m.number.gt(20)))
})
test('number.gte', t => {
t.notThrows(() => m(10, m.number.gte(5)))
t.notThrows(() => m(10, m.number.gte(10)))
t.throws(() => m(10, m.number.gte(11)))
t.throws(() => m(10, m.number.gte(20)))
})
test('number.lt', t => {
t.notThrows(() => m(10, m.number.lt(20)))
t.notThrows(() => m(10, m.number.lt(11)))
t.throws(() => m(10, m.number.lt(10)))
t.throws(() => m(10, m.number.lt(9)))
t.throws(() => m(10, m.number.lt(0)))
})
test('number.lte', t => {
t.notThrows(() => m(10, m.number.lte(20)))
t.notThrows(() => m(10, m.number.lte(10)))
t.throws(() => m(10, m.number.lte(9)))
t.throws(() => m(10, m.number.lte(0)))
})
test('number.eq', t => {
t.notThrows(() => m(10, m.number.eq(10)))
t.throws(() => m(10, m.number.eq(5)))
})
test('number.integer', t => {
t.notThrows(() => m(10, m.number.integer))
t.throws(() => m(10.1, m.number.integer))
})
test('number.positive', t => {
t.notThrows(() => m(1, m.number.positive))
t.throws(() => m(-1, m.number.positive))
})
test('number.negative', t => {
t.notThrows(() => m(-1, m.number.negative))
t.throws(() => m(1, m.number.negative))
})
/*
test('number.finite', t => {
t.notThrows(() => m(10, m.number.finite))
t.throws(() => m(Infinity, m.number.finite), 'Expected number to be finite, got Infinity')
})
test('number.infinite', t => {
t.notThrows(() => m(Infinity, m.number.infinite))
t.throws(() => m(10, m.number.infinite), 'Expected number to be infinite, got 10')
})
test('number.inRange', t => {
t.notThrows(() => m(10, m.number.inRange(0, 20)))
t.notThrows(() => m(10, m.number.inRange(10, 20)))
t.notThrows(() => m(10, m.number.inRange(0, 10)))
t.notThrows(() => m(10, m.number.inRange(0, 10)))
t.notThrows(() => m(10, m.number.inRange(0, 10)))
t.throws(() => m(10, m.number.inRange(0, 9)), 'Expected number to be in range [0..9], got 10')
t.throws(() => m(10, m.number.inRange(0, 9), 'foo'), 'Expected number `foo` to be in range [0..9], got 10')
t.throws(() => m(10, m.number.inRange(0, 9), 'foo'), 'Expected number `foo` to be in range [0..9], got 10')
t.throws(() => m(10, m.number.inRange(11, 20)), 'Expected number to be in range [11..20], got 10')
})
*/

90
node_modules/ow-lite/test/object.js generated vendored Normal file
View File

@@ -0,0 +1,90 @@
import test from 'ava'
import m from '..'
class Unicorn {}
test('object', t => {
t.notThrows(() => m({}, m.object))
t.notThrows(() => m({}, m.object))
t.notThrows(() => m(new Error('foo'), m.object))
t.throws(() => m('foo', m.object))
t.throws(() => m('foo', m.object))
t.throws(() => m(1, m.object))
})
test('object.plain', t => {
t.notThrows(() => m({}, m.object.plain))
t.notThrows(() => m({}, m.object.plain))
t.notThrows(() => m({}, m.object.plain))
t.throws(() => m(new Error('foo'), m.object.plain))
t.throws(() => m(new Error('foo'), m.object.plain))
t.throws(() => m(new Error('foo'), m.object.plain))
})
test('object.empty', t => {
t.notThrows(() => m({}, m.object.empty))
t.throws(() => m({unicorn: '🦄'}, m.object.empty))
})
test('object.nonEmpty', t => {
t.notThrows(() => m({unicorn: '🦄'}, m.object.nonEmpty))
t.throws(() => m({}, m.object.nonEmpty))
})
test('object.instanceOf', t => {
t.notThrows(() => m(new Error('🦄'), m.object.instanceOf(Error)))
t.notThrows(() => m(new Unicorn(), m.object.instanceOf(Unicorn)))
t.throws(() => m(new Unicorn(), m.object.instanceOf(Error)))
t.throws(() => m(new Unicorn(), m.object.instanceOf(Error)))
t.throws(() => m(new Error('🦄'), m.object.instanceOf(Unicorn)))
t.throws(() => m({unicorn: '🦄'}, m.object.instanceOf(Unicorn)))
})
/*
test('object.valuesOfType', t => {
t.notThrows(() => m({unicorn: '🦄'}, m.object.valuesOfType(m.string)))
t.notThrows(() => m({unicorn: '🦄', rainbow: '🌈'}, m.object.valuesOfType(m.string)))
t.notThrows(() => m({unicorn: 1, rainbow: 2}, m.object.valuesOfType(m.number)))
t.notThrows(() => m({unicorn: 1, rainbow: 2}, m.object.valuesOfType(m.number)))
t.throws(() => m({unicorn: '🦄', rainbow: 2}, m.object.valuesOfType(m.string)), '(object) Expected argument to be of type `string` but received type `number`')
t.throws(() => m({unicorn: '🦄', rainbow: 2}, m.object.valuesOfType(m.string)), '(object `foo`) Expected argument to be of type `string` but received type `number`')
t.throws(() => m({unicorn: '🦄', rainbow: 2}, m.object.valuesOfType(m.string)), '(object `foo`) Expected `bar` to be of type `string` but received type `number`')
t.throws(() => m({unicorn: 'a', rainbow: 'b'}, m.object.valuesOfType(m.string.minLength(2))), '(object) Expected string to have a minimum length of `2`, got `a`')
})
test('object.valuesOfTypeDeep', t => {
t.notThrows(() => m({unicorn: '🦄'}, m.object.deepValuesOfType(m.string)))
t.notThrows(() => m({unicorn: '🦄', rainbow: '🌈'}, m.object.deepValuesOfType(m.string)))
t.notThrows(() => m({unicorn: {key: '🦄', value: '🌈'}}, m.object.deepValuesOfType(m.string)))
t.notThrows(() => m({a: {b: {c: {d: 1}, e: 2}, f: 3}}, m.object.deepValuesOfType(m.number)))
t.notThrows(() => m({a: {b: {c: {d: 1}, e: 2}, f: 3}}, m.object.deepValuesOfType(m.number)))
t.throws(() => m({unicorn: {key: '🦄', value: 1}}, m.object.deepValuesOfType(m.string)), '(object) Expected argument to be of type `string` but received type `number`')
t.throws(() => m({unicorn: {key: '🦄', value: 1}}, m.object.deepValuesOfType(m.string)), '(object `foo`) Expected argument to be of type `string` but received type `number`')
t.throws(() => m({unicorn: {key: '🦄', value: 1}}, m.object.deepValuesOfType(m.string)), '(object `foo`) Expected `bar` to be of type `string` but received type `number`')
t.throws(() => m({a: {b: {c: {d: 1}, e: '2'}, f: 3}}, m.object.deepValuesOfType(m.number)), '(object) Expected argument to be of type `number` but received type `string`')
})
test('object.deepEqual', t => {
t.notThrows(() => m({unicorn: '🦄'}, m.object.deepEqual({unicorn: '🦄'})))
t.notThrows(() => m({unicorn: '🦄', rain: {bow: '🌈'}}, m.object.deepEqual({unicorn: '🦄', rain: {bow: '🌈'}})))
t.throws(() => m({unicorn: '🦄'}, m.object.deepEqual({rainbow: '🌈'})))
})
test('object.hasKeys', t => {
t.notThrows(() => m({unicorn: '🦄'}, m.object.hasKeys('unicorn')))
t.notThrows(() => m({unicorn: {value: '🦄'}}, m.object.hasKeys('unicorn')))
t.notThrows(() => m({unicorn: {value: '🦄'}}, m.object.hasKeys('unicorn.value')))
t.notThrows(() => m({unicorn: '🦄', rainbow: '🌈'}, m.object.hasKeys('unicorn', 'rainbow')))
t.throws(() => m({unicorn: '🦄'}, m.object.hasKeys('unicorn', 'rainbow')))
t.throws(() => m({unicorn: {value: '🦄'}}, m.object.hasKeys('unicorn.foo')))
})
test('object.hasAnyKeys', t => {
t.notThrows(() => m({unicorn: '🦄'}, m.object.hasAnyKeys('unicorn', 'rainbow', 'foo.bar')))
t.notThrows(() => m({unicorn: {value: '🦄'}}, m.object.hasAnyKeys('unicorn', 'rainbow')))
t.notThrows(() => m({unicorn: {value: '🦄'}}, m.object.hasAnyKeys('unicorn.value', 'rainbow')))
t.notThrows(() => m({unicorn: '🦄', rainbow: '🌈'}, m.object.hasAnyKeys('unicorn')))
t.throws(() => m({unicorn: '🦄'}, m.object.hasAnyKeys('foo')))
t.throws(() => m({unicorn: '🦄'}, m.object.hasAnyKeys('unicorn.value')))
})
*/

82
node_modules/ow-lite/test/string.js generated vendored Normal file
View File

@@ -0,0 +1,82 @@
import test from 'ava'
import m from '..'
test('string', t => {
t.notThrows(() => m('foo', m.string))
t.notThrows(() => m('foo', m.string))
t.throws(() => m(12, m.string))
t.throws(() => m(12, m.string))
})
test('string.length', t => {
t.notThrows(() => m('foo', m.string.length(3)))
t.notThrows(() => m('foobar', m.string.length(6)))
t.notThrows(() => m('bar', m.string.length(3)))
t.notThrows(() => m('bar', m.string.length(3)))
t.throws(() => m('foo', m.string.length(4)))
t.throws(() => m('foo', m.string.length(4)))
t.throws(() => m('foo', m.string.length(4)))
})
test('string.minLength', t => {
t.notThrows(() => m('foo', m.string.minLength(2)))
t.notThrows(() => m('foo', m.string.minLength(3)))
t.throws(() => m('foo', m.string.minLength(4)))
})
test('string.maxLength', t => {
t.notThrows(() => m('foo', m.string.maxLength(3)))
t.notThrows(() => m('foo', m.string.maxLength(5)))
t.throws(() => m('foo', m.string.maxLength(2)))
})
test('string.matches', t => {
t.notThrows(() => m('foo', m.string.matches(/^f.o$/)))
t.notThrows(() => m('Foo', m.string.matches(/^f.o$/i)))
t.throws(() => m('Foo', m.string.matches(/^f.o$/)))
t.throws(() => m('bar', m.string.matches(/^f.o$/i)))
})
test('string.startsWith', t => {
t.notThrows(() => m('foo', m.string.startsWith('fo')))
t.notThrows(() => m('foo', m.string.startsWith('f')))
t.throws(() => m('foo', m.string.startsWith('oo')))
t.throws(() => m('foo', m.string.startsWith('b')))
})
test('string.endsWith', t => {
t.notThrows(() => m('foo', m.string.endsWith('oo')))
t.notThrows(() => m('foo', m.string.endsWith('o')))
t.throws(() => m('foo', m.string.endsWith('fo')))
t.throws(() => m('foo', m.string.endsWith('ar')))
})
test('string.empty', t => {
t.notThrows(() => m('', m.string.empty))
t.throws(() => m('foo', m.string.empty))
})
test('string.nonEmpty', t => {
t.notThrows(() => m('foo', m.string.nonEmpty))
t.throws(() => m('', m.string.nonEmpty))
})
test('string.eq', t => {
t.notThrows(() => m('foo', m.string.eq('foo')))
t.throws(() => m('bar', m.string.eq('foo')))
})
/*
test('string.includes', t => {
t.notThrows(() => m('foo', m.string.includes('fo')))
t.throws(() => m('foo', m.string.includes('bar')))
})
test('string.oneOf', t => {
t.notThrows(() => m('foo', m.string.oneOf(['foo', 'bar'])))
t.throws(() => m('foo', m.string.oneOf(['unicorn', 'rainbow'])))
t.throws(() => m('foo', m.string.oneOf(['unicorn', 'rainbow'])))
t.throws(() => m('foo', m.string.oneOf(['a', 'b', 'c', 'd', 'e'])))
t.throws(() => m('foo', m.string.oneOf(['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'])))
})
*/