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.
 
 

28 lines
655 B

import test from 'ava';
import ow from '..';
test('null', t => {
// tslint:disable-next-line no-null-keyword
const x = null;
t.notThrows(() => {
// tslint:disable-next-line no-null-keyword
ow(null, ow.null);
});
t.notThrows(() => {
ow(x, ow.null);
});
t.throws(() => {
ow(undefined as any, ow.null);
}, 'Expected argument to be of type `null` but received type `undefined`');
t.throws(() => {
ow(undefined as any, 'foo', ow.null);
}, 'Expected `foo` to be of type `null` but received type `undefined`');
t.throws(() => {
ow('foo' as any, ow.null);
}, 'Expected argument to be of type `null` but received type `string`');
});