Skip to content

Commit 66eac00

Browse files
committed
WIP
1 parent a0c52b0 commit 66eac00

3 files changed

+13
-3
lines changed

lib/addAdditionalPromiseMethods.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const Context = require('./Context');
22

3-
function addAdditionalPromiseMethods(promise, expect, subject) {
3+
function addAdditionalPromiseMethods(promise, expect, subject, args) {
44
promise.and = function (...args) {
55
function executeAnd() {
66
if (expect.findTypeOf(args[0]).is('expect.it')) {
@@ -32,6 +32,11 @@ function addAdditionalPromiseMethods(promise, expect, subject) {
3232
subject
3333
);
3434
} else {
35+
return expect.execute(
36+
shiftedSubject,
37+
methodName.replace(/[A-Z]/g, ($0) => ` ${$0.toLowerCase()}`),
38+
...args
39+
);
3540
return camelCaseMethods[methodName](shiftedSubject)(...args);
3641
}
3742
}

lib/createTopLevelExpect.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,12 @@ expectPrototype._expect = function (context, args, forwardedFlags) {
15531553
} else {
15541554
result = makePromise.resolve(result);
15551555
}
1556-
return addAdditionalPromiseMethods(result, this, subject);
1556+
return addAdditionalPromiseMethods(
1557+
result,
1558+
this,
1559+
subject,
1560+
Array.prototype.slice.call(args, 0, 2)
1561+
);
15571562
} catch (e) {
15581563
if (e && e._isUnexpected) {
15591564
let newError = e;

test/camelCaseSyntax.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ describe('camel case syntax', () => {
112112
expect([1, 2, 3]).whenPassedAsParametersTo(Math.max).toEqual(3);
113113
});
114114

115-
it('should fail', () => {
115+
it.only('should fail', () => {
116116
expect(() =>
117117
expect([1, 2, 3]).whenPassedAsParametersTo(Math.max).toEqual(2)
118118
).toThrow(

0 commit comments

Comments
 (0)