1 | import React from 'react';
|
2 | import { render, screen } from '@testing-library/react';
|
3 | import { ListGroup } from '..';
|
4 | import {
|
5 | testForCustomClass,
|
6 | testForCustomTag,
|
7 | testForDefaultClass,
|
8 | } from '../testUtils';
|
9 |
|
10 | describe('ListGroup', () => {
|
11 | it('should render with "list-group" class', () => {
|
12 | testForDefaultClass(ListGroup, 'list-group');
|
13 | });
|
14 |
|
15 | it('should render with "flush"', () => {
|
16 | render(<ListGroup flush>Yo!</ListGroup>);
|
17 |
|
18 | expect(screen.getByText('Yo!')).toHaveClass('list-group-flush');
|
19 | expect(screen.getByText('Yo!')).toHaveClass('list-group');
|
20 | });
|
21 |
|
22 | it('should render with "horizontal"', () => {
|
23 | render(<ListGroup horizontal>Yo!</ListGroup>);
|
24 |
|
25 | expect(screen.getByText('Yo!')).toHaveClass('list-group-horizontal');
|
26 | });
|
27 |
|
28 | it('should not render with "horizontal" if flush is true', () => {
|
29 | render(
|
30 | <ListGroup flush horizontal>
|
31 | Yo!
|
32 | </ListGroup>,
|
33 | );
|
34 |
|
35 | expect(screen.getByText('Yo!')).toHaveClass('list-group');
|
36 | expect(screen.getByText('Yo!')).toHaveClass('list-group-flush');
|
37 | expect(screen.getByText('Yo!')).not.toHaveClass('list-group-horizontal');
|
38 | });
|
39 |
|
40 | it('should render with "horizontal-{breakpoint}"', () => {
|
41 | render(<ListGroup horizontal="lg">Yo!</ListGroup>);
|
42 |
|
43 | expect(screen.getByText('Yo!')).toHaveClass('list-group');
|
44 | expect(screen.getByText('Yo!')).toHaveClass('list-group-horizontal-lg');
|
45 | });
|
46 |
|
47 | it('should render with "numbered"', () => {
|
48 | render(<ListGroup numbered>Yo!</ListGroup>);
|
49 |
|
50 | expect(screen.getByText('Yo!')).toHaveClass('list-group-numbered');
|
51 | });
|
52 |
|
53 | it('should render additional classes', () => {
|
54 | testForCustomClass(ListGroup);
|
55 | });
|
56 |
|
57 | it('should render custom tag', () => {
|
58 | testForCustomTag(ListGroup);
|
59 | });
|
60 | });
|