Skip to content

Commit

Permalink
fix: test composite for TextInput
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoChollet committed Dec 9, 2022
1 parent 1a960b5 commit efbfca6
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/__tests__/to-be-disabled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,23 @@ describe('.toBeDisabled', () => {
});

test('handle editable prop for TextInput', () => {
const { getByTestId } = render(
const { getByTestId, getByPlaceholderText } = render(
<View>
<TextInput testID="disabled" editable={false} />
<TextInput testID="enabled-by-default" />
<TextInput testID="enabled" editable />
<TextInput testID="disabled" placeholder="disabled" editable={false} />
<TextInput testID="enabled-by-default" placeholder="enabled-by-default" />
<TextInput testID="enabled" placeholder="enabled" editable />
</View>,
);

// Check host TextInput
expect(getByTestId('disabled')).toBeDisabled();
expect(getByTestId('enabled-by-default')).not.toBeDisabled();
expect(getByTestId('enabled')).not.toBeDisabled();

// Check composite TextInput
expect(getByPlaceholderText('disabled')).toBeDisabled();
expect(getByPlaceholderText('enabled-by-default')).not.toBeDisabled();
expect(getByPlaceholderText('enabled')).not.toBeDisabled();
});
});

Expand Down Expand Up @@ -95,17 +101,23 @@ describe('.toBeEnabled', () => {
});

test('handle editable prop for TextInput', () => {
const { getByTestId } = render(
const { getByTestId, getByPlaceholderText } = render(
<View>
<TextInput testID="enabled-by-default" />
<TextInput testID="enabled" editable />
<TextInput testID="disabled" editable={false} />
<TextInput testID="enabled-by-default" placeholder="enabled-by-default" />
<TextInput testID="enabled" placeholder="enabled" editable />
<TextInput testID="disabled" placeholder="disabled" editable={false} />
</View>,
);

// Check host TextInput
expect(getByTestId('enabled-by-default')).toBeEnabled();
expect(getByTestId('enabled')).toBeEnabled();
expect(getByTestId('disabled')).not.toBeEnabled();

// Check composite TextInput
expect(getByPlaceholderText('enabled-by-default')).toBeEnabled();
expect(getByPlaceholderText('enabled')).toBeEnabled();
expect(getByPlaceholderText('disabled')).not.toBeEnabled();
});
});

Expand Down

0 comments on commit efbfca6

Please sign in to comment.