-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
56 lines (44 loc) · 957 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const test = require('tape')
const InvertedPromise = require('.')
test('resolve', function (assert) {
assert.plan(1)
const p = new InvertedPromise()
p.then(value => {
assert.ok(value === 'ok')
}).catch(err => {
assert.error(err)
})
p.resolve('ok')
})
test('resolve', function (assert) {
assert.plan(1)
const p = new InvertedPromise()
p.then(value => {
assert.error(new Error())
}).catch(err => {
assert.ok(err === 'ok')
})
p.reject('ok')
})
test('resolve twice', function (assert) {
assert.plan(1)
const p = new InvertedPromise()
p.then(value => {
assert.ok(value === 'ok')
}).catch(err => {
assert.error(err)
})
p.resolve('ok')
p.resolve('ok2')
})
test('resolve then reject', function (assert) {
assert.plan(1)
const p = new InvertedPromise()
p.then(value => {
assert.ok(value === 'ok')
}).catch(err => {
assert.error(err)
})
p.resolve('ok')
p.reject('ok')
})