Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow to fully override testID in TextInput #3405

Merged
merged 1 commit into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/TextInput/TextInputFlat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const TextInputFlat = ({
left,
right,
placeholderTextColor,
testID = 'text-input',
testID = 'text-input-flat',
...rest
}: ChildTextInputProps) => {
const isAndroid = Platform.OS === 'android';
Expand Down Expand Up @@ -339,7 +339,7 @@ const TextInputFlat = ({
)}
<InputLabel parentState={parentState} labelProps={labelProps} />
{render?.({
testID: `${testID}-flat`,
testID,
...rest,
ref: innerRef,
onChangeText,
Expand Down
4 changes: 2 additions & 2 deletions src/components/TextInput/TextInputOutlined.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const TextInputOutlined = ({
left,
right,
placeholderTextColor,
testID = 'text-input',
testID = 'text-input-outlined',
...rest
}: ChildTextInputProps) => {
const adornmentConfig = getAdornmentConfig({ left, right });
Expand Down Expand Up @@ -311,7 +311,7 @@ const TextInputOutlined = ({
maxFontSizeMultiplier={rest.maxFontSizeMultiplier}
/>
{render?.({
testID: `${testID}-outlined`,
testID,
...rest,
ref: innerRef,
onChangeText,
Expand Down
8 changes: 4 additions & 4 deletions src/components/__tests__/TextInput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ it('renders label with correct color when active', () => {
placeholder="Type something"
value={'Some test value'}
onChangeText={(text) => this.setState({ text })}
testID={'text-input'}
testID={'text-input-flat'}
/>
);

fireEvent(getByTestId('text-input-flat'), 'focus');

expect(getByTestId('text-input-label-active')).toHaveStyle({
expect(getByTestId('text-input-flat-label-active')).toHaveStyle({
color: getTheme().colors.primary,
});
});
Expand All @@ -220,7 +220,7 @@ it('renders input placeholder initially with an empty space character', () => {
<TextInput multiline label="Multiline input" testID={'text-input'} />
);

expect(getByTestId('text-input-flat').props.placeholder).toBe(' ');
expect(getByTestId('text-input').props.placeholder).toBe(' ');
});

it('correctly applies padding offset to input label on Android when RTL', () => {
Expand Down Expand Up @@ -278,7 +278,7 @@ it('correctly applies padding offset to input label on Android when LTR', () =>
mode={mode}
multiline
label="Flat input"
testID={'text-input'}
testID={`text-input-${mode}`}
style={style.lineHeight}
/>
);
Expand Down
24 changes: 12 additions & 12 deletions src/components/__tests__/__snapshots__/TextInput.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ exports[`correctly applies a component as the text label 1`] = `
"writingDirection": "ltr",
}
}
testID="text-input-label-active"
testID="text-input-flat-label-active"
>
<Text
style={
Expand Down Expand Up @@ -144,7 +144,7 @@ exports[`correctly applies a component as the text label 1`] = `
"writingDirection": "ltr",
}
}
testID="text-input-label-inactive"
testID="text-input-flat-label-inactive"
>
<Text
style={
Expand Down Expand Up @@ -307,7 +307,7 @@ exports[`correctly applies default textAlign based on default RTL 1`] = `
"writingDirection": "ltr",
}
}
testID="text-input-label-active"
testID="text-input-flat-label-active"
>
Flat input
</Text>
Expand Down Expand Up @@ -344,7 +344,7 @@ exports[`correctly applies default textAlign based on default RTL 1`] = `
"writingDirection": "ltr",
}
}
testID="text-input-label-inactive"
testID="text-input-flat-label-inactive"
>
Flat input
</Text>
Expand Down Expand Up @@ -554,7 +554,7 @@ exports[`correctly applies height to multiline Outline TextInput 1`] = `
"writingDirection": "ltr",
}
}
testID="text-input-label-active"
testID="text-input-outlined-label-active"
>
Outline Input
</Text>
Expand Down Expand Up @@ -590,7 +590,7 @@ exports[`correctly applies height to multiline Outline TextInput 1`] = `
"writingDirection": "ltr",
}
}
testID="text-input-label-inactive"
testID="text-input-outlined-label-inactive"
>
Outline Input
</Text>
Expand Down Expand Up @@ -744,7 +744,7 @@ exports[`correctly applies textAlign center 1`] = `
"writingDirection": "ltr",
}
}
testID="text-input-label-active"
testID="text-input-flat-label-active"
>
Flat input
</Text>
Expand Down Expand Up @@ -781,7 +781,7 @@ exports[`correctly applies textAlign center 1`] = `
"writingDirection": "ltr",
}
}
testID="text-input-label-inactive"
testID="text-input-flat-label-inactive"
>
Flat input
</Text>
Expand Down Expand Up @@ -936,7 +936,7 @@ exports[`correctly renders left-side affix adornment, and right-side icon adornm
"writingDirection": "ltr",
}
}
testID="text-input-label-active"
testID="text-input-flat-label-active"
>
Flat input
</Text>
Expand Down Expand Up @@ -973,7 +973,7 @@ exports[`correctly renders left-side affix adornment, and right-side icon adornm
"writingDirection": "ltr",
}
}
testID="text-input-label-inactive"
testID="text-input-flat-label-inactive"
>
Flat input
</Text>
Expand Down Expand Up @@ -1298,7 +1298,7 @@ exports[`correctly renders left-side icon adornment, and right-side affix adornm
"writingDirection": "ltr",
}
}
testID="text-input-label-active"
testID="text-input-flat-label-active"
>
Flat input
</Text>
Expand Down Expand Up @@ -1335,7 +1335,7 @@ exports[`correctly renders left-side icon adornment, and right-side affix adornm
"writingDirection": "ltr",
}
}
testID="text-input-label-inactive"
testID="text-input-flat-label-inactive"
>
Flat input
</Text>
Expand Down