Skip to content

Commit

Permalink
chore: Add missing Unordered and Ordered List tests (#1117)
Browse files Browse the repository at this point in the history
Co-authored-by: Vincent Smedinga <[email protected]>
  • Loading branch information
alimpens and VincentSmedinga authored Mar 8, 2024
1 parent 4281fa1 commit 0eb305f
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/react/src/OrderedList/OrderedList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ describe('Ordered list', () => {
expect(component).toHaveClass('amsterdam-ordered-list')
})

it('renders a no markers class', () => {
render(<OrderedList markers={false} />)

const component = screen.getByRole('list')

expect(component).toHaveClass('amsterdam-ordered-list--no-markers')
})

it('renders an inverse color class', () => {
render(<OrderedList inverseColor />)

const component = screen.getByRole('list')

expect(component).toHaveClass('amsterdam-ordered-list--inverse-color')
})

it('renders an additional class name', () => {
render(<OrderedList className="extra" />)

Expand All @@ -27,6 +43,24 @@ describe('Ordered list', () => {
expect(component).toHaveClass('amsterdam-ordered-list extra')
})

it('renders its subcomponent', () => {
const listItems = ['Item 1', 'Item 2', 'Item 3']

const { container } = render(
<OrderedList>
{listItems.map((item, index) => (
<OrderedList.Item key={index}>{item}</OrderedList.Item>
))}
</OrderedList>,
)

const list = screen.getByRole('list')
const items = container.querySelectorAll('.amsterdam-ordered-list__item')

expect(list).toBeInTheDocument()
expect(items.length).toBe(3)
})

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

Expand Down
34 changes: 34 additions & 0 deletions packages/react/src/UnorderedList/UnorderedList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ describe('Unordered list', () => {
expect(component).toHaveClass('amsterdam-unordered-list')
})

it('renders a no markers class', () => {
render(<UnorderedList markers={false} />)

const component = screen.getByRole('list')

expect(component).toHaveClass('amsterdam-unordered-list--no-markers')
})

it('renders an inverse color class', () => {
render(<UnorderedList inverseColor />)

const component = screen.getByRole('list')

expect(component).toHaveClass('amsterdam-unordered-list--inverse-color')
})

it('renders an additional class name', () => {
render(<UnorderedList className="extra" />)

Expand All @@ -27,6 +43,24 @@ describe('Unordered list', () => {
expect(component).toHaveClass('amsterdam-unordered-list extra')
})

it('renders its subcomponent', () => {
const listItems = ['Item 1', 'Item 2', 'Item 3']

const { container } = render(
<UnorderedList>
{listItems.map((item, index) => (
<UnorderedList.Item key={index}>{item}</UnorderedList.Item>
))}
</UnorderedList>,
)

const list = screen.getByRole('list')
const items = container.querySelectorAll('.amsterdam-unordered-list__item')

expect(list).toBeInTheDocument()
expect(items.length).toBe(3)
})

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

Expand Down

0 comments on commit 0eb305f

Please sign in to comment.