Files
lucide/packages/astro/tests/Icon.spec.ts
2026-11-10 13:48:35 +01:00

57 lines
1.5 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { airVent } from './testIconNodes';
import { createAstroHTMLString, render } from './utils';
import { Icon, Rocket } from '../src/lucide-astro';
describe('Using Icon Component', async () => {
const { container } = await render(Icon, {
props: { iconNode: airVent, size: 48, stroke: 'red' },
});
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();
});
});
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',
},
});
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',
'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',
title: 'Release icon',
},
});
expect(container.firstChild).not.toHaveAttribute('aria-hidden');
});
});