mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-08-29 12:08:25 +02:00
* Add context provider for svelte package * Add context provider for react * Remove old vue 2 package * Add @lucide/vue package * Remove old vue 2 doc * Update docs * Adjust export template * Add context provider to solid package * Fix context * Implement context providers * Add context provider to preact * Adjust vue package! * Fix tests * Format code * Add context provider for Vue * Improve memoization * Update packages/lucide-react-native/tests/context.spec.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Apply fixes * Cleanup * Formatting * Move on * Update packages/lucide-react/tests/context.spec.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/lucide-preact/tests/context.spec.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/vue/tests/context.spec.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove x * update export template * apply feedback * fix export template * Fixes types and tests * fix tests * apply feedback * Remove class * Formatting * Update packages/svelte/src/context.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove fill form context providers * formatting * Add classname to context provider * Apply feedback * Format code * Rename files * Rename tsx to ts * Format file --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
89 lines
2.4 KiB
TypeScript
89 lines
2.4 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 override the provider's global props when passing 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');
|
|
});
|
|
|
|
it('should merge class names from LucideProvider and icon props', () => {
|
|
const { container } = render(
|
|
<LucideProvider class="provider-class">
|
|
<House class="icon-class" />
|
|
</LucideProvider>,
|
|
);
|
|
|
|
const IconComponent = container.firstElementChild;
|
|
|
|
expect(IconComponent).toHaveAttribute('class', 'lucide provider-class lucide-house icon-class');
|
|
});
|
|
});
|