import { test, expect } from 'vitest';
import { render, screen, within } from '@testing-library/react';
import CategoryList from './CategoryList';
import CategoryItem from '../CategoryItem';
test('category list renders correctly', () => {
render(
Find information about local travel by road, rail and water and National Entitlement Cards.
Find out about getting a disabled parking space and information on Blue Badges.
How to apply to court to reduce your driving ban. Includes who can apply and how much it costs.
Find out about the drink-drive limit, how to stay safe on the roads and what to do if you receive parking tickets.
);
const categoryList = screen.getByRole('list');
expect(categoryList).toHaveClass('ds_category-list');
expect(categoryList).not.toHaveClass('ds_category-list--grid');
expect(categoryList.tagName).toEqual('UL');
const child = within(categoryList).getByTestId('category-item');
expect(child.tagName).toEqual('LI');
});
test('ordered category list', () => {
render(
);
const categoryList = screen.getByRole('list');
expect(categoryList.tagName).toEqual('OL');
});
test('grid category list', () => {
render(
);
const categoryList = screen.getByRole('list');
expect(categoryList).toHaveClass('ds_category-list--grid');
});
test('passing additional props', () => {
render(
);
const categoryList = screen.getByRole('list');
expect(categoryList.dataset.test).toEqual('foo');
});
test('passing additional CSS classes', () => {
render(
);
const categoryList = screen.getByRole('list');
expect(categoryList).toHaveClass('foo');
});