mirror of https://github.com/lukechilds/ow.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
745 B
33 lines
745 B
import test from 'ava';
|
|
import ow from '../source';
|
|
|
|
test('nullOrUndefined', t => {
|
|
// tslint:disable-next-line no-null-keyword
|
|
const x = null;
|
|
const y = undefined;
|
|
|
|
t.notThrows(() => {
|
|
// tslint:disable-next-line no-null-keyword
|
|
ow(null, ow.nullOrUndefined);
|
|
});
|
|
|
|
t.notThrows(() => {
|
|
ow(undefined, ow.nullOrUndefined);
|
|
});
|
|
|
|
t.notThrows(() => {
|
|
ow(x, ow.nullOrUndefined);
|
|
});
|
|
|
|
t.notThrows(() => {
|
|
ow(y, ow.nullOrUndefined);
|
|
});
|
|
|
|
t.throws(() => {
|
|
ow('foo' as any, ow.nullOrUndefined);
|
|
}, 'Expected argument to be of type `nullOrUndefined` but received type `string`');
|
|
|
|
t.throws(() => {
|
|
ow('foo' as any, 'foo', ow.nullOrUndefined);
|
|
}, 'Expected `foo` to be of type `nullOrUndefined` but received type `string`');
|
|
});
|
|
|