Skip to content

Commit

Permalink
try this instead
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Jan 28, 2025
1 parent 96f98e9 commit 40936ad
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
import * as React from 'react';
import SvgComponent, { SvgComponentWithRef } from './SvgComponent';
import ReactDOMClient from 'react-dom/client';

global.IS_REACT_ACT_ENVIRONMENT = true;
import { flushSync } from 'react-dom';

describe('svg component', () => {
it('renders without crashing', () => {
it('renders without crashing', async () => {
const div = document.createElement('div');
ReactDOMClient.createRoot(div).render(<SvgComponent />);
flushSync(() => {
ReactDOMClient.createRoot(div).render(<SvgComponent />);
});
expect(div.textContent).toBe('logo.svg');
});

it('svg root element equals the passed ref', async () => {
const div = document.createElement('div');
const someRef = React.createRef();
// eslint-disable-next-line testing-library/no-unnecessary-act
await React.act(async () => {
flushSync(() => {
ReactDOMClient.createRoot(div).render(
<SvgComponentWithRef ref={someRef} />
);
Expand Down

0 comments on commit 40936ad

Please sign in to comment.