mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-18 17:07:40 +01:00
* Add useIconComponent, lucide-react * Add concept useIconComponent * add useIconComponents to packages * Add icon component * Add icon component * Add tests for react packages * Reset changes in icons * Add types * Add support for Icon components in Lucide Vue Next * update tests * Update tests * Enable Svelte component * Fix lucide-react-native tests * Update Solid package * update snapshots * Add docs * add docs * Update tests * Formatting * Formatting * Update package lock * Remove `useIconComponent` * Update guides * Update exports preact and solid package * Formatting * Format createIcons.ts * Add lucide lab repo link in docs
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { Suspense, lazy } from 'react';
|
|
import { render, waitFor } from '@testing-library/react';
|
|
|
|
import dynamicIconImports from '../src/dynamicIconImports';
|
|
import { LucideProps } from '../src/types';
|
|
|
|
describe('Using dynamicImports', () => {
|
|
it('should render icons dynamically by using the dynamicIconImports module', async () => {
|
|
interface IconProps extends Omit<LucideProps, 'ref'> {
|
|
name: keyof typeof dynamicIconImports;
|
|
}
|
|
|
|
const Icon = ({ name, ...props }: IconProps) => {
|
|
const LucideIcon = lazy(dynamicIconImports[name]);
|
|
|
|
return (
|
|
<Suspense fallback={null}>
|
|
<LucideIcon {...props} />
|
|
</Suspense>
|
|
);
|
|
};
|
|
|
|
const { container, getByLabelText } = render(
|
|
<Icon
|
|
aria-label="smile"
|
|
name="smile"
|
|
size={48}
|
|
stroke="red"
|
|
absoluteStrokeWidth
|
|
/>,
|
|
);
|
|
|
|
await waitFor(() => getByLabelText('smile'));
|
|
|
|
expect(container.innerHTML).toMatchSnapshot();
|
|
});
|
|
});
|