UNPKG

598 BJavaScriptView Raw
1function addAdditionalPromiseMethods(promise, expect, subject) {
2 promise.and = function(...args) {
3 function executeAnd() {
4 if (expect.findTypeOf(args[0]).is('expect.it')) {
5 return addAdditionalPromiseMethods(args[0](subject), expect, subject);
6 } else {
7 return expect(subject, ...args);
8 }
9 }
10
11 if (this.isFulfilled()) {
12 return executeAnd();
13 } else {
14 return addAdditionalPromiseMethods(
15 this.then(executeAnd),
16 expect,
17 subject
18 );
19 }
20 };
21
22 return promise;
23}
24
25module.exports = addAdditionalPromiseMethods;