import { render, screen, within } from '../test-utils'; import InstructionsList from '.'; describe('InstructionsList', () => { it('should render with custom class', () => { render(); expect(screen.getByRole('list')).toHaveClass('foo'); }); it('should render dos list only', () => { const dos = ['Test this component', 'With multiple dos']; render(); expect(screen.getByText(dos[0])).toBeInTheDocument(); expect(screen.getByText(dos[1])).toBeInTheDocument(); }); it('should render donts list only', () => { const donts = ['Card validation', 'ID verification']; render(); expect(screen.getByText(donts[0])).toBeInTheDocument(); expect(screen.getByText(donts[1])).toBeInTheDocument(); }); it('should render do/dont lists with description for icons', () => { const dos = [{ content: 'Card validation', 'aria-label': 'Provides card validation' }]; const donts = [{ content: 'ID verification', 'aria-label': 'No ID verification' }]; const { container } = render(); expect(screen.getByText(dos[0].content)).toBeInTheDocument(); expect(screen.getByText(donts[0].content)).toBeInTheDocument(); const instructions = container.querySelectorAll('.instruction'); expect(instructions).toHaveLength(2); expect( within(instructions[0] as HTMLElement).getByRole('graphics-symbol', { name: dos[0]['aria-label'], }), ).toBeInTheDocument(); expect( within(instructions[1] as HTMLElement).getByRole('graphics-symbol', { name: donts[0]['aria-label'], }), ).toBeInTheDocument(); }); it('should render donts first when sort is set to `dontsFirst`', () => { const dos = [{ content: 'Card validation', 'aria-label': 'Provides card validation' }]; const donts = [{ content: 'ID verification', 'aria-label': 'No ID verification' }]; const { container } = render(); expect(screen.getByText(dos[0].content)).toBeInTheDocument(); expect(screen.getByText(donts[0].content)).toBeInTheDocument(); const instructions = container.querySelectorAll('.instruction'); expect(instructions).toHaveLength(2); expect( within(instructions[0] as HTMLElement).getByRole('graphics-symbol', { name: donts[0]['aria-label'], }), ).toBeInTheDocument(); expect( within(instructions[1] as HTMLElement).getByRole('graphics-symbol', { name: dos[0]['aria-label'], }), ).toBeInTheDocument(); }); });