Skip to content

Commit

Permalink
idk
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Jan 28, 2025
1 parent a8b21a1 commit 7510aa6
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,20 @@
import * as React from 'react';
import SvgComponent, { SvgComponentWithRef } from './SvgComponent';
import ReactDOMClient from 'react-dom/client';
import { flushSync } from 'react-dom';

describe('svg component', () => {
it('renders without crashing', async () => {
const div = document.createElement('div');
flushSync(() => {
ReactDOMClient.createRoot(div).render(<SvgComponent />);
});
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();
flushSync(() => {
ReactDOMClient.createRoot(div).render(
<SvgComponentWithRef ref={someRef} />
);
});
ReactDOMClient.createRoot(div).render(
<SvgComponentWithRef ref={someRef} />
);
const svgElement = div.getElementsByTagName('svg');
expect(svgElement).toHaveLength(1);
expect(svgElement[0]).toBe(someRef.current);
Expand Down

0 comments on commit 7510aa6

Please sign in to comment.