From c37e3519cad5e2777017051906ab1ecc591df7c8 Mon Sep 17 00:00:00 2001 From: Chris P Date: Sat, 30 Mar 2019 17:05:47 -0400 Subject: [PATCH] :grimacing: can't figure out which test is causing tests to fail in py2 --- package.json | 2 +- src/actions/index.js | 73 ++++++++++++++++++++++++++++---------------- 2 files changed, 47 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index adc0555..493acb3 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "format": "prettier --config .prettierrc --write src/**/*.js src/**/*.react.js", "format:test": "prettier --config .prettierrc src/**/*.js src/**/*.react.js --list-different", "test": "npm run lint", - "test:py": "python -m unittest tests.test_clientside tests.test_render tests.test_race_conditions" + "test:py": "python -m unittest -v tests.test_clientside tests.test_render tests.test_race_conditions" }, "author": "chriddyp", "license": "MIT", diff --git a/src/actions/index.js b/src/actions/index.js index c9ba75a..d9f611d 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -531,36 +531,55 @@ function updateOutput( return; } - const [outputId, outputProp] = payload.output.split('.'); - const updatedProps = { - [outputProp]: returnValue, - }; + function updateOutput(outputIdAndProp, outputValue) { + const [outputId, outputProp] = outputIdAndProp.split('.'); + const updatedProps = { + [outputProp]: outputValue, + }; - /* - * Update the request queue by treating a successful clientside - * like a succesful serverside response (200 status code) - */ - updateRequestQueue(false, STATUS.OK); + /* + * Update the request queue by treating a successful clientside + * like a succesful serverside response (200 status code) + */ + updateRequestQueue(false, STATUS.OK); - // Update the layout with the new result - dispatch( - updateProps({ - itempath: getState().paths[outputId], - props: updatedProps, - source: 'response', - }) - ); + // Update the layout with the new result + dispatch( + updateProps({ + itempath: getState().paths[outputId], + props: updatedProps, + source: 'response', + }) + ); - /* - * This output could itself be a serverside or clientside input - * to another function - */ - dispatch( - notifyObservers({ - id: outputId, - props: updatedProps, - }) - ); + /* + * This output could itself be a serverside or clientside input + * to another function + */ + dispatch( + notifyObservers({ + id: outputId, + props: updatedProps, + }) + ); + } + + if (payload.output.startsWith('..')) { + /* + * If this update is for multiple outputs, then it has + * starting & trailing `..` and each propId pair is separated + * by `...`, e.g. + * "..output-1.value...output-2.value...output-3.value...output-4.value.." + */ + const outputPropIds = payload.output.split('...').map( + o => o.replace('..', '') // trim starting & trailing .. + ); + for(let i=0; i < outputPropIds.length; i++) { + updateOutput(outputPropIds[i], returnValue[i]); + } + } else { + updateOutput(payload.output, returnValue); + } /* * Note that unlike serverside updates, we're not handling