Sha256: dd7a277b7ae7e5633c439ca0d1c541ae7b90419cce296515c2965f8cf9fcd380

Contents?: true

Size: 1.97 KB

Versions: 360

Compression:

Stored size: 1.97 KB

Contents

import React from 'react'
import { cleanup, render, screen } from '../utilities/test-utils'

import Badge from './_badge'

const testId = "badge"

test('default class name', () => {
  render(
    <Badge
        data={{ testid: testId }}
        text="+1"
    />
  )

  const kit = screen.getByTestId(testId)

  expect(kit).toHaveClass('pb_badge_kit_neutral')
})

test('primary class name', () => {
  render(
    <Badge
        data={{ testid: testId }}
        text="+1"
        variant="primary"
    />
  )

  const kit = screen.getByTestId(testId)

  expect(kit).toHaveClass('pb_badge_kit_primary')
})

test('displays text content', () => {
  render(
    <Badge
        text="+1"
        variant="primary"
    />
  )

  const text = screen.getByText("+1")
  expect(text).toBeInTheDocument()
})

test('displays rounded corners', () => {
  render(
    <Badge
        data={{ testid: testId }}
        rounded
        text="+1"
        variant="primary"
    />
  )

  const kit = screen.getByTestId(testId)
  expect(kit).toHaveClass('pb_badge_kit_primary_rounded')
})

test('displays color variants', () => {
  [
    "warning",
    "error",
    "info"
  ].forEach((colorVariant) => {
    render(
      <Badge
          data={{ testid: testId }}
          text={colorVariant}
          variant={colorVariant}
      />
    )
    const kit = screen.getByTestId(testId)
    expect(kit).toHaveClass(`pb_badge_kit_${colorVariant}`)

    cleanup()
  })
})

test('displays success variant', () => {
    render(
      <Badge
          data={{ testid: testId }}
          text={"success"}
          variant={"success"}
      />
    )
    const kit = screen.getByTestId(testId)
    expect(kit).toHaveClass(`pb_badge_kit_success_sm
    `)

    cleanup()

})

test('displays notification variant', () => {
  render(
    <Badge
        data={{ testid: testId }}
        text="1"
        variant="notification"
    />
  )
  const kit = screen.getByTestId(testId)
  expect(kit).toHaveClass(`pb_badge_kit_notification`)
  cleanup()
})

Version data entries

360 entries across 360 versions & 1 rubygems

Version Path
playbook_ui-13.12.0.pre.alpha.play1051highchartstest1567 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.12.0.pre.alpha.play1051highchartstest1558 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.12.0.pre.alpha.play1051highchartstest1556 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.12.0.pre.alpha.PLAY1051removinghighchartsdependency1551 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.12.0.pre.alpha.play900startratingasinput1550 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.12.0.pre.alpha.play900startratingasinput1543 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.11.1.pre.alpha.play900startratingasinput1530 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.12.0 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.11.1 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.11.0 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.10.0.pre.alpha.PLAY1051removinghighchartsdependency1465 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.10.0.pre.alpha.webpackerregistercomponents1463 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.10.0.pre.alpha.dependabotnpmandyarnfortawesomefontawesomepro6421439 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.10.0.pre.alpha.play10561428 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.10.0.pre.alpha.play1054tableheadersortconsolidation1416 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.10.0.pre.alpha.play10561409 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.10.0.pre.alpha.dependabotnpmandyarntiptapextensionlink21121407 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.10.0.pre.alpha.PLAY1046multilevelsingleselectphase21365 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.10.0.pre.alpha.PLAY1046multilevelsingleselectphase21358 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-13.10.0.pre.alpha.play10481357 app/pb_kits/playbook/pb_badge/badge.test.js