Skip to content

Commit

Permalink
The tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dlnr committed Nov 26, 2024
1 parent 425fa29 commit 11d1d5e
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions packages/react/src/DescriptionList/DescriptionListGroup.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { render } from '@testing-library/react'
import { createRef } from 'react'
import { DescriptionList } from './DescriptionList'
import '@testing-library/jest-dom'

describe('Description List Group', () => {
it('renders', () => {
const { container } = render(<DescriptionList.Group>Test</DescriptionList.Group>)

const component = container.querySelector(':only-child')

expect(component).toBeInTheDocument()
expect(component).toBeVisible()
})

it('renders a design system BEM class name', () => {
const { container } = render(<DescriptionList.Group>Test</DescriptionList.Group>)

const component = container.querySelector(':only-child')

expect(component).toHaveClass('ams-description-list__group')
})

it('renders an additional class name', () => {
const { container } = render(<DescriptionList.Group className="extra">Test</DescriptionList.Group>)

const component = container.querySelector(':only-child')

expect(component).toHaveClass('ams-description-list__group extra')
})

it('supports ForwardRef in React', () => {
const ref = createRef<HTMLDivElement>()

const { container } = render(<DescriptionList.Group ref={ref}>Test</DescriptionList.Group>)

const component = container.querySelector(':only-child')

expect(ref.current).toBe(component)
})
})

0 comments on commit 11d1d5e

Please sign in to comment.