mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-05-18 09:34:43 +02:00
* Add aria hidden to lucide package * Add aria-hidden to astro package * Add tests for shared package * Fix test for props * add aria prop to lucide-solid * Add aria-hidden to lucide-vue-next * Add aria-hidden prop to angular package * Fix builds * Add notice about aria-label in docs * Format code * Update packages/svelte/tests/Icon.spec.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/lucide-svelte/tests/Icon.spec.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/shared/src/utils/hasA11yProp.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Adjusted docs * Fix import * update tests * test(shared): fix hasA11yProp unit test * fix(packages/lucide-angular): fix hasA11yProp import path (non-relative import path will not get properly resolved by ng-packagr) * Format code * Adjust aria props to root element * Format code --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Karsa <contact@karsa.org>
111 lines
2.7 KiB
TypeScript
111 lines
2.7 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { render } from '@testing-library/vue';
|
|
|
|
import { airVent } from './testIconNodes';
|
|
import { Icon } from '../src/lucide-vue-next';
|
|
|
|
describe('Using Icon Component', () => {
|
|
it('should render icon based on a iconNode', async () => {
|
|
const { container } = render(Icon, {
|
|
props: {
|
|
iconNode: airVent,
|
|
size: 48,
|
|
color: 'red',
|
|
absoluteStrokeWidth: true,
|
|
},
|
|
});
|
|
|
|
expect(container.firstChild).toBeDefined();
|
|
});
|
|
|
|
it('should render icon and match snapshot', async () => {
|
|
const { container } = render(Icon, {
|
|
props: {
|
|
iconNode: airVent,
|
|
size: 48,
|
|
color: 'red',
|
|
absoluteStrokeWidth: true,
|
|
},
|
|
});
|
|
|
|
expect(container.firstChild).toMatchSnapshot();
|
|
});
|
|
});
|
|
|
|
describe('Icon Component Accessibility', () => {
|
|
it('should have aria-hidden prop when no aria prop is present', async () => {
|
|
const { container } = render(Icon, {
|
|
props: {
|
|
iconNode: airVent,
|
|
size: 48,
|
|
color: '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 } = render(Icon, {
|
|
props: {
|
|
iconNode: airVent,
|
|
size: 48,
|
|
color: 'red',
|
|
absoluteStrokeWidth: true,
|
|
'aria-label': 'Air conditioning',
|
|
},
|
|
});
|
|
|
|
expect(container.firstChild).not.toHaveAttribute('aria-hidden');
|
|
});
|
|
|
|
it('should not have aria-hidden prop when title prop is present', async () => {
|
|
const { container } = render(Icon, {
|
|
props: {
|
|
iconNode: airVent,
|
|
size: 48,
|
|
color: 'red',
|
|
absoluteStrokeWidth: true,
|
|
title: 'Air conditioning',
|
|
},
|
|
});
|
|
|
|
expect(container.firstChild).not.toHaveAttribute('aria-hidden');
|
|
});
|
|
|
|
it('should not have aria-hidden prop when there are children that could be a <title> element', async () => {
|
|
const template = {
|
|
name: 'Stub',
|
|
template: `<title>Some title</title>`,
|
|
};
|
|
const { container } = render(Icon, {
|
|
props: {
|
|
iconNode: airVent,
|
|
size: 48,
|
|
color: 'red',
|
|
absoluteStrokeWidth: true,
|
|
},
|
|
slots: {
|
|
default: template,
|
|
},
|
|
});
|
|
|
|
expect(container.firstChild).not.toHaveAttribute('aria-hidden');
|
|
});
|
|
|
|
it('should never override aria-hidden prop', async () => {
|
|
const { container } = render(Icon, {
|
|
props: {
|
|
iconNode: airVent,
|
|
size: 48,
|
|
color: 'red',
|
|
absoluteStrokeWidth: true,
|
|
'aria-hidden': false,
|
|
},
|
|
});
|
|
|
|
expect(container.firstChild).toHaveAttribute('aria-hidden', 'false');
|
|
});
|
|
});
|