2025-10-16 17:57:23 +02:00
|
|
|
import { render } from '@testing-library/vue';
|
|
|
|
|
import { describe, expect, it } from 'vitest';
|
2025-10-16 18:32:12 +02:00
|
|
|
// @ts-ignore
|
2025-10-16 17:57:23 +02:00
|
|
|
import ContextWrapper from './ContextWrapper.vue';
|
2025-07-04 18:51:21 +02:00
|
|
|
|
|
|
|
|
describe('Using lucide icon context', () => {
|
2025-10-16 17:57:23 +02:00
|
|
|
it('should render the icon with LucideProvider', () => {
|
2025-07-04 18:51:21 +02:00
|
|
|
const { container } = render(ContextWrapper);
|
|
|
|
|
|
|
|
|
|
expect(container.firstChild).toMatchSnapshot();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should render the icon with LucideProvider and custom strokeWidth', () => {
|
|
|
|
|
const { container } = render(ContextWrapper);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-12 10:29:24 +01:00
|
|
|
it('should render the icon with LucideProvider and custom absoluteStrokeWidth', () => {
|
|
|
|
|
const { container } = render(ContextWrapper);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
});
|
|
|
|
|
|
2025-10-16 18:07:47 +02:00
|
|
|
it("should override the provider's global props when passing props to the icon", () => {
|
2025-07-04 18:51:21 +02:00
|
|
|
const { container } = render(ContextWrapper, {
|
|
|
|
|
props: {
|
|
|
|
|
strokeWidth: 1,
|
|
|
|
|
color: 'blue',
|
|
|
|
|
size: 24,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const IconComponent = container.firstElementChild;
|
|
|
|
|
|
|
|
|
|
expect(IconComponent).toHaveAttribute('width', '24');
|
|
|
|
|
expect(IconComponent).toHaveAttribute('height', '24');
|
|
|
|
|
expect(IconComponent).toHaveAttribute('stroke', 'blue');
|
|
|
|
|
expect(IconComponent).toHaveAttribute('stroke-width', '1');
|
|
|
|
|
});
|
2025-12-12 10:29:24 +01:00
|
|
|
|
|
|
|
|
it('should merge className from provider and icon', () => {
|
|
|
|
|
const { container } = render(ContextWrapper, {
|
|
|
|
|
props: {
|
|
|
|
|
class: 'icon-class',
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const IconComponent = container.firstElementChild;
|
|
|
|
|
|
|
|
|
|
expect(IconComponent).toHaveAttribute(
|
|
|
|
|
'class',
|
|
|
|
|
'lucide provider-class lucide-house-icon lucide-house icon-class',
|
|
|
|
|
);
|
|
|
|
|
});
|
2025-10-16 17:57:23 +02:00
|
|
|
});
|