From 8dad653a81a5a0e4faf93bd1fd01d77790858166 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 16 Dec 2021 16:27:18 +0530 Subject: [PATCH] test: add more cases --- tests/lib/rules/id-match.js | 64 +++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/tests/lib/rules/id-match.js b/tests/lib/rules/id-match.js index cb21e5d8f0b..5a1f75812f4 100644 --- a/tests/lib/rules/id-match.js +++ b/tests/lib/rules/id-match.js @@ -197,6 +197,46 @@ ruleTester.run("id-match", rule, { }], parserOptions: { ecmaVersion: 2022 } }, + { + code: ` + const foo = { + foo_one: 1, + bar_one: 2, + fooBar: 3 + }; + `, + options: ["^[^_]+$", { + properties: false + }], + parserOptions: { ecmaVersion: 2022 } + }, + { + code: ` + const foo = { + foo_one: 1, + bar_one: 2, + fooBar: 3 + }; + `, + options: ["^[^_]+$", { + onlyDeclarations: true + }], + parserOptions: { ecmaVersion: 2022 } + }, + { + code: ` + const foo = { + foo_one: 1, + bar_one: 2, + fooBar: 3 + }; + `, + options: ["^[^_]+$", { + properties: false, + onlyDeclarations: false + }], + parserOptions: { ecmaVersion: 2022 } + }, // Class Methods { @@ -800,6 +840,30 @@ ruleTester.run("id-match", rule, { type: "Identifier" } ] + }, + { + code: ` + const foo = { + foo_one: 1, + bar_one: 2, + fooBar: 3 + }; + `, + options: ["^[^_]+$", { + properties: true, + onlyDeclarations: false + }], + parserOptions: { ecmaVersion: 2022 }, + errors: [ + { + message: "Identifier 'foo_one' does not match the pattern '^[^_]+$'.", + type: "Identifier" + }, + { + message: "Identifier 'bar_one' does not match the pattern '^[^_]+$'.", + type: "Identifier" + } + ] } ] });