import React from 'react' import { render, screen } from '@testing-library/react' import { Icon } from './Icon' describe('', () => { it('sets required attributes for a presentational icon', () => { render() const icon = screen.getByTestId('test__icon') expect(icon).toHaveAttribute('aria-hidden', 'true') expect(icon).not.toHaveAttribute('role') expect(icon).not.toHaveAttribute('aria-label') }) it('sets required attributes for a meaningful icon', () => { render() const icon = screen.getByTestId('test__icon') expect(icon).not.toHaveAttribute('aria-hidden') expect(icon).toHaveAttribute('role', 'img') expect(icon).toHaveAttribute('aria-label', 'Favourite') }) describe('shouldMirrorInRTL', () => { it('does not show icon name in accessible name for switched icons', () => { render( , ) const button = screen.getByRole('button') expect(button).toHaveAccessibleName('Pancakes') }) }) })