diff --git a/packages/web-react/src/components/Field/__tests__/ValidationText.test.tsx b/packages/web-react/src/components/Field/__tests__/ValidationText.test.tsx index bfbe9fc6be..5734515c45 100644 --- a/packages/web-react/src/components/Field/__tests__/ValidationText.test.tsx +++ b/packages/web-react/src/components/Field/__tests__/ValidationText.test.tsx @@ -13,20 +13,27 @@ describe('ValidationText', () => { expect(container.firstElementChild).toHaveAttribute('role', 'alert'); }); - it('should render multiple validation texts', () => { - render( - , - ); + describe('should render multiple validation texts', () => { + beforeEach(() => { + render( + , + ); + }); + + it('should render list wrapper with alert role', () => { + const list = screen.getByRole('list'); - const list = screen.getByRole('list'); - const listItems = screen.getAllByRole('listitem'); + expect(list.parentElement).toHaveAttribute('role', 'alert'); + }); - expect(listItems[0].textContent).toBe('validation text'); - expect(listItems[1].textContent).toBe('another validation text'); + it('should render correct validation texts for list items', () => { + const listItems = screen.getAllByRole('listitem'); - expect(list.parentElement).toHaveAttribute('role', 'alert'); + expect(listItems[0]).toHaveTextContent('validation text'); + expect(listItems[1]).toHaveTextContent('another validation text'); + }); }); });