From d90aec1a1d78c1c5642ffadb3bdc8f5b0df25a92 Mon Sep 17 00:00:00 2001 From: Brian Ng Date: Sun, 15 Oct 2017 17:09:57 -0500 Subject: [PATCH] Add test for nested ternary with arrow func (#3039) --- package.json | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 24 +++++++++++++++++++ tests/ternaries/nested.js | 3 +++ yarn.lock | 6 ++--- 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 tests/ternaries/nested.js diff --git a/package.json b/package.json index 08ac5d69..4cca0150 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ }, "dependencies": { "babel-code-frame": "7.0.0-alpha.12", - "babylon": "7.0.0-beta.23", + "babylon": "7.0.0-beta.28", "camelcase": "4.1.0", "chalk": "2.1.0", "cjk-regex": "1.0.1", diff --git a/tests/ternaries/__snapshots__/jsfmt.spec.js.snap b/tests/ternaries/__snapshots__/jsfmt.spec.js.snap index b688b489..beaed404 100644 --- a/tests/ternaries/__snapshots__/jsfmt.spec.js.snap +++ b/tests/ternaries/__snapshots__/jsfmt.spec.js.snap @@ -92,6 +92,30 @@ aaaaaaaaaaaaaaa `; +exports[`nested.js 1`] = ` +let icecream = what == "cone" + ? p => !!p ? \`here's your \${p} cone\` : \`just the empty cone for you\` + : p => \`here's your \${p} \${what}\`; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +let icecream = + what == "cone" + ? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`) + : p => \`here's your \${p} \${what}\`; + +`; + +exports[`nested.js 2`] = ` +let icecream = what == "cone" + ? p => !!p ? \`here's your \${p} cone\` : \`just the empty cone for you\` + : p => \`here's your \${p} \${what}\`; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +let icecream = + what == "cone" + ? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`) + : p => \`here's your \${p} \${what}\`; + +`; + exports[`parenthesis.js 1`] = ` debug ? this.state.isVisible ? "partially visible" : "hidden" : null; debug ? this.state.isVisible && somethingComplex ? "partially visible" : "hidden" : null; diff --git a/tests/ternaries/nested.js b/tests/ternaries/nested.js new file mode 100644 index 00000000..a00fda82 --- /dev/null +++ b/tests/ternaries/nested.js @@ -0,0 +1,3 @@ +let icecream = what == "cone" + ? p => !!p ? `here's your ${p} cone` : `just the empty cone for you` + : p => `here's your ${p} ${what}`; diff --git a/yarn.lock b/yarn.lock index 2e2b3c5b..a41763f5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -800,9 +800,9 @@ babel-types@^6.26.0: lodash "^4.17.4" to-fast-properties "^1.0.3" -babylon@7.0.0-beta.23: - version "7.0.0-beta.23" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.23.tgz#c7e8e7a389b6f6c6212ceac1a3905c7e73d7e45a" +babylon@7.0.0-beta.28: + version "7.0.0-beta.28" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.28.tgz#14521f26a19918db2b5f4aca89e62e02e0644be7" babylon@^6.13.0, babylon@^6.17.2: version "6.17.3"