Skip to content

Commit

Permalink
Define bejaviour with unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ajhyndman committed Jun 8, 2016
1 parent 1899651 commit dd480d5
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/lib/rules/arrow-body-style.js
Expand Up @@ -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: [
{
Expand Down Expand Up @@ -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." }
]
}
]
});

0 comments on commit dd480d5

Please sign in to comment.