Skip to content

Commit

Permalink
Chore: add missing output property to tests (#8195)
Browse files Browse the repository at this point in the history
  • Loading branch information
alberto authored and not-an-aardvark committed Mar 4, 2017
1 parent f882a11 commit 580da36
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 4 deletions.
1 change: 1 addition & 0 deletions tests/lib/rules/brace-style.js
Expand Up @@ -479,6 +479,7 @@ ruleTester.run("brace-style", rule, {
},
{
code: "try { bar(); }\ncatch (e) { baz(); }",
output: "try { bar(); }catch (e) { baz(); }",
options: ["1tbs", { allowSingleLine: true }],
errors: [{ message: CLOSE_MESSAGE, type: "Punctuator" }]
},
Expand Down
56 changes: 56 additions & 0 deletions tests/lib/rules/indent.js
Expand Up @@ -2277,6 +2277,11 @@ ruleTester.run("indent", rule, {
" foo\n" +
" .bar\n" +
"}",
output:
"var foo = function(){\n" +
" foo\n" +
" .bar\n" +
"}",
options: [4, { MemberExpression: 1 }],
errors: expectedErrors(
[3, 8, 10, "Punctuator"]
Expand All @@ -2288,6 +2293,11 @@ ruleTester.run("indent", rule, {
" foo\n" +
" .bar\n" +
"}",
output:
"var foo = function(){\n" +
" foo\n" +
" .bar\n" +
"}",
options: [4, { MemberExpression: 2 }],
errors: expectedErrors(
[3, 12, 13, "Punctuator"]
Expand All @@ -2299,6 +2309,11 @@ ruleTester.run("indent", rule, {
" foo\n" +
" .bar\n" +
"}",
output:
"var foo = () => {\n" +
" foo\n" +
" .bar\n" +
"}",
options: [4, { MemberExpression: 2 }],
parserOptions: { ecmaVersion: 6 },
errors: expectedErrors(
Expand All @@ -2313,6 +2328,13 @@ ruleTester.run("indent", rule, {
" return x;\n" +
" });\n" +
"};",
output:
"TestClass.prototype.method = function () {\n" +
" return Promise.resolve(3)\n" +
" .then(function (x) {\n" +
" return x;\n" +
" });\n" +
"};",
options: [2, { MemberExpression: 1 }],
parserOptions: { ecmaVersion: 6 },
errors: expectedErrors(
Expand Down Expand Up @@ -3022,6 +3044,12 @@ ruleTester.run("indent", rule, {
" return x + 1;\n" +
" }\n" +
"})();",
output:
"(function(){\n" +
"function foo(x) {\n" +
" return x + 1;\n" +
" }\n" +
"})();",
options: [2, { outerIIFEBody: 0 }],
errors: expectedErrors([[2, 0, 2, "FunctionDeclaration"]])
},
Expand All @@ -3032,6 +3060,12 @@ ruleTester.run("indent", rule, {
" return x + 1;\n" +
" }\n" +
"})();",
output:
"(function(){\n" +
" function foo(x) {\n" +
" return x + 1;\n" +
" }\n" +
"})();",
options: [4, { outerIIFEBody: 2 }],
errors: expectedErrors([[2, 8, 4, "FunctionDeclaration"]])
},
Expand All @@ -3040,6 +3074,10 @@ ruleTester.run("indent", rule, {
"if(data) {\n" +
"console.log('hi');\n" +
"}",
output:
"if(data) {\n" +
" console.log('hi');\n" +
"}",
options: [2, { outerIIFEBody: 0 }],
errors: expectedErrors([[2, 2, 0, "ExpressionStatement"]])
},
Expand All @@ -3050,6 +3088,12 @@ ruleTester.run("indent", rule, {
" return x + 1;\n" +
" }\n" +
"}(x);",
output:
"var ns = function(){\n" +
" function fooVar(x) {\n" +
" return x + 1;\n" +
" }\n" +
"}(x);",
options: [4, { outerIIFEBody: 2 }],
errors: expectedErrors([[2, 8, 4, "FunctionDeclaration"]])
},
Expand All @@ -3060,6 +3104,12 @@ ruleTester.run("indent", rule, {
" return true;\n" +
" }()\n" +
"};\n",
output:
"var obj = {\n" +
" foo: function() {\n" +
" return true;\n" +
" }()\n" +
"};\n",
options: [2, { outerIIFEBody: 0 }],
errors: expectedErrors([[3, 4, 2, "ReturnStatement"]])
},
Expand All @@ -3070,6 +3120,12 @@ ruleTester.run("indent", rule, {
" return x + 1;\n" +
" }\n" +
"}();",
output:
"typeof function() {\n" +
" function fooVar(x) {\n" +
" return x + 1;\n" +
" }\n" +
"}();",
options: [2, { outerIIFEBody: 2 }],
errors: expectedErrors([[2, 2, 4, "FunctionDeclaration"]])
},
Expand Down
25 changes: 25 additions & 0 deletions tests/lib/rules/key-spacing.js
Expand Up @@ -1233,6 +1233,11 @@ ruleTester.run("key-spacing", rule, {
" , cats: cats",
"};"
].join("\n"),
output: [
"var obj = { foo : foo",
" , cats: cats",
"};"
].join("\n"),
options: [{ align: "colon" }],
errors: [
{ message: "Extra space after key 'foo'.", line: 1, column: 13, type: "Identifier" }
Expand Down Expand Up @@ -1683,6 +1688,16 @@ ruleTester.run("key-spacing", rule, {
" key4: 4",
"}"
].join("\n"),
output: [
"var obj = {",
" key1: 1,",
"",
" key2: 2,",
" key3: 3,",
"",
" key4: 4",
"}"
].join("\n"),
options: [{
multiLine: {
beforeColon: false,
Expand Down Expand Up @@ -1711,6 +1726,16 @@ ruleTester.run("key-spacing", rule, {
" key4: 4",
"}"
].join("\n"),
output: [
"var obj = {",
" key1: 1,",
"",
" key2: 2,",
" key3: 3,",
"",
" key4: 4",
"}"
].join("\n"),
options: [{
multiLine: {
beforeColon: false,
Expand Down
9 changes: 9 additions & 0 deletions tests/lib/rules/lines-around-comment.js
Expand Up @@ -1169,6 +1169,15 @@ ruleTester.run("lines-around-comment", rule, {
" // hi\n" +
" }\n" +
"}",
output:
"function hi() {\n" +
" return {\n" +
" test: function() {\n" +
" }\n" +
" // hi\n" +
"\n" +
" }\n" +
"}",
options: [{
afterLineComment: true
}],
Expand Down
8 changes: 8 additions & 0 deletions tests/lib/rules/object-shorthand.js
Expand Up @@ -738,16 +738,19 @@ ruleTester.run("object-shorthand", rule, {
// consistent
{
code: "var x = {a: a, b}",
output: null,
options: ["consistent"],
errors: [MIXED_SHORTHAND_ERROR]
},
{
code: "var x = {b, c: d, f: g}",
output: null,
options: ["consistent"],
errors: [MIXED_SHORTHAND_ERROR]
},
{
code: "var x = {foo, bar: baz, ...qux}",
output: null,
parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } },
options: ["consistent"],
errors: [MIXED_SHORTHAND_ERROR]
Expand All @@ -756,28 +759,33 @@ ruleTester.run("object-shorthand", rule, {
// consistent-as-needed
{
code: "var x = {a: a, b: b}",
output: null,
options: ["consistent-as-needed"],
errors: [ALL_SHORTHAND_ERROR]
},
{
code: "var x = {a, z: function z(){}}",
output: null,
options: ["consistent-as-needed"],
errors: [MIXED_SHORTHAND_ERROR]

},
{
code: "var x = {foo: function() {}}",
output: null,
options: ["consistent-as-needed"],
errors: [ALL_SHORTHAND_ERROR]
},
{
code: "var x = {a: a, b: b, ...baz}",
output: null,
parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } },
options: ["consistent-as-needed"],
errors: [ALL_SHORTHAND_ERROR]
},
{
code: "var x = {foo, bar: bar, ...qux}",
output: null,
parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } },
options: ["consistent-as-needed"],
errors: [MIXED_SHORTHAND_ERROR]
Expand Down
8 changes: 4 additions & 4 deletions tests/lib/rules/semi.js
Expand Up @@ -140,10 +140,10 @@ ruleTester.run("semi", rule, {
{ code: "import theDefault, { named1, named2 } from 'src/mylib';", output: "import theDefault, { named1, named2 } from 'src/mylib'", options: ["never"], parserOptions: { sourceType: "module" }, errors: [{ message: "Extra semicolon.", type: "ImportDeclaration" }] },
{ code: "do{}while(true);", output: "do{}while(true)", options: ["never"], errors: [{ message: "Extra semicolon.", type: "DoWhileStatement", line: 1 }] },

{ code: "if (foo) { bar()\n }", options: ["always", { omitLastInOneLineBlock: true }], errors: [{ message: "Missing semicolon." }] },
{ code: "if (foo) {\n bar() }", options: ["always", { omitLastInOneLineBlock: true }], errors: [{ message: "Missing semicolon." }] },
{ code: "if (foo) {\n bar(); baz() }", options: ["always", { omitLastInOneLineBlock: true }], errors: [{ message: "Missing semicolon." }] },
{ code: "if (foo) { bar(); }", options: ["always", { omitLastInOneLineBlock: true }], errors: [{ message: "Extra semicolon." }] },
{ code: "if (foo) { bar()\n }", output: "if (foo) { bar();\n }", options: ["always", { omitLastInOneLineBlock: true }], errors: [{ message: "Missing semicolon." }] },
{ code: "if (foo) {\n bar() }", output: "if (foo) {\n bar(); }", options: ["always", { omitLastInOneLineBlock: true }], errors: [{ message: "Missing semicolon." }] },
{ code: "if (foo) {\n bar(); baz() }", output: "if (foo) {\n bar(); baz(); }", options: ["always", { omitLastInOneLineBlock: true }], errors: [{ message: "Missing semicolon." }] },
{ code: "if (foo) { bar(); }", output: "if (foo) { bar() }", options: ["always", { omitLastInOneLineBlock: true }], errors: [{ message: "Extra semicolon." }] },


// exports, "always"
Expand Down
8 changes: 8 additions & 0 deletions tests/lib/rules/sort-imports.js
Expand Up @@ -136,30 +136,35 @@ ruleTester.run("sort-imports", rule, {
code:
"import a from 'foo.js';\n" +
"import A from 'bar.js';",
output: null,
errors: [expectedError]
},
{
code:
"import b from 'foo.js';\n" +
"import a from 'bar.js';",
output: null,
errors: [expectedError]
},
{
code:
"import {b, c} from 'foo.js';\n" +
"import {a, d} from 'bar.js';",
output: null,
errors: [expectedError]
},
{
code:
"import * as foo from 'foo.js';\n" +
"import * as bar from 'bar.js';",
output: null,
errors: [expectedError]
},
{
code:
"import a from 'foo.js';\n" +
"import {b, c} from 'bar.js';",
output: null,
errors: [{
message: "Expected 'multiple' syntax before 'single' syntax.",
type: "ImportDeclaration"
Expand All @@ -169,6 +174,7 @@ ruleTester.run("sort-imports", rule, {
code:
"import a from 'foo.js';\n" +
"import * as b from 'bar.js';",
output: null,
errors: [{
message: "Expected 'all' syntax before 'single' syntax.",
type: "ImportDeclaration"
Expand All @@ -178,6 +184,7 @@ ruleTester.run("sort-imports", rule, {
code:
"import a from 'foo.js';\n" +
"import 'bar.js';",
output: null,
errors: [{
message: "Expected 'none' syntax before 'single' syntax.",
type: "ImportDeclaration"
Expand All @@ -187,6 +194,7 @@ ruleTester.run("sort-imports", rule, {
code:
"import b from 'bar.js';\n" +
"import * as a from 'foo.js';",
output: null,
options: [{
memberSyntaxSortOrder: ["all", "single", "multiple", "none"]
}],
Expand Down
2 changes: 2 additions & 0 deletions tests/lib/rules/spaced-comment.js
Expand Up @@ -577,11 +577,13 @@ ruleTester.run("spaced-comment", rule, {
// Parser errors
{
code: invalidShebangProgram,
output: null,
errors: 1,
options: ["always"]
},
{
code: invalidShebangProgram,
output: null,
errors: 1,
options: ["never"]
}
Expand Down

0 comments on commit 580da36

Please sign in to comment.