mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-16 10:51:06 +00:00
40 lines
1.6 KiB
JavaScript
40 lines
1.6 KiB
JavaScript
import { render } from '@testing-library/svelte';
|
|
import Component from './Breadcrumb.Story.svelte';
|
|
|
|
describe('Breadcrumb', () => {
|
|
function getLastBreadcrumbItem(container) {
|
|
const breadcrumbItems = container.querySelectorAll('.bx--breadcrumb-item');
|
|
return breadcrumbItems[breadcrumbItems.length - 1];
|
|
}
|
|
|
|
test('default', () => {
|
|
const { getByText, container, rerender } = render(Component, { noTrailingSlash: false });
|
|
const selector = '.bx--breadcrumb--no-trailing-slash';
|
|
expect(getByText('Breadcrumb 1')).toBeInTheDocument();
|
|
expect(getByText('Breadcrumb 2')).toBeInTheDocument();
|
|
expect(getByText('Breadcrumb 3')).toBeInTheDocument();
|
|
expect(container.querySelector(selector)).not.toBeInTheDocument();
|
|
expect(container.innerHTML).toMatchSnapshot();
|
|
|
|
rerender({ props: { noTrailingSlash: true } });
|
|
expect(container.querySelector(selector)).toBeInTheDocument();
|
|
expect(container.innerHTML).toMatchSnapshot();
|
|
});
|
|
|
|
test('skeleton', () => {
|
|
const { container } = render(Component, { story: 'skeleton' });
|
|
expect(container.innerHTML).toMatchSnapshot();
|
|
});
|
|
|
|
test('current page', () => {
|
|
const { container } = render(Component, { story: 'current page' });
|
|
const lastItem = getLastBreadcrumbItem(container);
|
|
expect(lastItem.classList.contains('bx--breadcrumb-item--current')).toEqual(true);
|
|
});
|
|
|
|
test('current page with aria-current', () => {
|
|
const { container } = render(Component, { story: 'current page with aria-current' });
|
|
const lastItem = getLastBreadcrumbItem(container);
|
|
expect(lastItem.querySelector('[aria-current="page"]')).toBeTruthy();
|
|
});
|
|
});
|