Files
lucide/packages/lucide-react/tests/DynamicIcon.spec.tsx
Eric Fennis 58c2e108c3 feat(lucide-react): Add DynamicIcon component (#2686)
* Adding the DynamicIcon component

* Fix imports

* Add docs

* Formatting

* Fix use client in output rollup

* revert changes

* Fix formatting

* Revert changes in icons directory

* Revert time command

* update exports
2025-01-10 14:35:28 +01:00

56 lines
1.5 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { act, render, waitFor, type RenderResult } from '@testing-library/react';
import DynamicIcon from '../src/DynamicIcon';
describe('Using DynamicIcon Component', () => {
it('should render icon by given name', async () => {
let container: RenderResult['container'];
await act(async () => {
const result = render(<DynamicIcon name="smile" />);
container = result.container;
});
await waitFor(() => {
// I'd look for a real text here that is renderer when the data loads
expect(container.firstChild).not.toBeNull();
});
});
it('should render icon by alias name', async () => {
let container: RenderResult['container'];
await act(async () => {
const result = render(<DynamicIcon name="home" />);
container = result.container;
});
await waitFor(() => {
// I'd look for a real text here that is renderer when the data loads
expect(container.firstChild).not.toBeNull();
});
});
it('should render icon and match snapshot', async () => {
const { container } = render(<DynamicIcon name="circle" />);
expect(container.firstChild).toMatchSnapshot();
});
it('should adjust the style based', async () => {
const { container } = render(
<DynamicIcon
name="circle"
size={48}
stroke="red"
absoluteStrokeWidth
/>,
);
expect(container.firstChild).toMatchSnapshot();
});
});