Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed May 28, 2022
1 parent a0c52b0 commit 7b0eb42
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/addAdditionalPromiseMethods.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Context = require('./Context');

function addAdditionalPromiseMethods(promise, expect, subject) {
function addAdditionalPromiseMethods(promise, expect, subject, args) {
promise.and = function (...args) {
function executeAnd() {
if (expect.findTypeOf(args[0]).is('expect.it')) {
Expand Down Expand Up @@ -32,6 +32,11 @@ function addAdditionalPromiseMethods(promise, expect, subject) {
subject
);
} else {
return expect.execute(
shiftedSubject,
methodName.replace(/[A-Z]/g, ($0) => ` ${$0.toLowerCase()}`),
...args
);
return camelCaseMethods[methodName](shiftedSubject)(...args);
}
}
Expand Down
7 changes: 6 additions & 1 deletion lib/createTopLevelExpect.js
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,12 @@ expectPrototype._expect = function (context, args, forwardedFlags) {
} else {
result = makePromise.resolve(result);
}
return addAdditionalPromiseMethods(result, this, subject);
return addAdditionalPromiseMethods(
result,
this,
subject,
Array.prototype.slice.call(args, 0, 2)
);
} catch (e) {
if (e && e._isUnexpected) {
let newError = e;
Expand Down

0 comments on commit 7b0eb42

Please sign in to comment.