Merge branch 'avatar-tests' into 'next'

Add tests for Avatar

See merge request soapbox-pub/soapbox-fe!1182
This commit is contained in:
Justin 2022-04-05 14:01:08 +00:00
commit 887ef55cd4
2 changed files with 21 additions and 1 deletions

View file

@ -54,7 +54,7 @@ class StillImage extends React.PureComponent {
const hoverToPlay = this.hoverToPlay();
return (
<div className={classNames(className, 'still-image', { 'still-image--play-on-hover': hoverToPlay })} style={style}>
<div data-testid='still-image-container' className={classNames(className, 'still-image', { 'still-image--play-on-hover': hoverToPlay })} style={style}>
<img src={src} alt={alt} ref={this.setImageRef} onLoad={this.handleImageLoad} />
{hoverToPlay && <canvas ref={this.setCanvasRef} />}
</div>

View file

@ -0,0 +1,20 @@
import React from 'react';
import { render, screen } from '../../../../jest/test-helpers';
import Avatar from '../avatar';
const src = '/static/alice.jpg';
describe('<Avatar />', () => {
it('renders', () => {
render(<Avatar src={src} />);
expect(screen.getByRole('img')).toBeInTheDocument();
});
it('handles size props', () => {
render(<Avatar src={src} size={50} />);
expect(screen.getByTestId('still-image-container').getAttribute('style')).toMatch(/50px/i);
});
});