|
|
@ -14,7 +14,7 @@ const expectPromise = (pred, statement, options = {}) => a => (...b) => { |
|
|
|
) |
|
|
|
) |
|
|
|
.catch(e => |
|
|
|
(options.shouldNotCatch) |
|
|
|
options.shouldNotCatch |
|
|
|
? _assertPromise( |
|
|
|
pred(a, ...b), |
|
|
|
statement(e, ...b) |
|
|
@ -29,43 +29,43 @@ const expectPromise = (pred, statement, options = {}) => a => (...b) => { |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
const expect = a => { |
|
|
|
const expect = thing => { |
|
|
|
|
|
|
|
return ({ |
|
|
|
done : () => Promise.resolve(), |
|
|
|
equal : expectPromise( |
|
|
|
(a, b) => a === b, |
|
|
|
(a, b) => `${a} is not equal to ${b}`, |
|
|
|
)(a), |
|
|
|
)(thing), |
|
|
|
deepEqual : expectPromise( |
|
|
|
(a, b) => isEq(a, b), |
|
|
|
(a, b) => `${stringify(a)} is not deeply equal to ${stringify(b)}`, |
|
|
|
)(a), |
|
|
|
)(thing), |
|
|
|
isTrue : expectPromise( |
|
|
|
a => a === true, |
|
|
|
a => `${a} is not true`, |
|
|
|
)(a), |
|
|
|
)(thing), |
|
|
|
hasProp : expectPromise( |
|
|
|
(a, b) => b in a, |
|
|
|
(a, b) => `Property ${b} does not exist in ${stringify(a)}`, |
|
|
|
)(a), |
|
|
|
)(thing), |
|
|
|
hasPair : expectPromise( |
|
|
|
(a, b, c) => a[b] === c, |
|
|
|
(a, b, c) => `Pair <${b}, ${c}> does not exist in ${stringify(a)}`, |
|
|
|
)(a), |
|
|
|
)(thing), |
|
|
|
resolvesTo : expectPromise( |
|
|
|
(a, b) => (a && typeof a.then === 'function') |
|
|
|
? a.then(x => x === b ? Promise.resolve() : Promise.reject()) |
|
|
|
: Promise.reject(`${a} was not a Promise`), |
|
|
|
(a, b) => `${a} does not resolve to ${b}`, |
|
|
|
)(a), |
|
|
|
)(thing), |
|
|
|
isPromise : expectPromise( |
|
|
|
a => (a && typeof a.then === 'function') |
|
|
|
? a.then(() => Promise.resolve()).catch(() => Promise.resolve()) |
|
|
|
: Promise.reject(), |
|
|
|
a => `${a} is not a Promise`, |
|
|
|
{ shouldNotCatch: true }, |
|
|
|
)(a), |
|
|
|
)(thing), |
|
|
|
}); |
|
|
|
|
|
|
|
}; |
|
|
|