Sha256: 7c71ab8e4c6149295a75dfdf4adab4d6e9ef6fb42ec300b485423009bb22b563

Contents?: true

Size: 1.98 KB

Versions: 371

Compression:

Stored size: 1.98 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_sm_default')).toBeTruthy()
})

test('should hide icon', () => {
    render(<SourceDefault hideIcon />)
    const kit = screen.getByTestId(testId)
    expect(kit.querySelector('.pb_icon_circle_kit_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

371 entries across 371 versions & 1 rubygems

Version Path
playbook_ui-13.19.0.pre.alpha.PBNTR207tabledivsupport2261 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.19.0.pre.alpha.PBNTR207tabledivsupport2245 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.19.0 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.thor93bargraphoptions2219 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.thor93bargraphoptions2211 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.play1141iconkitusinglibrary2210 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.PLAY12062203 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.powercentrainplaybookpt22201 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.PLAY8672199 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2197 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.dependabotnpmandyarnreactrouterdom62212196 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.dependabotnpmandyarntypescripteslintparser56202194 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.PLAY12062192 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.useexactnodejsversionghactions2183 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.useexactnodejsversionghactions2181 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.useexactnodejsversionghactions2180 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.useexactnodejsversionghactions2179 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2178 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.PLAY12062177 app/pb_kits/playbook/pb_source/source.test.js
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2176 app/pb_kits/playbook/pb_source/source.test.js