Skip to content

Commit ef0ca15

Browse files
ShaswatPrabhatmdjastrzebski
authored andcommitted
Add tests for labeltext with exact set to false
1 parent 5ce03b7 commit ef0ca15

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/queries/__tests__/labelText.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,24 @@ test('getAllByLabelText, queryAllByLabelText, findAllByLabelText', async () => {
9393
getNoInstancesFoundMessage(NO_MATCHES_TEXT)
9494
);
9595
});
96+
97+
test('getAllByLabelText, queryAllByLabelText, findAllByLabelText with exact as false', async () => {
98+
const { getAllByLabelText, queryAllByLabelText, findAllByLabelText } = render(
99+
<Section />
100+
);
101+
102+
expect(getAllByLabelText(TEXT_LABEL, { exact: false })).toHaveLength(2);
103+
expect(queryAllByLabelText(/cool/g, { exact: false })).toHaveLength(3);
104+
105+
expect(() => getAllByLabelText(NO_MATCHES_TEXT)).toThrow(
106+
getNoInstancesFoundMessage(NO_MATCHES_TEXT)
107+
);
108+
expect(queryAllByLabelText(NO_MATCHES_TEXT, { exact: false })).toEqual([]);
109+
110+
await expect(
111+
findAllByLabelText(TEXT_LABEL, { exact: false })
112+
).resolves.toHaveLength(2);
113+
await expect(
114+
findAllByLabelText(NO_MATCHES_TEXT, { exact: false })
115+
).rejects.toThrow(getNoInstancesFoundMessage(NO_MATCHES_TEXT));
116+
});

0 commit comments

Comments
 (0)