Sha256: 50be3cde8963ed12ac3b1730fc92858aea236780414b0368cf623176f3915187
Contents?: true
Size: 1.18 KB
Versions: 372
Compression:
Stored size: 1.18 KB
Contents
import React from 'react' import { render, screen } from '../utilities/test-utils' import Avatar from './_avatar' const imageUrl = 'https://randomuser.me/api/portraits/men/44.jpg', testId = 'tjohnson', name = 'Terry Johnson', imageAlt = 'Terry Johnson Standing' test('loads the given image url and name', () => { render( <Avatar data={{ testid: testId }} imageAlt={imageAlt} imageUrl={imageUrl} name={name} /> ) const kit = screen.getByTestId(testId) const image = screen.getByAltText(imageAlt) const initials = name.split(/\s/)[0].substr(0, 1) + name.split(/\s/)[1].substr(0, 1) expect(kit).toHaveClass('pb_avatar_kit_size_md') expect(kit).toHaveAttribute('data-initials', initials) expect(image).toHaveAttribute('data-src', imageUrl) expect(image).toHaveAttribute('src', imageUrl) expect(image).toHaveAttribute('alt', imageAlt) }) test('uses the name prop as the alt property if no imageAlt prop is passed in', () => { render( <Avatar data={{ testid: testId }} imageUrl={imageUrl} name={name} /> ) const image = screen.getByAltText(name) expect(image).toHaveAttribute('alt', name) })
Version data entries
372 entries across 372 versions & 1 rubygems