-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtest.js
36 lines (34 loc) · 763 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import test from 'ava';
import Bluebird from 'bluebird';
import isPromise from './index.js';
test('main', t => {
t.true(isPromise(Promise.resolve()));
t.true(isPromise(global.Promise.resolve()));
t.true(isPromise(Bluebird.resolve()));
t.true(isPromise({
then: () => {},
catch: () => {}
}));
t.false(isPromise({
then: () => {}
}));
t.false(isPromise({
catch: () => {}
}));
t.false(isPromise({
then: '🦄'
}));
t.false(isPromise({}));
t.false(isPromise([]));
t.false(isPromise(undefined));
t.false(isPromise(null));
t.false(isPromise('🦄'));
t.false(isPromise(0));
t.false(isPromise(true));
});
test('function', t => {
const fixture = () => {};
fixture.then = () => {};
fixture.catch = () => {};
t.true(isPromise(fixture));
});