mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-13 13:48:26 +00:00
* feat(packages): extract build logic to @lucide/shared, still wip * feat(): unify icon build logic some more, add nonScalingStroke option, marking absoluteStrokeWidth as deprecated * feat(): unify icon build logic some more, add nonScalingStroke option, marking absoluteStrokeWidth as deprecated * feat(packages): extract build logic to @lucide/shared, still wip * feat(): unify icon build logic some more, add nonScalingStroke option, marking absoluteStrokeWidth as deprecated * feat(): unify icon build logic some more, add nonScalingStroke option, marking absoluteStrokeWidth as deprecated * chore(icons): revert git hook changes made to icons * fix(packages/astro,react-native,vue): fix iconNode type fix(packages/vue): fix hasA11yProp * fix(packages/solid): make component reactive & add unit tests for checking prop changes * test(packages/vue): add reactivity tests to @lucide/vue * fix(packages): replace cpy-cli, accidentally removed during main merge * docs(packages): upgrade react documentation with nonScalingStroke * fix(tests): update snapshots for lucide-react * feat(docs): upgraded package guides with nonScalingStroke, dropping absoluteStrokeWidth * fix(vue,react-native): fix linting issues * fix(icons): add proper fallback for icon width in calculatedStrokeWidth * fix(packages/svelte): add globalProps.class to icons * fix(packages/shared): wrap width, height & size in isDefined * Update types.ts * fix(packages/svelte): do not pass propsClass to mergeClasses --------- Co-authored-by: Eric Fennis <eric.fennis@gmail.com>
121 lines
3.4 KiB
TypeScript
121 lines
3.4 KiB
TypeScript
import { render } from '@testing-library/react';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { House, LucideProvider } from '../src/lucide-react';
|
|
|
|
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 default props when no provider is used', () => {
|
|
const { container } = render(<House />);
|
|
|
|
const IconComponent = container.firstElementChild;
|
|
|
|
expect(IconComponent).toHaveAttribute('width', '24');
|
|
expect(IconComponent).toHaveAttribute('height', '24');
|
|
expect(IconComponent).toHaveAttribute('stroke', 'currentColor');
|
|
expect(IconComponent).toHaveAttribute('stroke-width', '2');
|
|
});
|
|
|
|
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');
|
|
expect(container.firstChild).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render the icon with LucideProvider and custom nonScalingStroke', () => {
|
|
const { container } = render(
|
|
<LucideProvider
|
|
size={48}
|
|
color="red"
|
|
nonScalingStroke
|
|
>
|
|
<House />
|
|
</LucideProvider>,
|
|
);
|
|
|
|
const IconComponent = container.firstElementChild;
|
|
|
|
expect(IconComponent?.firstElementChild).toHaveAttribute('vector-effect', 'non-scaling-stroke');
|
|
expect(container.firstChild).toMatchSnapshot();
|
|
});
|
|
|
|
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 className from provider and icon', () => {
|
|
const { container } = render(
|
|
<LucideProvider className="provider-class">
|
|
<House className="icon-class" />
|
|
</LucideProvider>,
|
|
);
|
|
|
|
const IconComponent = container.firstElementChild;
|
|
|
|
expect(IconComponent).toHaveAttribute(
|
|
'class',
|
|
'lucide lucide-house lucide-home provider-class icon-class',
|
|
);
|
|
});
|
|
});
|