-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7af7971
commit 7862897
Showing
1 changed file
with
42 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,42 @@ | ||
import * as React from 'react'; | ||
import {Header} from '../header'; | ||
import {makeTheme} from './test-utils'; | ||
import {render, screen} from '@testing-library/react'; | ||
import ThemeContextProvider from '../theme-context-provider'; | ||
|
||
const pretitleFirst = 'HeadlinePretitleTitleDescription'; | ||
const titleFirst = 'HeadlineTitlePretitleDescription'; | ||
|
||
test.each` | ||
pretitleAs | titleAs | expectedOrder | ||
${undefined} | ${undefined} | ${titleFirst} | ||
${undefined} | ${'span'} | ${titleFirst} | ||
${undefined} | ${'h1'} | ${titleFirst} | ||
${'span'} | ${undefined} | ${titleFirst} | ||
${'h3'} | ${undefined} | ${titleFirst} | ||
${'h3'} | ${'h1'} | ${titleFirst} | ||
${'span'} | ${'h1'} | ${titleFirst} | ||
${'h1'} | ${undefined} | ${pretitleFirst} | ||
${'h1'} | ${'h3'} | ${pretitleFirst} | ||
${'h1'} | ${'span'} | ${pretitleFirst} | ||
`( | ||
'Header has correct reading order with pretitleAs={$pretitleAs} and titleAs={$titleAs}', | ||
async ({pretitleAs, titleAs, expectedOrder}) => { | ||
render( | ||
<ThemeContextProvider theme={makeTheme()}> | ||
<Header | ||
headline="Headline" | ||
pretitle="Pretitle" | ||
title="Title" | ||
description="Description" | ||
titleAs={titleAs} | ||
pretitleAs={pretitleAs} | ||
dataAttributes={{testid: 'header'}} | ||
/> | ||
</ThemeContextProvider> | ||
); | ||
|
||
const header = await screen.findByTestId('header'); | ||
expect(header.textContent).toEqual(expectedOrder); | ||
} | ||
); |