Skip to content

Commit

Permalink
fix(Image): Allow passing testID (react-native-elements#2092)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomJKlug authored and iRoachie committed Sep 26, 2019
1 parent 97fcd7e commit 1dbd7e0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/image/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Image extends React.Component {
style={StyleSheet.flatten([styles.container, containerStyle])}
>
<ImageComponent
testID="RNE__Image"
{...attributes}
onLoad={this.onLoad}
style={[
Expand All @@ -59,7 +60,6 @@ class Image extends React.Component {
height: style.height,
},
]}
testID="RNE__Image"
/>

<Animated.View
Expand Down
23 changes: 23 additions & 0 deletions src/image/__tests__/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,29 @@ describe('Image Component', () => {
expect(toJson(component)).toMatchSnapshot();
});

it('should render the appropriate testId when one is passed.', () => {
const component = shallow(
<Image
testID="customTestId"
source={{ uri: 'https://i.imgur.com/0y8Ftya.jpg' }}
/>
);

const image = component.find({ testID: 'customTestId' });

expect(image.length).toBe(1);
});

it('should render the appropriate testId when one is not passed.', () => {
const component = shallow(
<Image source={{ uri: 'https://i.imgur.com/0y8Ftya.jpg' }} />
);

const image = component.find({ testID: 'RNE__Image' });

expect(image.length).toBe(1);
});

it('should apply values from theme', () => {
const theme = {
Image: {
Expand Down

0 comments on commit 1dbd7e0

Please sign in to comment.