Skip to content

Commit

Permalink
test: add heading1 test
Browse files Browse the repository at this point in the history
To ensure the tsconfig.test.json is not causing issues after Button.test.ts was removed

It also allows us to test if the Utrecht Heading1 component is behaving as expected
  • Loading branch information
Yolijn committed May 29, 2024
1 parent 9f66f30 commit 3d196f3
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions packages/components-react/src/heading1.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { render, screen } from '@testing-library/react';
import { Heading1 } from '@utrecht/component-library-react';
import '@testing-library/jest-dom';

describe('Heading1', () => {
it('renders a heading role element', () => {
render(<Heading1>Hello World</Heading1>);

const heading1 = screen.getByRole('heading', {
name: 'Hello World',
});

expect(heading1).toBeInTheDocument();
expect(heading1).toBeVisible();
});

it('renders an HTML h1 element', () => {
const { container } = render(<Heading1>Hello World</Heading1>);

const heading1 = container.querySelector('h1:only-child');

expect(heading1).toBeInTheDocument();
});

it('renders labels that contain HTML rich text content', () => {
const { container } = render(
<Heading1>
Hello <strong>World</strong>
</Heading1>,
);

const heading1 = container.querySelector(':only-child');

const richText = heading1?.querySelector('strong');

expect(richText).toBeInTheDocument();
});
});

0 comments on commit 3d196f3

Please sign in to comment.