Sha256: 2d4fe12ed4949b1fad157e58ed99f9114685192e02db3e831db50e2de2c50e56

Contents?: true

Size: 1.72 KB

Versions: 339

Compression:

Stored size: 1.72 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 size prop', () => {
    render(<ToggleDefault size='md' />)
    const kit = screen.getByTestId(testId)
    expect(kit).toHaveClass('pb_toggle_kit_md_off')
})

Version data entries

339 entries across 339 versions & 1 rubygems

Version Path
playbook_ui-13.18.0.pre.alpha.dependabotnpmandyarnreactrouterdom62212196 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.18.0.pre.alpha.dependabotnpmandyarntypescripteslintparser56202194 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.18.0.pre.alpha.PLAY12062192 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.18.0.pre.alpha.useexactnodejsversionghactions2183 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.18.0.pre.alpha.useexactnodejsversionghactions2181 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.18.0.pre.alpha.useexactnodejsversionghactions2180 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.18.0.pre.alpha.useexactnodejsversionghactions2179 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2178 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.18.0.pre.alpha.PLAY12062177 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2176 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.18.0.pre.alpha.dependabotnpmandyarnpowerhomeplaybookicons001alpha52175 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.18.0.pre.alpha.dependabotnpmandyarnpowerhomeplaybookicons001alpha52174 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2173 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2159 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.17.0.pre.alpha.nodealphaupgrade2157 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.18.0 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.16.0.pre.alpha.play1141iconkitusinglibrary2130 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.16.0.pre.alpha.PLAY12002127 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.16.0.pre.alpha.powercentrainplaybookpt22125 app/pb_kits/playbook/pb_toggle/toggle.test.js
playbook_ui-13.16.0.pre.alpha.play1141iconkitusinglibrary2107 app/pb_kits/playbook/pb_toggle/toggle.test.js