Skip to content

Commit 8a3d674

Browse files
authored
refactor: replace the deprecated __proto__ with Object.getPrototypeOf (#1931)
1 parent cfc91a0 commit 8a3d674

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/matchers/mock/toBeRequestedWith.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,21 +231,21 @@ const headersMatcher = (
231231
*
232232
* Jest and Jasmine support special matchers like `jasmine.objectContaining`, `expect.arrayContaining`, etc.
233233
*
234-
* All these kind of objects have `sample` and `asymmetricMatch` function in __proto__
235-
* `expect.objectContaining({ foo: 'bar })` -> `{ sample: { foo: 'bar' }, __proto__: asymmetricMatch() {} }`
234+
* All these kind of objects have `sample` and `asymmetricMatch` function in their prototype
235+
* `expect.objectContaining({ foo: 'bar })` -> `{ sample: { foo: 'bar' }, [prototype]: asymmetricMatch() {} }`
236236
*
237237
* jasmine.any and jasmine.anything don't have `sample` property
238238
* @param filter
239239
*/
240240
const isMatcher = (filter: unknown) => {
241+
const proto = Object.getPrototypeOf(filter)
241242
return (
242243
typeof filter === 'object' &&
243244
filter !== null &&
244-
'__proto__' in filter &&
245-
typeof filter.__proto__ === 'object' &&
246-
filter.__proto__ &&
247-
'asymmetricMatch' in filter.__proto__ &&
248-
typeof filter.__proto__.asymmetricMatch === 'function'
245+
typeof proto === 'object' &&
246+
proto &&
247+
'asymmetricMatch' in proto &&
248+
typeof proto.asymmetricMatch === 'function'
249249
)
250250
}
251251

0 commit comments

Comments
 (0)