generated from nl-design-system/example
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |