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); + }); + }); });