Skip to content

Commit

Permalink
fix(user-profile-component): Fix user profile image
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandronanez committed Oct 25, 2017
1 parent 4fece57 commit 9cea636
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions __tests__/tests/components/UserProfile.js
Expand Up @@ -44,7 +44,9 @@ describe('<UserProfile />', () => {
);

const result = wrapper.instance().getUserUri();
const expectedResult = `${initialUser.avatar_url}&lastModified=${initialUser.updated_at}`;
const expectedResult = {
uri: `${initialUser.avatar_url}&lastModified=${initialUser.updated_at}`,
};

expect(result).toEqual(expectedResult);
});
Expand All @@ -62,7 +64,9 @@ describe('<UserProfile />', () => {
);

const result = wrapper.instance().getUserUri();
const expectedResult = `${user.avatar_url}&lastModified=${user.updated_at}`;
const expectedResult = {
uri: `${user.avatar_url}&lastModified=${user.updated_at}`,
};

expect(result).toEqual(expectedResult);
});
Expand Down
7 changes: 4 additions & 3 deletions src/components/user-profile.component.js
Expand Up @@ -101,10 +101,11 @@ export class UserProfile extends Component {

getUserUri = () => {
const { initialUser, user } = this.props;

return initialUser.avatar_url
const image = initialUser.avatar_url
? `${initialUser.avatar_url}&lastModified=${initialUser.updated_at}`
: `${user.avatar_url}&lastModified=${user.updated_at}`;

return { uri: image };
};

render() {
Expand All @@ -130,7 +131,7 @@ export class UserProfile extends Component {
>
<View style={styles.profile}>
<ImageZoom
uri={this.getUserUri}
uri={this.getUserUri()}
style={[
styles.avatar,
(initialUser.type === 'User' || user.type === 'User') &&
Expand Down

0 comments on commit 9cea636

Please sign in to comment.