import { Typography } from '../common'; import { render, screen } from '../test-utils'; import Title from '.'; describe('Title', () => { it('testing default state', () => { render(Test); const copy = screen.getByText('Test'); expect(copy).toBeInTheDocument(); expect(copy.tagName).toBe('H5'); expect(copy).toHaveClass(`np-text-${Typography.TITLE_GROUP}`); }); it('enforces tag via `as` prop', () => { render(Test); const copy = screen.getByText('Test'); expect(copy).toBeInTheDocument(); expect(copy.tagName).toBe('SPAN'); expect(copy).toHaveClass(`np-text-${Typography.TITLE_GROUP}`); }); it('supports native HTML attrs', () => { render( Test , ); const copy = screen.getByText('Test'); expect(copy).toBeInTheDocument(); expect(copy).toHaveAttribute('id', 'test-id'); expect(copy).toHaveAttribute('role', 'banner'); }); it('handles unsupported typography type', () => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error render(Test); const copy = screen.getByText('Test'); expect(copy).toBeInTheDocument(); expect(copy.tagName).toBe('H5'); expect(copy).toHaveClass(`np-text-${Typography.TITLE_GROUP}`); }); });