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.
28 lines
651 B
28 lines
651 B
7 years ago
|
import test from 'ava';
|
||
6 years ago
|
import ow from '../source';
|
||
7 years ago
|
|
||
|
test('promise', t => {
|
||
6 years ago
|
t.notThrows(() => {
|
||
|
ow(Promise.resolve(), ow.promise);
|
||
|
});
|
||
|
|
||
|
t.notThrows(() => {
|
||
|
const promise = new Promise<void>(resolve => {
|
||
|
resolve();
|
||
|
});
|
||
|
ow(promise, ow.promise);
|
||
|
});
|
||
|
|
||
|
t.throws(() => {
|
||
|
ow('foo' as any, ow.promise);
|
||
|
}, 'Expected argument to be of type `Promise` but received type `string`');
|
||
|
|
||
|
t.throws(() => {
|
||
|
ow('foo' as any, 'foo', ow.promise);
|
||
|
}, 'Expected `foo` to be of type `Promise` but received type `string`');
|
||
|
|
||
|
t.throws(() => {
|
||
|
ow(12 as any, ow.promise);
|
||
|
}, 'Expected argument to be of type `Promise` but received type `number`');
|
||
7 years ago
|
});
|