mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-17 14:28:25 +00:00
* Add Lucide React integration tests * Apply batched suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Remove redundant icon comparison test Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * test(lucide-react): fix browser locator markup assertions --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
53 lines
2.2 KiB
TypeScript
53 lines
2.2 KiB
TypeScript
import { expect, test } from 'vitest';
|
|
import { render } from 'vitest-browser-react';
|
|
import { MemoryRouter, Route, Routes } from 'react-router';
|
|
import About from '../app/routes/about';
|
|
import Home from '../app/routes/home';
|
|
|
|
test('renders Lucide public APIs and survives router navigation', async () => {
|
|
const screen = await render(
|
|
<MemoryRouter initialEntries={['/']}>
|
|
<Routes>
|
|
<Route
|
|
element={<Home />}
|
|
path="/"
|
|
/>
|
|
<Route
|
|
element={<About />}
|
|
path="/about"
|
|
/>
|
|
</Routes>
|
|
</MemoryRouter>,
|
|
);
|
|
|
|
const staticIcon = screen.getByTestId('static-icon');
|
|
await expect.element(staticIcon).toBeVisible();
|
|
await expect.element(staticIcon).toHaveAttribute('width', '24');
|
|
await expect.element(staticIcon).toHaveAttribute('height', '24');
|
|
await expect.element(staticIcon).toHaveAttribute('viewBox', '0 0 24 24');
|
|
await expect.element(staticIcon).toHaveAttribute('aria-hidden', 'true');
|
|
|
|
const customIcon = screen.getByTestId('custom-icon');
|
|
await expect.element(customIcon).toBeVisible();
|
|
await expect.element(customIcon).toHaveAttribute('width', '48');
|
|
const aliasIcon = screen.getByTestId('alias-icon');
|
|
const canonicalIcon = screen.getByTestId('canonical-icon');
|
|
await expect.element(aliasIcon).toBeVisible();
|
|
await expect.element(canonicalIcon).toBeVisible();
|
|
expect(aliasIcon.element().innerHTML).toBe(canonicalIcon.element().innerHTML);
|
|
await expect.element(customIcon).toHaveClass('consumer-icon');
|
|
|
|
const providerIcon = screen.getByTestId('provider-icon');
|
|
await expect.element(providerIcon).toHaveAttribute('width', '32');
|
|
await expect.element(providerIcon).toHaveAttribute('stroke', 'purple');
|
|
await expect.element(providerIcon).toHaveAttribute('stroke-width', '3');
|
|
|
|
const dynamicIcon = screen.getByTestId('dynamic-icon');
|
|
await expect.element(dynamicIcon).toBeVisible();
|
|
await expect.element(dynamicIcon).toHaveAttribute('aria-label', 'Dynamic circle');
|
|
await expect.element(dynamicIcon).not.toHaveAttribute('aria-hidden');
|
|
|
|
await screen.getByRole('link', { name: 'About' }).click();
|
|
await expect.element(screen.getByTestId('route-icon')).toBeVisible();
|
|
});
|