Test :Add a small test for ReactTestUtils to find rendered component with type in document (#24368)

I tried to write test for the ReactTestUtils to find rendered component
with type in document

Tests before this PR

![Windows PowerShell 4_13_2022 11_35_24
PM](https://user-images.githubusercontent.com/72331432/163243620-40eb753c-4136-4793-a628-efcf9e004562.png)


Tests after this PR 

![Windows PowerShell 4_13_2022 11_35_30
PM](https://user-images.githubusercontent.com/72331432/163244704-cd17f0e3-7289-4794-895a-be03753e46de.png)
This commit is contained in:
BIKI DAS 2023-02-17 16:53:10 +05:30 committed by GitHub
parent 42106558ed
commit 4fcc9184ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -463,4 +463,19 @@ describe('ReactTestUtils', () => {
ReactTestUtils.renderIntoDocument(<Component />);
expect(mockArgs.length).toEqual(0);
});
it('should find rendered component with type in document', () => {
class MyComponent extends React.Component {
render() {
return true;
}
}
const instance = ReactTestUtils.renderIntoDocument(<MyComponent />);
const renderedComponentType = ReactTestUtils.findRenderedComponentWithType(
instance,
MyComponent,
);
expect(renderedComponentType).toBe(instance);
});
});