Sha256: 03097bb0b08f5e9bbcc6c540abc9e46e38147e5c8ed958050d594dabc636a04b

Contents?: true

Size: 912 Bytes

Versions: 158

Compression:

Stored size: 912 Bytes

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)
})

Version data entries

158 entries across 158 versions & 1 rubygems

Version Path
playbook_ui-12.14.0.pre.alpha.lightboxcurrentphotoprop460 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.14.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown457 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.14.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown456 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.14.0 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.13.0.pre.alpha.PLAY693tooltipwrongbg440 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.13.0.pre.alpha.addingProductTokens439 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.13.0.pre.alpha.PLAY705phonenumberkit438 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.13.0 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.12.0.pre.alpha.PLAY697sandpacklayoutstyles413 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.12.0 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.11.0 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.10.0.pre.alpha.PLAY705phonenumberreturn372 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.10.0.pre.alpha.PLAY677richtexteditorts370 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.10.0 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.9.1.pre.alpha.play664tiptapinvestigation353 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.9.1.pre.alpha.PLAY689bugtxtinputlabel346 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.9.1.pre.alpha.menucleanup345 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.9.1.pre.alpha.menucleanup342 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.9.1 app/pb_kits/playbook/pb_avatar/avatar.test.js
playbook_ui-12.9.0 app/pb_kits/playbook/pb_avatar/avatar.test.js