fix: support sequential CallExpressions in member chains (#2990)

* fix: support sequential CallExpressions in member chains

fixes #2832

* test: add additional test cases for sequential CallExpressions

* test: regenerate method-chain snapshot
master
Chris Voll 2017-10-07 21:12:17 -04:00 committed by Lucas Azzola
parent 6c8cde9672
commit 4a6b61aaf3
3 changed files with 70 additions and 1 deletions

View File

@ -3580,7 +3580,10 @@ function printMemberChain(path, options, print) {
function rec(path) {
const node = path.getValue();
if (node.type === "CallExpression" && isMemberish(node.callee)) {
if (
node.type === "CallExpression" &&
(isMemberish(node.callee) || node.callee.type === "CallExpression")
) {
printedNodes.unshift({
node: node,
printed: comments.printComments(

View File

@ -621,6 +621,22 @@ if (testConfig.ENABLE_ONLINE_TESTS === "true") {
});
});
}
wrapper.find('SomewhatLongNodeName').prop('longPropFunctionName')().then(function() {
doSomething();
});
wrapper.find('SomewhatLongNodeName').prop('longPropFunctionName')('argument').then(function() {
doSomething();
});
wrapper.find('SomewhatLongNodeName').prop('longPropFunctionName', 'second argument that pushes this group past 80 characters')('argument').then(function() {
doSomething();
});
wrapper.find('SomewhatLongNodeName').prop('longPropFunctionName')('argument', 'second argument that pushes this group past 80 characters').then(function() {
doSomething();
});
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (testConfig.ENABLE_ONLINE_TESTS === "true") {
describe("POST /users/me/pet", function() {
@ -641,6 +657,40 @@ if (testConfig.ENABLE_ONLINE_TESTS === "true") {
});
}
wrapper
.find("SomewhatLongNodeName")
.prop("longPropFunctionName")()
.then(function() {
doSomething();
});
wrapper
.find("SomewhatLongNodeName")
.prop("longPropFunctionName")("argument")
.then(function() {
doSomething();
});
wrapper
.find("SomewhatLongNodeName")
.prop(
"longPropFunctionName",
"second argument that pushes this group past 80 characters"
)("argument")
.then(function() {
doSomething();
});
wrapper
.find("SomewhatLongNodeName")
.prop("longPropFunctionName")(
"argument",
"second argument that pushes this group past 80 characters"
)
.then(function() {
doSomething();
});
`;
exports[`square_0.js 1`] = `

View File

@ -14,3 +14,19 @@ if (testConfig.ENABLE_ONLINE_TESTS === "true") {
});
});
}
wrapper.find('SomewhatLongNodeName').prop('longPropFunctionName')().then(function() {
doSomething();
});
wrapper.find('SomewhatLongNodeName').prop('longPropFunctionName')('argument').then(function() {
doSomething();
});
wrapper.find('SomewhatLongNodeName').prop('longPropFunctionName', 'second argument that pushes this group past 80 characters')('argument').then(function() {
doSomething();
});
wrapper.find('SomewhatLongNodeName').prop('longPropFunctionName')('argument', 'second argument that pushes this group past 80 characters').then(function() {
doSomething();
});