@samitouri / QOS-React-2 / commits / 9c48fb25ec

Remove ReactTestUtils from refs-destruction-test (#28532)

```diff -expect(ReactTestUtils.isDOMComponent(maybeElement)).toBe(true); +expect(maybeElement).toBeInstanceOf(Element); ``` It's not equivalent since `isDOMComponent` checks `maybeElement.nodeType === Element.ELEMENT_NODE && !!maybeElement.tagName` but `instanceof` check seems sufficient here. Checking `nodeType` is mostly for cross-realm checks and checking falsy `tagName` seems like a check specifically for incomplete DOM implementations because tagName can't be empty by spec I believe.

Sebastian Silbermann committed Mar 11, 2024 at 22:11 UTC 9c48fb25ecc467b37abb3e145c6e25e311dcdde5
1 file changed +3 -5
packages/react-dom/src/__tests__/refs-destruction-test.js
+3 -5
@@ -12,7 +12,6 @@
12 let React;
13 let ReactDOM;
14 let ReactDOMClient;
15 -let ReactTestUtils;
15 let TestComponent;
16 let act;
17 let theInnerDivRef;
@@ -25,7 +24,6 @@ describe('refs-destruction', () => {
24 React = require('react');
25 ReactDOM = require('react-dom');
26 ReactDOMClient = require('react-dom/client');
28 - ReactTestUtils = require('react-dom/test-utils');
27 act = require('internal-test-utils').act;
28
29 class ClassComponent extends React.Component {
@@ -75,7 +73,7 @@ describe('refs-destruction', () => {
73 root.render(<TestComponent />);
74 });
75
78 - expect(ReactTestUtils.isDOMComponent(theInnerDivRef.current)).toBe(true);
76 + expect(theInnerDivRef.current).toBeInstanceOf(Element);
77 expect(theInnerClassComponentRef.current).toBeTruthy();
78
79 root.unmount();
@@ -91,7 +89,7 @@ describe('refs-destruction', () => {
89 root.render(<TestComponent />);
90 });
91
94 - expect(ReactTestUtils.isDOMComponent(theInnerDivRef.current)).toBe(true);
92 + expect(theInnerDivRef.current).toBeInstanceOf(Element);
93 expect(theInnerClassComponentRef.current).toBeTruthy();
94
95 await act(async () => {
@@ -109,7 +107,7 @@ describe('refs-destruction', () => {
107 root.render(<TestComponent />);
108 });
109
112 - expect(ReactTestUtils.isDOMComponent(theInnerDivRef.current)).toBe(true);
110 + expect(theInnerDivRef.current).toBeInstanceOf(Element);
111 expect(theInnerClassComponentRef.current).toBeTruthy();
112
113 await act(async () => {