-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "fixup! Feat: Add alert role for ValidationText #DS-1175"
This reverts commit 3d24876.
- Loading branch information
Showing
2 changed files
with
13 additions
and
21 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
22 changes: 8 additions & 14 deletions
22
packages/web-react/src/components/Field/__tests__/ValidationText.test.tsx
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 |
---|---|---|
@@ -1,32 +1,26 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { render } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import ValidationText from '../ValidationText'; | ||
|
||
describe('ValidationText', () => { | ||
it('should render single validation text', () => { | ||
const { container } = render( | ||
<ValidationText className="ValidationText__validationText" validationText="validation text" />, | ||
); | ||
const dom = render(<ValidationText className="ValidationText__validationText" validationText="validation text" />); | ||
|
||
expect(container.textContent).toBe('validation text'); | ||
expect(container.firstElementChild).toHaveAttribute('role', 'alert'); | ||
const element = dom.container.querySelector('div') as HTMLElement; | ||
expect(element.textContent).toBe('validation text'); | ||
}); | ||
|
||
it('should render multiple validation texts', () => { | ||
render( | ||
const dom = render( | ||
<ValidationText | ||
className="ValidationText__validationText" | ||
validationText={['validation text', 'another validation text']} | ||
/>, | ||
); | ||
|
||
const list = screen.getByRole('list'); | ||
const listItems = screen.getAllByRole('listitem'); | ||
|
||
expect(listItems[0].textContent).toBe('validation text'); | ||
expect(listItems[1].textContent).toBe('another validation text'); | ||
|
||
expect(list.parentElement).toHaveAttribute('role', 'alert'); | ||
const elements = dom.container.querySelectorAll('li') as NodeListOf<HTMLLIElement>; | ||
expect(elements[0].textContent).toBe('validation text'); | ||
expect(elements[1].textContent).toBe('another validation text'); | ||
}); | ||
}); |