1 | function addAdditionalPromiseMethods(promise, expect, subject) {
|
2 | promise.and = function() {
|
3 | var args = [], len = arguments.length;
|
4 | while ( len-- ) args[ len ] = arguments[ len ];
|
5 |
|
6 | function executeAnd() {
|
7 | if (expect.findTypeOf(args[0]).is('expect.it')) {
|
8 | return addAdditionalPromiseMethods(args[0](subject), expect, subject);
|
9 | } else {
|
10 | return expect.apply(void 0, [ subject ].concat( args ));
|
11 | }
|
12 | }
|
13 |
|
14 | if (this.isFulfilled()) {
|
15 | return executeAnd();
|
16 | } else {
|
17 | return addAdditionalPromiseMethods(
|
18 | this.then(executeAnd),
|
19 | expect,
|
20 | subject
|
21 | );
|
22 | }
|
23 | };
|
24 |
|
25 | return promise;
|
26 | }
|
27 |
|
28 | module.exports = addAdditionalPromiseMethods;
|