test(lucide-react): add tests for DynamicIcon fallback and ref forwarding (#4966)

* test(lucide-react): add tests for DynamicIcon fallback and ref forwarding

* style(lucide-react): format DynamicIcon test with Prettier

---------

Co-authored-by: grzdev <grzdev@users.noreply.github.com>
Co-authored-by: Eric Fennis <eric.fennis@gmail.com>
This commit is contained in:
Dami Oyeniyi
2026-10-09 15:06:46 +02:00
committed by GitHub
co-authored by grzdev Eric Fennis
parent edaf5070d7
commit 949bc6d61f
@@ -52,4 +52,33 @@ describe('Using DynamicIcon Component', () => {
expect(container.firstChild).toMatchSnapshot();
});
it('should render fallback component while icon is loading', () => {
const FallbackComponent = () => <span data-testid="fallback">Loading...</span>;
const { getByTestId } = render(
<DynamicIcon
name="smile"
fallback={FallbackComponent}
/>,
);
expect(getByTestId('fallback')).not.toBeNull();
});
it('should forward ref to the rendered svg element', async () => {
const ref = { current: null as SVGSVGElement | null };
await act(async () => {
render(
<DynamicIcon
ref={ref}
name="smile"
/>,
);
});
await waitFor(() => {
expect(ref.current).toBeInstanceOf(SVGSVGElement);
});
});
});