-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.js
31 lines (27 loc) · 1.09 KB
/
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
"use strict";
const assert = require('assert');
const on = require('./');
describe('Await Handler', function() {
it('should return promise', function() {
let result = on(Promise.resolve('success'));
assert.ok(result instanceof Promise);
});
describe('Signature', function() {
it('should receive both properties on success', async function() {
let [err, res] = await on(Promise.resolve('success'));
assert.ok(err === null);
assert.ok(res === 'success');
});
it('should receive error and undefined', async function() {
let [err, res] = await on(Promise.reject('error'));
assert.ok(err === 'error');
assert.ok(res === undefined);
});
it('should include additional properties on error object', async function() {
let [err, res] = await on(Promise.reject(new Error('Test')), { prop: 'test' });
assert.ok(err instanceof Error);
assert.ok(err.prop === 'test');
assert.ok(res === undefined);
});
});
});