import * as React from 'react' import { render } from '@testing-library/react' import { Heading, type AllowedHeadingTags, type HeadingVariants } from '.' describe('', () => { it('changes rendered HTML element when passed tag', () => { const headingMock = render( Example , ) expect(headingMock.getByText('Example').tagName).toBe('DIV') }) it('passes through data attributes', () => { const { getByTestId } = render( Example , ) expect(getByTestId('test-id')).toBeInTheDocument() }) describe('defaults to the correct HTML element', () => { type TestObject = { variant: HeadingVariants; el: AllowedHeadingTags } const testCases: TestObject[] = [ { variant: 'display-0', el: 'h1' }, { variant: 'heading-1', el: 'h1' }, { variant: 'heading-2', el: 'h2' }, { variant: 'heading-3', el: 'h3' }, { variant: 'heading-4', el: 'h4' }, { variant: 'heading-5', el: 'h5' }, { variant: 'heading-6', el: 'h6' }, ] testCases.forEach(({ variant, el }) => { it(`renders the correct element for `, () => { const headingMock = render(Example) expect(headingMock.getByText('Example').tagName.toLowerCase()).toBe(el) }) }) }) it('allows consumers to provide a className', () => { const { getByText } = render( Example , ) expect(getByText('Example').classList).toContain('example-classname') }) })