Skip to content

Commit 48c5b41

Browse files
committed
refactor: tweaks
1 parent d33b9aa commit 48c5b41

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/queries/__tests__/labelText.test.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ const TEXT_HINT = 'static text';
1010
const NO_MATCHES_TEXT: any = 'not-existent-element';
1111

1212
const getMultipleInstancesFoundMessage = (value: string) => {
13-
return `Found multiple elements with aria-label or accessibilityLabel: ${value}`;
13+
return `Found multiple elements with accessibility label: ${value}`;
1414
};
1515

1616
const getNoInstancesFoundMessage = (value: string) => {
17-
return `Unable to find an element with aria-label or accessibilityLabel: ${value}`;
17+
return `Unable to find an element with accessibility label: ${value}`;
1818
};
1919

2020
const Typography = ({ children, ...rest }: any) => {
@@ -161,7 +161,7 @@ test('byLabelText queries support hidden option', () => {
161161
).toBeFalsy();
162162
expect(() => getByLabelText('hidden', { includeHiddenElements: false }))
163163
.toThrowErrorMatchingInlineSnapshot(`
164-
"Unable to find an element with aria-label or accessibilityLabel: hidden
164+
"Unable to find an element with accessibility label: hidden
165165
166166
<Text
167167
accessibilityLabel="hidden"
@@ -258,7 +258,7 @@ test('error message renders the element tree, preserving only helpful props', as
258258
const view = render(<TouchableOpacity accessibilityLabel="LABEL" key="3" />);
259259

260260
expect(() => view.getByLabelText('FOO')).toThrowErrorMatchingInlineSnapshot(`
261-
"Unable to find an element with aria-label or accessibilityLabel: FOO
261+
"Unable to find an element with accessibility label: FOO
262262
263263
<View
264264
accessibilityLabel="LABEL"
@@ -267,7 +267,7 @@ test('error message renders the element tree, preserving only helpful props', as
267267

268268
expect(() => view.getAllByLabelText('FOO'))
269269
.toThrowErrorMatchingInlineSnapshot(`
270-
"Unable to find an element with aria-label or accessibilityLabel: FOO
270+
"Unable to find an element with accessibility label: FOO
271271
272272
<View
273273
accessibilityLabel="LABEL"
@@ -276,7 +276,7 @@ test('error message renders the element tree, preserving only helpful props', as
276276

277277
await expect(view.findByLabelText('FOO')).rejects
278278
.toThrowErrorMatchingInlineSnapshot(`
279-
"Unable to find an element with aria-label or accessibilityLabel: FOO
279+
"Unable to find an element with accessibility label: FOO
280280
281281
<View
282282
accessibilityLabel="LABEL"
@@ -285,7 +285,7 @@ test('error message renders the element tree, preserving only helpful props', as
285285

286286
await expect(view.findAllByLabelText('FOO')).rejects
287287
.toThrowErrorMatchingInlineSnapshot(`
288-
"Unable to find an element with aria-label or accessibilityLabel: FOO
288+
"Unable to find an element with accessibility label: FOO
289289
290290
<View
291291
accessibilityLabel="LABEL"

src/queries/labelText.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,9 @@ function queryAllByLabelText(instance: ReactTestInstance) {
2626
}
2727

2828
const getMultipleError = (labelText: TextMatch) =>
29-
`Found multiple elements with aria-label or accessibilityLabel: ${String(
30-
labelText
31-
)} `;
29+
`Found multiple elements with accessibility label: ${String(labelText)} `;
3230
const getMissingError = (labelText: TextMatch) =>
33-
`Unable to find an element with aria-label or accessibilityLabel: ${String(
34-
labelText
35-
)}`;
31+
`Unable to find an element with accessibility label: ${String(labelText)}`;
3632

3733
const { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(
3834
queryAllByLabelText,

0 commit comments

Comments
 (0)