Fix avatar tests

This commit is contained in:
Alex Gleason 2020-06-10 19:10:13 -05:00 committed by Bárbara de Castro Fernandes
parent 52f3f8ce8d
commit 853a68cd54
4 changed files with 41 additions and 31 deletions

View file

@ -2,30 +2,36 @@
exports[`<Avatar /> Autoplay renders an animated avatar 1`] = ` exports[`<Avatar /> Autoplay renders an animated avatar 1`] = `
<div <div
className="account__avatar" className="account__avatar still-image"
onMouseEnter={[Function]}
onMouseLeave={[Function]}
style={ style={
Object { Object {
"backgroundImage": "url(/animated/alice.gif)",
"height": "100px", "height": "100px",
"width": "100px", "width": "100px",
} }
} }
/> >
<img
alt=""
onLoad={[Function]}
src="/animated/alice.gif"
/>
</div>
`; `;
exports[`<Avatar /> Still renders a still avatar 1`] = ` exports[`<Avatar /> Still renders a still avatar 1`] = `
<div <div
className="account__avatar" className="account__avatar still-image"
onMouseEnter={[Function]}
onMouseLeave={[Function]}
style={ style={
Object { Object {
"backgroundImage": "url(/static/alice.jpg)",
"height": "100px", "height": "100px",
"width": "100px", "width": "100px",
} }
} }
/> >
<img
alt=""
onLoad={[Function]}
src="/animated/alice.gif"
/>
</div>
`; `;

View file

@ -5,20 +5,24 @@ exports[`<AvatarOverlay renders a overlay avatar 1`] = `
className="account__avatar-overlay" className="account__avatar-overlay"
> >
<div <div
className="account__avatar-overlay-base" className="account__avatar-overlay-base still-image"
style={ style={Object {}}
Object { >
"backgroundImage": "url(/static/alice.jpg)", <img
} alt=""
} onLoad={[Function]}
/> src="/animated/alice.gif"
/>
</div>
<div <div
className="account__avatar-overlay-overlay" className="account__avatar-overlay-overlay still-image"
style={ style={Object {}}
Object { >
"backgroundImage": "url(/static/eve.jpg)", <img
} alt=""
} onLoad={[Function]}
/> src="/animated/eve.gif"
/>
</div>
</div> </div>
`; `;

View file

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import renderer from 'react-test-renderer';
import { fromJS } from 'immutable'; import { fromJS } from 'immutable';
import { Avatar } from '../avatar'; import { createComponent } from 'soapbox/test_helpers';
import Avatar from '../avatar';
describe('<Avatar />', () => { describe('<Avatar />', () => {
const account = fromJS({ const account = fromJS({
@ -16,7 +16,7 @@ describe('<Avatar />', () => {
describe('Autoplay', () => { describe('Autoplay', () => {
it('renders an animated avatar', () => { it('renders an animated avatar', () => {
const component = renderer.create(<Avatar account={account} animate size={size} />); const component = createComponent(<Avatar account={account} animate size={size} />);
const tree = component.toJSON(); const tree = component.toJSON();
expect(tree).toMatchSnapshot(); expect(tree).toMatchSnapshot();
@ -25,7 +25,7 @@ describe('<Avatar />', () => {
describe('Still', () => { describe('Still', () => {
it('renders a still avatar', () => { it('renders a still avatar', () => {
const component = renderer.create(<Avatar account={account} size={size} />); const component = createComponent(<Avatar account={account} size={size} />);
const tree = component.toJSON(); const tree = component.toJSON();
expect(tree).toMatchSnapshot(); expect(tree).toMatchSnapshot();

View file

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import renderer from 'react-test-renderer';
import { fromJS } from 'immutable'; import { fromJS } from 'immutable';
import { AvatarOverlay } from '../avatar_overlay'; import { createComponent } from 'soapbox/test_helpers';
import AvatarOverlay from '../avatar_overlay';
describe('<AvatarOverlay', () => { describe('<AvatarOverlay', () => {
const account = fromJS({ const account = fromJS({
@ -21,7 +21,7 @@ describe('<AvatarOverlay', () => {
}); });
it('renders a overlay avatar', () => { it('renders a overlay avatar', () => {
const component = renderer.create(<AvatarOverlay account={account} friend={friend} />); const component = createComponent(<AvatarOverlay account={account} friend={friend} />);
const tree = component.toJSON(); const tree = component.toJSON();
expect(tree).toMatchSnapshot(); expect(tree).toMatchSnapshot();