Sha256: 40a18dc1d4515275902bdf26b717ab1548e55ad783a9aa44c01ccbb8753e91d9

Contents?: true

Size: 1.99 KB

Versions: 541

Compression:

Stored size: 1.99 KB

Contents

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

import Source from './_source'

const testId = 'source'
const className = 'custom-class-name'

const SourceDefault = (props) => (
    <>
        <Source
            aria={{ label: testId }}
            className={className}
            data={{ testid: testId }}
            source="BJ's Johnston-208"
            type='retail'
            {...props}
        />
    </>
)

test('should pass data prop', () => {
    render(<SourceDefault />)
    const kit = screen.getByTestId(testId)
    expect(kit).toBeInTheDocument()
})

test('should pass className prop', () => {
    render(<SourceDefault />)
    const kit = screen.getByTestId(testId)
    expect(kit).toHaveClass(className)
})

test('should pass aria prop', () => {
    render(<SourceDefault />)
    const kit = screen.getByTestId(testId)
    expect(kit).toHaveAttribute('aria-label', testId)
})

test('should pass type prop', () => {
    render(<SourceDefault />)
    const kit = screen.getByText('Retail')
    expect(kit).toBeInTheDocument()
})

test('should pass source prop', () => {
    render(<SourceDefault />)
    const kit = screen.getByText("BJ's Johnston-208")
    expect(kit).toBeInTheDocument()
})

test('should not hide icon by default', () => {
    render(<SourceDefault />)
    const kit = screen.getByTestId(testId)
    expect(kit.querySelector('.pb_icon_circle_kit_size_sm_default')).toBeTruthy()
})

test('should hide icon', () => {
    render(<SourceDefault hideIcon />)
    const kit = screen.getByTestId(testId)
    expect(kit.querySelector('.pb_icon_circle_kit_size_sm_default')).toBeFalsy()
})

test('should pass user prop', () => {
    const user = {
        name: 'Anna Black',
        userId: '48582',
    }
    
    render(
        <SourceDefault
            type='user'
            user={user}
        />
    )

    let kit = screen.getByText(user.name)
    expect(kit).toBeInTheDocument()

    kit = screen.getByText(user.userId)
    expect(kit).toBeInTheDocument()
})

Version data entries

541 entries across 541 versions & 1 rubygems

Version Path
playbook_ui-14.11.1.pre.alpha.PLAY17445539 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR798datepickerturbo5537 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.11.1.pre.alpha.pbntr703collapsiblerowsrails5536 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.11.1.pre.alpha.PLAY1751pbcontenttagpt25529 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR7495495 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.12.0.pre.rc.11 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.12.0.pre.rc.10 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.12.0.pre.rc.9 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.12.0.pre.rc.8 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.12.0.pre.rc.7 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5437 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR719listdraggablesimple5432 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR768stickyrightcolumn5431 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.12.0.pre.rc.6 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5415 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5413 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.12.0.pre.rc.5 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5409 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5400 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5392 app/pb_kits/playbook/pb_source/source.test.js