Merge branch 'avatar-tests' into 'next'
Add tests for Avatar See merge request soapbox-pub/soapbox-fe!1182
This commit is contained in:
commit
887ef55cd4
2 changed files with 21 additions and 1 deletions
|
@ -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>
|
||||
|
|
20
app/soapbox/components/ui/avatar/__tests__/avatar.test.tsx
Normal file
20
app/soapbox/components/ui/avatar/__tests__/avatar.test.tsx
Normal 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);
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue