From 7e0c12d777fab73944594d1a0d9ac6319fc68a5a Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 11 Dec 2021 16:54:01 +0530 Subject: [PATCH] test: add more test cases --- tests/lib/rules/prefer-object-has-own.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/lib/rules/prefer-object-has-own.js b/tests/lib/rules/prefer-object-has-own.js index 814967d985d..64b34eafeed 100644 --- a/tests/lib/rules/prefer-object-has-own.js +++ b/tests/lib/rules/prefer-object-has-own.js @@ -358,6 +358,28 @@ ruleTester.run("prefer-object-has-own", rule, { endColumn: 67 }] }, + { + code: "for (const x in{}.hasOwnProperty.call(object, property).toString());", + output: "for (const x in Object.hasOwn(object, property).toString());", + errors: [{ + messageId: "useHasOwn", + line: 1, + column: 16, + endLine: 1, + endColumn: 56 + }] + }, + { + code: "for (const x in/*comment*/{}.hasOwnProperty.call(object, property).toString());", + output: "for (const x in/*comment*/Object.hasOwn(object, property).toString());", + errors: [{ + messageId: "useHasOwn", + line: 1, + column: 27, + endLine: 1, + endColumn: 67 + }] + }, { code: "Object['prototype']['hasOwnProperty']['call'](object, property);", output: "Object.hasOwn(object, property);",