Sha256: 0084b397c43d4df244f5afde11756606ba819594b3836fbabc759af5a3ef6947

Contents?: true

Size: 1.7 KB

Versions: 112

Compression:

Stored size: 1.7 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()

})

Version data entries

112 entries across 112 versions & 1 rubygems

Version Path
playbook_ui-12.26.0.pre.alpha.multiselectfixes795 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.26.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown794 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.25.0.pre.alpha.play824786 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.26.0 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.25.0.pre.alpha.railsmultilevelimprovements785 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.25.0.pre.alpha.railsmultilevelimprovements780 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.25.0.pre.alpha.PLAY818multilevelrebuild779 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.25.0.pre.alpha.railsmultilevelimprovements776 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.25.0.pre.alpha.PLAY818multilevelrebuild774 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.25.0.pre.alpha.PLAY818multilevelrebuild773 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.25.0.pre.alpha.PLAY818multilevelrebuild770 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.25.0.pre.alpha.play822bolddefaultfortitle3764 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.25.0.pre.alpha.PLAY733DetailKit761 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.25.0.pre.alpha.railsmultilevelimprovements758 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.25.0 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.24.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown756 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.24.0.pre.alpha.play824753 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.24.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown752 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.24.0.pre.alpha.play824751 app/pb_kits/playbook/pb_badge/badge.test.js
playbook_ui-12.24.0.pre.alpha.railsmultilevelimprovements749 app/pb_kits/playbook/pb_badge/badge.test.js