Socialify

Folder ..

Viewing badge.test.tsx
22 lines (19 loc) • 666.0 B

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { render } from '@testing-library/react'

import Badge from './badge'

test('Badge renders', () => {
  const { container } = render(
    <Badge color="black" name="name1" value="value1" />
  )
  const badge = container.firstElementChild!

  expect(badge).toMatchSnapshot()
  expect(badge.classList.contains('badge-wrapper')).toBe(true)
  expect(
    badge.querySelector<HTMLElement>('.badge-label')?.textContent
  ).toStrictEqual('name1')
  expect(
    badge.querySelector<HTMLElement>('.badge-value')?.textContent
  ).toStrictEqual('value1')
  expect(
    badge.querySelector<HTMLElement>('.badge-value')?.style.backgroundColor
  ).toStrictEqual('black')
})