2025-03-31 14:20:33 +00:00
|
|
|
import { describe, it, expect } from 'vitest';
|
|
|
|
|
import { airVent } from './testIconNodes';
|
2026-01-20 15:55:02 +01:00
|
|
|
import { createAstroHTMLString, render } from './utils';
|
|
|
|
|
import { Icon, Rocket } from '../src/lucide-astro';
|
2025-03-31 14:20:33 +00:00
|
|
|
|
|
|
|
|
describe('Using Icon Component', async () => {
|
|
|
|
|
const { container } = await render(Icon, {
|
|
|
|
|
props: { iconNode: airVent, size: 48, stroke: 'red', absoluteStrokeWidth: true },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should render icon and match snapshot', async () => {
|
|
|
|
|
expect(container.innerHTML).toMatchSnapshot();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should render icon based on a iconNode', async () => {
|
|
|
|
|
expect(container.innerHTML).toBeDefined();
|
|
|
|
|
});
|
|
|
|
|
});
|
2026-01-20 15:55:02 +01:00
|
|
|
|
|
|
|
|
describe('Icon Component Accessibility', () => {
|
|
|
|
|
it('should have aria-hidden prop when no aria prop is present', async () => {
|
|
|
|
|
const { container } = await render(Icon, {
|
|
|
|
|
props: {
|
|
|
|
|
iconNode: airVent,
|
|
|
|
|
size: 48,
|
|
|
|
|
stroke: 'red',
|
|
|
|
|
absoluteStrokeWidth: true,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(container.firstChild).toHaveAttribute('aria-hidden', 'true');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should not have aria-hidden prop when aria prop is present', async () => {
|
|
|
|
|
const { container } = await render(Rocket, {
|
|
|
|
|
props: {
|
|
|
|
|
size: 48,
|
|
|
|
|
stroke: 'red',
|
|
|
|
|
absoluteStrokeWidth: true,
|
|
|
|
|
'aria-label': 'Release icon',
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(container.firstChild).not.toHaveAttribute('aria-hidden');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should not have aria-hidden prop when title prop is present', async () => {
|
|
|
|
|
const { container } = await render(Rocket, {
|
|
|
|
|
props: {
|
|
|
|
|
size: 48,
|
|
|
|
|
stroke: 'red',
|
|
|
|
|
absoluteStrokeWidth: true,
|
|
|
|
|
title: 'Release icon',
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(container.firstChild).not.toHaveAttribute('aria-hidden');
|
|
|
|
|
});
|
|
|
|
|
});
|