Skip to content

Commit c077dbe

Browse files
committed
chore(test): do better testing of promise getters
1 parent fb3630a commit c077dbe

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/loopback.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { test } from 'tape-promise/tape';
22
import { E, harden, makeCapTP } from '../lib/captp';
33

4-
// TODO: remove .only when you have this test working
54
test('try loopback captp', async t => {
65
try {
76
const debug = false;
@@ -15,6 +14,11 @@ test('try loopback captp', async t => {
1514
rightDispatch(obj);
1615
},
1716
);
17+
const pr = {};
18+
pr.p = new Promise((resolve, reject) => {
19+
pr.res = resolve;
20+
pr.rej = reject;
21+
});
1822
({ dispatch: rightDispatch } = makeCapTP(
1923
'right',
2024
obj => {
@@ -24,6 +28,7 @@ test('try loopback captp', async t => {
2428
leftDispatch(obj);
2529
},
2630
harden({
31+
promise: pr.p,
2732
encourager: {
2833
encourage(name) {
2934
const bang = new Promise(resolve => {
@@ -48,6 +53,9 @@ test('try loopback captp', async t => {
4853
).P;
4954
t.equal(comment, 'good work, buddy', 'got encouragement');
5055
t.equal(await E(bang).trigger(), 'buddy BANG!', 'called on promise');
56+
pr.res('resolution');
57+
t.equal(await E.G(rightRef).promise, 'resolution', 'got resolution');
58+
t.equal(await E.C(rightRef).G.promise.P, 'resolution', 'chained resolution');
5159
} catch (e) {
5260
t.isNot(e, e, 'unexpected exception');
5361
} finally {

0 commit comments

Comments
 (0)