From 949bc6d61f5964a98f99f4eb9b5bc291949ca18f Mon Sep 17 00:00:00 2001 From: Dami Oyeniyi Date: Fri, 9 Oct 2026 14:06:46 +0100 Subject: [PATCH] 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 Co-authored-by: Eric Fennis --- .../lucide-react/tests/DynamicIcon.spec.tsx | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/lucide-react/tests/DynamicIcon.spec.tsx b/packages/lucide-react/tests/DynamicIcon.spec.tsx index b3e1321f4..a99ea6c15 100644 --- a/packages/lucide-react/tests/DynamicIcon.spec.tsx +++ b/packages/lucide-react/tests/DynamicIcon.spec.tsx @@ -52,4 +52,33 @@ describe('Using DynamicIcon Component', () => { expect(container.firstChild).toMatchSnapshot(); }); + + it('should render fallback component while icon is loading', () => { + const FallbackComponent = () => Loading...; + const { getByTestId } = render( + , + ); + + 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( + , + ); + }); + + await waitFor(() => { + expect(ref.current).toBeInstanceOf(SVGSVGElement); + }); + }); });