Skip to content

Commit

Permalink
feat(eslint-plugin): add test for case where enum key has special cha…
Browse files Browse the repository at this point in the history
…racters for rule switch-exhaustiveness-check
  • Loading branch information
karishnu committed Jun 11, 2020
1 parent 28181a8 commit 4704ebe
Showing 1 changed file with 37 additions and 0 deletions.
Expand Up @@ -483,6 +483,43 @@ function test(value: T): number {
case 1: { throw new Error('Not implemented yet: 1 case') }
case 2: { throw new Error('Not implemented yet: 2 case') }
}
}
`.trimRight(),
},
],
},
],
},
{
// keys include special characters
code: `
export enum Enum {
'test-test' = 'test-test',
'test' = 'test',
}
function test(arg: Enum): string {
switch (arg) {
}
}
`.trimRight(),
errors: [
{
messageId: 'switchIsNotExhaustive',
suggestions: [
{
messageId: 'addMissingCases',
output: noFormat`
export enum Enum {
'test-test' = 'test-test',
'test' = 'test',
}
function test(arg: Enum): string {
switch (arg) {
case Enum['test-test']: { throw new Error('Not implemented yet: Enum['test-test'] case') }
case Enum.test: { throw new Error('Not implemented yet: Enum.test case') }
}
}
`.trimRight(),
},
Expand Down

0 comments on commit 4704ebe

Please sign in to comment.