mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-16 18:47:43 +01:00
78 lines
2.0 KiB
TypeScript
78 lines
2.0 KiB
TypeScript
|
|
import { render } from "@testing-library/preact";
|
||
|
|
import { describe, expect, it } from "vitest";
|
||
|
|
import { House, LucideProvider } from "../src/lucide-preact";
|
||
|
|
|
||
|
|
describe('Using LucideProvider', () => {
|
||
|
|
it('should render the icon with LucideProvider', () => {
|
||
|
|
const { container } = render(
|
||
|
|
<LucideProvider
|
||
|
|
size={48}
|
||
|
|
color="red"
|
||
|
|
>
|
||
|
|
<House/>
|
||
|
|
</LucideProvider>
|
||
|
|
);
|
||
|
|
|
||
|
|
expect(container.firstChild).toMatchSnapshot();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('should render the icon with LucideProvider and custom strokeWidth', () => {
|
||
|
|
const { container } = render(
|
||
|
|
<LucideProvider
|
||
|
|
size={48}
|
||
|
|
color="red"
|
||
|
|
strokeWidth={4}
|
||
|
|
>
|
||
|
|
<House/>
|
||
|
|
</LucideProvider>
|
||
|
|
);
|
||
|
|
|
||
|
|
const IconComponent = container.firstElementChild;
|
||
|
|
|
||
|
|
expect(IconComponent).toHaveAttribute('width', '48');
|
||
|
|
expect(IconComponent).toHaveAttribute('height', '48');
|
||
|
|
expect(IconComponent).toHaveAttribute('stroke', 'red');
|
||
|
|
expect(IconComponent).toHaveAttribute('stroke-width', '4');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('should render the icon with LucideProvider and custom absoluteStrokeWidth', () => {
|
||
|
|
const { container } = render(
|
||
|
|
<LucideProvider
|
||
|
|
size={48}
|
||
|
|
color="red"
|
||
|
|
absoluteStrokeWidth
|
||
|
|
>
|
||
|
|
<House/>
|
||
|
|
</LucideProvider>
|
||
|
|
);
|
||
|
|
|
||
|
|
const IconComponent = container.firstElementChild;
|
||
|
|
|
||
|
|
expect(IconComponent).toHaveAttribute('stroke-width', '1');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('should render override the providers global props when passed props to the icon', () => {
|
||
|
|
const { container } = render(
|
||
|
|
<LucideProvider
|
||
|
|
size={48}
|
||
|
|
color="red"
|
||
|
|
strokeWidth={4}
|
||
|
|
>
|
||
|
|
<House
|
||
|
|
size={24}
|
||
|
|
color="blue"
|
||
|
|
strokeWidth={2}
|
||
|
|
/>
|
||
|
|
</LucideProvider>
|
||
|
|
);
|
||
|
|
|
||
|
|
const IconComponent = container.firstElementChild;
|
||
|
|
|
||
|
|
expect(IconComponent).toHaveAttribute('width', '24');
|
||
|
|
expect(IconComponent).toHaveAttribute('height', '24');
|
||
|
|
expect(IconComponent).toHaveAttribute('stroke', 'blue');
|
||
|
|
expect(IconComponent).toHaveAttribute('stroke-width', '2');
|
||
|
|
}
|
||
|
|
);
|
||
|
|
})
|