Skip to content

Commit

Permalink
feat: Added more no-case-declarations tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ElianCordoba committed Jun 30, 2023
1 parent 9718a97 commit 6105a8d
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/lib/rules/no-case-declarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,49 @@ ruleTester.run("no-case-declarations", rule, {
{
code: "switch (a) { case 1: { class C {} break; } default: { class C {} break; } }",
parserOptions: { ecmaVersion: 6 }
},
{
code: `
switch (a) {
case 1:
case 2: {}
}
`,
parserOptions: { ecmaVersion: 6 }
},
{
code: `
switch (a) {
case 1: var x;
}
`,
parserOptions: { ecmaVersion: 6 }
}
],
invalid: [
{
code: `
switch (a) {
case 1:
{}
function f() {}
break;
}
`,
parserOptions: { ecmaVersion: 6 },
errors: [{ messageId: "unexpected", type: "FunctionDeclaration" }]
},
{
code: `
switch (a) {
case 1:
case 2:
let x;
}
`,
parserOptions: { ecmaVersion: 6 },
errors: [{ messageId: "unexpected", type: "VariableDeclaration" }]
},
{
code: "switch (a) { case 1: let x = 1; break; }",
parserOptions: { ecmaVersion: 6 },
Expand Down

0 comments on commit 6105a8d

Please sign in to comment.