Skip to content

Commit acb5f65

Browse files
authored
added driver implementation and test (#3786)
1 parent f54b476 commit acb5f65

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/components/button/Button.driver.new.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@ export const ButtonDriver = (props: ComponentProps) => {
3434
return StyleSheet.flatten(driver.getElement().props.style);
3535
};
3636

37-
return {getStyle, getLabel, getLabelStyle, getIconStyle, getIcon, ...driver};
37+
const isDisabled = () => {
38+
return !!driver.getElement().props.accessibilityState?.disabled;
39+
};
40+
41+
return {getStyle, getLabel, getLabelStyle, getIconStyle, getIcon, isDisabled, ...driver};
3842
};

src/components/button/__tests__/index.driver.spec.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ describe('Button', () => {
6666
buttonDriver.press();
6767
await waitFor(() => expect(onPressCallback).toHaveBeenCalledTimes(0));
6868
});
69+
it.each([true, false])(`button should be disabled when disabled is %s`, (disabled) => {
70+
const renderTree = render(<WrapperScreenWithButton disabled={disabled}/>);
71+
const buttonDriver = ButtonDriver({renderTree, testID: 'button_test_id'});
72+
expect(buttonDriver.isDisabled()).toBe(disabled);
73+
});
6974
});
7075

7176
describe('label', () => {

0 commit comments

Comments
 (0)