Skip to content

Commit a70a3a5

Browse files
test(components): add accessibilityState merge regression tests for Input/TextArea
Covers #221's fix (now merged): a caller-supplied accessibilityState merges with the component's own computed disabled value, with disabled winning on conflict. One consolidated test per component rather than separate #217/#220 tests, since they're one fix now. Verified each test fails against its respective pre-#221 source (Input's original no-merge-at-all code, TextArea's original caller-wins-on-conflict code) and passes against the fix.
1 parent fdbd197 commit a70a3a5

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

packages/components/src/components/Input/Input.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ describe("Input", () => {
6666
expect(input).toHaveProp("accessibilityState", { disabled: false });
6767
});
6868

69+
it("merges a caller-supplied accessibilityState, with the component's own disabled value winning on conflict", () => {
70+
render(
71+
<Input
72+
accessibilityState={{ selected: true, disabled: true }}
73+
placeholder="Type here"
74+
/>
75+
);
76+
expect(screen.getByPlaceholderText("Type here")).toHaveProp(
77+
"accessibilityState",
78+
{ selected: true, disabled: false }
79+
);
80+
});
81+
6982
it("calls the user-provided onFocus and onBlur handlers", () => {
7083
const onFocus = jest.fn();
7184
const onBlur = jest.fn();

packages/components/src/components/TextArea/TextArea.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,19 @@ describe("TextArea", () => {
8686
expect(input).toHaveProp("accessibilityState", { disabled: false });
8787
});
8888

89+
it("merges a caller-supplied accessibilityState, with the component's own disabled value winning on conflict", () => {
90+
render(
91+
<TextArea
92+
accessibilityState={{ selected: true, disabled: true }}
93+
defaultValue="hi"
94+
/>
95+
);
96+
expect(screen.getByDisplayValue("hi")).toHaveProp(
97+
"accessibilityState",
98+
{ selected: true, disabled: false }
99+
);
100+
});
101+
89102
it("defaults accessibilityHint to the joined description and helperMessage", () => {
90103
render(
91104
<TextArea

0 commit comments

Comments
 (0)