mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-11 13:28:19 +00: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>
106 lines
2.7 KiB
TypeScript
106 lines
2.7 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { render } from '@testing-library/svelte';
|
|
import Icon from '../src/Icon.svelte';
|
|
import TestSlotsTitle from './TestSlotsTitle.svelte';
|
|
|
|
import { airVent } from './testIconNodes.js';
|
|
|
|
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 { container } = render(TestSlotsTitle, {
|
|
props: {
|
|
iconNode: airVent,
|
|
size: 48,
|
|
color: 'red',
|
|
absoluteStrokeWidth: true,
|
|
'aria-label': 'Air conditioning',
|
|
},
|
|
});
|
|
|
|
expect(container.firstChild).not.toHaveAttribute('aria-hidden');
|
|
});
|
|
|
|
it('should 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');
|
|
});
|
|
});
|