I have a styled-component defined like this :
export const StyledButton = styled.TouchableOpacity<IButtonProps>
height: 46px;
width: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
height: 46px;
border-radius: 8px;
background: ${EAppColors.BLACK};
opacity: ${props => (props.disabled ? 0.6 : 1)};
;
interface IButtonProps {
readonly children: React.ReactNode;
readonly onPress: () => any;
readonly style?: StyleProp<ViewStyle>;
readonly testID?: string;
readonly disabled?: boolean;
}
const Button: React.FC<IButtonProps> = ({
children,
style,
onPress,
disabled = false,
}) => {
return (
<StyledButton
testID={'button.simple'}
onPress={onPress}
style={style}
disabled={disabled}>
{children}
</StyledButton>
);
};
and I would like with react-native-testing-library to access the disabled props. There is my test :
const { getByTestId } = render(
<Button disabled={false} onPress={onPressMock}>
<Text>Title</Text>
</Button>,
);
but when I log in my test suite I only have this:
console.log(getByTestId('button.simple').props);
And the result of the console.log in my terminal :
{
accessible: true,
style: {
height: 46,
width: '100%',
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
borderRadius: 8,
backgroundColor: '#000000',
opacity: 1
},
testID: 'button.simple'
How can I access to the props passed?