Sha256: 0b66f666ff4829f9642e79a4dea2375cc0e515bbf2a661e90ee9ccb8a65a0190

Contents?: true

Size: 1.93 KB

Versions: 551

Compression:

Stored size: 1.93 KB

Contents

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

import Toggle from './_toggle'

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

const ToggleDefault = (props) => (
    <>
        <Toggle
            aria={{ label: testId }}
            className={className}
            data={{ testid: testId }}
            id={testId}
            {...props}
        />
    </>
)

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

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

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

test('should pass id prop', () => {
    render(<ToggleDefault />)
    const kit = screen.getByTestId(testId)
    expect(kit).toHaveProperty('id', testId)
})

test('should not be checked by default', () => {
    render(<ToggleDefault />)
    const kit = screen.getByTestId(testId)
    expect(kit).toHaveClass('pb_toggle_kit_sm_off')
})

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

test('should have sm size by default', () => {
    render(<ToggleDefault />)
    const kit = screen.getByTestId(testId)
    expect(kit).toHaveClass('pb_toggle_kit_sm_off')
})

test('should pass disabled prop', () => {
    render(<ToggleDefault disabled />)
    const kit = screen.getByTestId(testId)
    const input = kit.querySelector('input')
    expect(input).toHaveAttribute('disabled')
})  

test('should pass size prop', () => {
    render(<ToggleDefault size='md' />)
    const kit = screen.getByTestId(testId)
    expect(kit).toHaveClass('pb_toggle_kit_md_off')
})

Version data entries

551 entries across 551 versions & 1 rubygems

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