Skip to content

Commit 8e1a08b

Browse files
committed
fix: improve accessible queries
1 parent 2d27ce0 commit 8e1a08b

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/components/CriterionContainer/index.test.jsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ jest.unmock('react');
1111
jest.unmock('@edx/frontend-platform/i18n');
1212

1313
jest.mock('components/InfoPopover', () => ({ children }) => (
14-
<div data-testid="info-popover">{children}</div>
14+
<div role="tooltip">{children}</div>
1515
));
1616

1717
describe('<CriterionContainer />', () => {
1818
const props = {
19-
input: <div data-testid="input">input</div>,
20-
feedback: <div data-testid="feedback">feedback</div>,
19+
input: <div>input</div>,
20+
feedback: <div>feedback</div>,
2121
criterion: {
2222
name: 'criterionName',
2323
description: 'description',
@@ -41,16 +41,14 @@ describe('<CriterionContainer />', () => {
4141

4242
expect(screen.getByText('criterionName')).toBeInTheDocument();
4343

44-
expect(screen.getByTestId('info-popover')).toHaveTextContent('description');
44+
expect(screen.getByRole('tooltip')).toHaveTextContent('description');
4545

4646
expect(screen.getByText('Option 1')).toBeInTheDocument();
4747
expect(screen.getByText('description1')).toBeInTheDocument();
4848
expect(screen.getByText('Option 2')).toBeInTheDocument();
4949
expect(screen.getByText('description2')).toBeInTheDocument();
5050

51-
expect(screen.getByTestId('input')).toBeInTheDocument();
5251
expect(screen.getByText('input')).toBeInTheDocument();
53-
expect(screen.getByTestId('feedback')).toBeInTheDocument();
5452
expect(screen.getByText('feedback')).toBeInTheDocument();
5553
});
5654

@@ -59,11 +57,11 @@ describe('<CriterionContainer />', () => {
5957

6058
expect(screen.getByText('criterionName')).toBeInTheDocument();
6159

62-
expect(screen.getByTestId('info-popover')).toHaveTextContent('description');
60+
expect(screen.getByRole('tooltip')).toHaveTextContent('description');
6361
expect(screen.getByText('Option 1')).toBeInTheDocument();
6462
expect(screen.getByText('Option 2')).toBeInTheDocument();
6563

66-
expect(screen.queryByTestId('input')).not.toBeInTheDocument();
67-
expect(screen.queryByTestId('feedback')).not.toBeInTheDocument();
64+
expect(screen.queryByText('input')).not.toBeInTheDocument();
65+
expect(screen.queryByText('feedback')).not.toBeInTheDocument();
6866
});
6967
});

0 commit comments

Comments
 (0)