Skip to content

Commit c88ba76

Browse files
committed
chore: tweak fo
1 parent ce969d4 commit c88ba76

File tree

8 files changed

+23
-23
lines changed

8 files changed

+23
-23
lines changed

src/helpers/format-default.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { StyleSheet, ViewStyle } from 'react-native';
22

33
const propsToDisplay = [
4+
'accessible',
45
'accessibilityElementsHidden',
56
'accessibilityHint',
67
'accessibilityLabel',
@@ -23,9 +24,7 @@ const propsToDisplay = [
2324
'testID',
2425
'title',
2526
'value',
26-
];
27-
28-
const stylePropsToDisplay = ['display', 'opacity'] as const;
27+
] as const;
2928

3029
/**
3130
* Preserve props that are helpful in diagnosing test failures, while stripping rest
@@ -87,14 +86,14 @@ function extractStyle(style: ViewStyle | undefined) {
8786
}
8887

8988
const result: Record<string, unknown> = {};
90-
let hasAnyStyle = false;
89+
if (style.display === 'none') {
90+
result.display = 'none';
91+
}
9192

92-
stylePropsToDisplay.forEach((styleProp) => {
93-
if (styleProp in style) {
94-
result[styleProp] = style[styleProp];
95-
hasAnyStyle = true;
96-
}
97-
});
93+
if (style.opacity === 0) {
94+
result.opacity = 0;
95+
}
9896

99-
return hasAnyStyle ? result : undefined;
97+
const hasAnyKeys = Object.keys(result).length > 0;
98+
return hasAnyKeys ? result : undefined;
10099
}

src/matchers/__tests__/to-be-disabled.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ test('toBeDisabled/toBeEnabled works with disabled Pressable', () => {
5757
"disabled": true,
5858
}
5959
}
60+
accessible={true}
6061
testID="subject"
6162
/>"
6263
`);
@@ -72,6 +73,7 @@ test('toBeDisabled/toBeEnabled works with disabled Pressable', () => {
7273
"disabled": true,
7374
}
7475
}
76+
accessible={true}
7577
testID="subject"
7678
/>"
7779
`);

src/matchers/__tests__/to-be-visible.test.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ test('toBeVisible() on view with opacity', () => {
3030
3131
Received element is visible:
3232
<View
33-
style={
34-
{
35-
"opacity": 0.2,
36-
}
37-
}
3833
testID="view"
3934
/>"
4035
`);

src/queries/__tests__/a11yState.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ test('byA11yState queries support hidden option', () => {
263263
"expanded": false,
264264
}
265265
}
266+
accessible={true}
266267
style={
267268
{
268269
"display": "none",

src/queries/__tests__/hintText.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ test('error message renders the element tree, preserving only helpful props', as
145145
146146
<View
147147
accessibilityHint="HINT"
148+
accessible={true}
148149
/>"
149150
`);
150151

@@ -154,6 +155,7 @@ test('error message renders the element tree, preserving only helpful props', as
154155
155156
<View
156157
accessibilityHint="HINT"
158+
accessible={true}
157159
/>"
158160
`);
159161

@@ -163,6 +165,7 @@ test('error message renders the element tree, preserving only helpful props', as
163165
164166
<View
165167
accessibilityHint="HINT"
168+
accessible={true}
166169
/>"
167170
`);
168171

@@ -172,6 +175,7 @@ test('error message renders the element tree, preserving only helpful props', as
172175
173176
<View
174177
accessibilityHint="HINT"
178+
accessible={true}
175179
/>"
176180
`);
177181
});

src/queries/__tests__/labelText.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ test('error message renders the element tree, preserving only helpful props', as
259259
260260
<View
261261
accessibilityLabel="LABEL"
262+
accessible={true}
262263
/>"
263264
`);
264265

@@ -268,6 +269,7 @@ test('error message renders the element tree, preserving only helpful props', as
268269
269270
<View
270271
accessibilityLabel="LABEL"
272+
accessible={true}
271273
/>"
272274
`);
273275

@@ -277,6 +279,7 @@ test('error message renders the element tree, preserving only helpful props', as
277279
278280
<View
279281
accessibilityLabel="LABEL"
282+
accessible={true}
280283
/>"
281284
`);
282285

@@ -286,6 +289,7 @@ test('error message renders the element tree, preserving only helpful props', as
286289
287290
<View
288291
accessibilityLabel="LABEL"
292+
accessible={true}
289293
/>"
290294
`);
291295
});

src/queries/__tests__/makeQueries.test.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,7 @@ describe('printing element tree', () => {
171171
expect(() => getByText(/foo/)).toThrowErrorMatchingInlineSnapshot(`
172172
"Unable to find an element with text: /foo/
173173
174-
<View
175-
style={
176-
{
177-
"display": "flex",
178-
}
179-
}
180-
>
174+
<View>
181175
<Text
182176
style={
183177
{

src/queries/__tests__/role.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,7 @@ test('byRole queries support hidden option', () => {
919919
920920
<View
921921
accessibilityRole="button"
922+
accessible={true}
922923
style={
923924
{
924925
"display": "none",

0 commit comments

Comments
 (0)