Sha256: 2c4951617764346bfd703f1a88f32ac49107960ae4a5b238730c4d8a0049b81a

Contents?: true

Size: 1.82 KB

Versions: 825

Compression:

Stored size: 1.82 KB

Contents

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

test('abbreviate prop returns proper abbreviated amount', () => {
  render(
    <>
      <Currency
          abbreviate
          amount="3200"
          data={{ testid: 'test-thousands' }}
      />
      <Currency
          abbreviate
          amount="3,200,000"
          data={{ testid: 'test-millions' }}
      />
      <Currency
          abbreviate
          amount="3200000000"
          data={{ testid: 'test-billions' }}
      />
      <Currency
          abbreviate
          amount="3,200,000,000,000"
          data={{ testid: 'test-trillions' }}
      />
    </>
  )

  expect(screen.getByTestId('test-thousands')).toHaveTextContent('$3.2K')
  expect(screen.getByTestId('test-millions')).toHaveTextContent('$3.2M')
  expect(screen.getByTestId('test-billions')).toHaveTextContent('$3.2B')
  expect(screen.getByTestId('test-trillions')).toHaveTextContent('$3.2T')
})

test('decimals matching prop returns decimals as title text', () => {
  render(
    <Currency
        amount="320.20"
        data={{ testid: 'test-decimals-matching' }}
        decimals='matching'
    />
  )

  const currencyKit = screen.getByTestId('test-decimals-matching')
  expect(currencyKit.querySelector('.pb_currency_value')).toHaveTextContent('320.20')
  expect(currencyKit.querySelector('.unit')).toHaveTextContent('')
})

test('decimals default prop returns decimals as body text', () => {
  render(
    <Currency
        amount="320.20"
        data={{ testid: 'test-decimals-default' }}
        decimals='default'
    />
  )

  const currencyKit = screen.getByTestId('test-decimals-default')
  expect(currencyKit.querySelector('.pb_currency_value')).toHaveTextContent('320')
  expect(currencyKit.querySelector('.unit')).toHaveTextContent('.20')
})

Version data entries

825 entries across 825 versions & 1 rubygems

Version Path
playbook_ui-14.6.2.pre.alpha.PBNTR576tooltiptruncatedformpills4304 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.6.2.pre.alpha.PBNTR633dropdownavailablepropstable4303 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.6.2.pre.alpha.PBNTR576tooltiptruncatedformpills4296 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.6.2.pre.alpha.PLAY1550lazysizesupgrade4295 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.6.2.pre.alpha.PLAY1485selectablecardoverflowoutlinebug4274 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.6.2.pre.alpha.PLAY1607dependencydisplayymlupdate4271 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.6.2.pre.alpha.PLAY1538READMEroot4262 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.6.2.pre.alpha.PLAY1538READMEroot4260 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.6.2.pre.alpha.PLAY1550lazysizesupgrade4257 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.6.2.pre.alpha.PLAY1538READMEroot4254 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.6.2.pre.alpha.PLAY1538READMEroot4251 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.7.0.pre.rc.5 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.6.2.pre.alpha.PLAY1485selectablecardoverflowoutlinebug4247 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.7.0.pre.rc.4 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.7.0.pre.rc.3 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.6.2 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.7.0.pre.rc.2 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.6.0.pre.alpha.dropdownclassfix4224 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.6.0.pre.alpha.PLAY1485selectablecardoverflowoutlinebug4222 app/pb_kits/playbook/pb_currency/currency.test.js
playbook_ui-14.6.1 app/pb_kits/playbook/pb_currency/currency.test.js