File: test.js

package info (click to toggle)
node-p-is-promise 3.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 124 kB
  • sloc: makefile: 2
file content (38 lines) | stat: -rw-r--r-- 790 bytes parent folder | download
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
37
38
const test = require('tape');
const Bluebird = require('bluebird');
const isPromise = require('.');

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));
	t.end();
});

test('function', t => {
	const fixture = () => {};
	fixture.then = () => {};
	fixture.catch = () => {};
	t.true(isPromise(fixture));
	t.end();
});