Skip to content

Commit

Permalink
Adds Alert story using validation prop and unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
kleinschmidtj committed Jul 20, 2023
1 parent 3230085 commit 7a6a963
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/Alert/Alert.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,12 @@ export const withCTA = (): React.ReactElement => (
{testText}
</Alert>
)

export const withValidation = (): React.ReactElement => (
<Alert type="info" heading="Code requirements" headingLevel="h4" validation>
<ul>
<li>Use at least one uppercase character</li>
<li>Use at least one number</li>
</ul>
</Alert>
)
15 changes: 15 additions & 0 deletions src/components/Alert/Alert.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ describe('Alert component', () => {
expect(queryByTestId('alert')).toContainHTML('p')
})

it('renders custom children with validation prop', () => {
const { queryByTestId } = render(
<Alert type="success" headingLevel="h4" validation>
<ul>
<li>test 1</li>
<li>test 2</li>
</ul>
</Alert>
)
expect(queryByTestId('alert')).toHaveTextContent('test 1test 2')
expect(queryByTestId('alert')).toContainHTML('ul')
expect(queryByTestId('alert')).toContainHTML('li')
expect(queryByTestId('alert')).not.toContainHTML('p')
})

it('renders validation style alert', () => {
const { queryByTestId } = render(
<Alert type="success" validation headingLevel="h4" className="myClass">
Expand Down

0 comments on commit 7a6a963

Please sign in to comment.