diff --git a/packages/eslint-plugin/tests/rules/switch-exhaustiveness-check.test.ts b/packages/eslint-plugin/tests/rules/switch-exhaustiveness-check.test.ts index 3eb47fb6eb9..e3faea342ba 100644 --- a/packages/eslint-plugin/tests/rules/switch-exhaustiveness-check.test.ts +++ b/packages/eslint-plugin/tests/rules/switch-exhaustiveness-check.test.ts @@ -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(), },