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.
34 lines
745 B
34 lines
745 B
7 years ago
|
import test from 'ava';
|
||
6 years ago
|
import ow from '../source';
|
||
7 years ago
|
|
||
|
test('nullOrUndefined', t => {
|
||
6 years ago
|
// tslint:disable-next-line no-null-keyword
|
||
7 years ago
|
const x = null;
|
||
|
const y = undefined;
|
||
|
|
||
6 years ago
|
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`');
|
||
7 years ago
|
});
|