From 028c05ec51562e6503df1f120baf76dfb1135e75 Mon Sep 17 00:00:00 2001 From: Andrew Hyndman Date: Tue, 7 Jun 2016 20:28:13 +1000 Subject: [PATCH] Define bejaviour with unit tests --- tests/lib/rules/arrow-body-style.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/lib/rules/arrow-body-style.js b/tests/lib/rules/arrow-body-style.js index fc19dfe081ce..a441c751fda8 100644 --- a/tests/lib/rules/arrow-body-style.js +++ b/tests/lib/rules/arrow-body-style.js @@ -30,7 +30,9 @@ ruleTester.run("arrow-body-style", rule, { { code: "var foo = () => { b = a };", parserOptions: { ecmaVersion: 6 } }, { code: "var foo = () => { bar: 1 };", parserOptions: { ecmaVersion: 6 } }, { code: "var foo = () => { return 0; };", parserOptions: { ecmaVersion: 6 }, options: ["always"] }, - { code: "var foo = () => { return bar(); };", parserOptions: { ecmaVersion: 6 }, options: ["always"] } + { code: "var foo = () => { return bar(); };", parserOptions: { ecmaVersion: 6 }, options: ["always"] }, + { code: "var foo = () => 0;", parserOptions: { ecmaVersion: 6 }, options: ["never"] }, + { code: "var foo = () => ({ foo: 0 });", parserOptions: { ecmaVersion: 6 }, options: ["never"] } ], invalid: [ { @@ -64,6 +66,22 @@ ruleTester.run("arrow-body-style", rule, { errors: [ { line: 1, column: 17, type: "ArrowFunctionExpression", message: "Unexpected block statement surrounding arrow body." } ] + }, + { + code: "var foo = () => {\nreturn 0;\n};", + parserOptions: { ecmaVersion: 6 }, + options: ["never"], + errors: [ + { line: 1, column: 17, type: "ArrowFunctionExpression", message: "Unexpected block statement surrounding arrow body." } + ] + }, + { + code: "var foo = (retv, name) => {\nretv[name] = true;\nreturn retv;\n};", + parserOptions: { ecmaVersion: 6 }, + options: ["never"], + errors: [ + { line: 1, column: 27, type: "ArrowFunctionExpression", message: "Unexpected block statement surrounding arrow body." } + ] } ] });