Skip to content

Commit 37bfce5

Browse files
committed
Specs.
1 parent 2a05240 commit 37bfce5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,30 @@ describe('Context', () => {
135135
initialContext
136136
));
137137
});
138+
139+
describe('Errors', () => {
140+
const runWithinPromise = () => new Promise((resolve, reject) => {
141+
const error = new Error('Promise failed');
142+
Context.run(() => reject(error));
143+
});
144+
145+
it('Bubbles up error', () => {
146+
const errorFn = () => {
147+
throw new Error('That went badly.');
148+
}
149+
expect(() => Context.run(errorFn)).toThrow();
150+
});
151+
152+
it('Rejects promises', async (done) => {
153+
try {
154+
await runWithinPromise();
155+
expect(true).toBeFlasy();
156+
} catch (e) {
157+
expect(e).toBeInstanceOf(Error)
158+
done();
159+
}
160+
});
161+
});
138162
});
139163
});
140164

0 commit comments

Comments
 (0)