UNPKG

2.52 kBJavaScriptView Raw
1import React from 'react';
2import { screen, render } from '@testing-library/react';
3import '@testing-library/jest-dom';
4import { Nav } from '..';
5import {
6 testForChildrenInComponent,
7 testForCustomClass,
8 testForCustomTag,
9 testForDefaultClass,
10} from '../testUtils';
11
12describe('Nav', () => {
13 it('should render .nav markup', () => {
14 testForDefaultClass(Nav, 'nav');
15 });
16
17 it('should render custom tag', () => {
18 testForCustomTag(Nav);
19 });
20
21 it('should render children', () => {
22 testForChildrenInComponent(Nav);
23 });
24
25 it('should handle justified prop', () => {
26 let { container } = render(<Nav justified />);
27 expect(container).toContainHTML('<ul class="nav nav-justified"></ul>');
28 });
29
30 it('should handle fill prop', () => {
31 let { container } = render(<Nav fill />);
32 expect(container).toContainHTML('<ul class="nav nav-fill"></ul>');
33 });
34
35 it('should handle pills prop', () => {
36 let { container } = render(<Nav pills />);
37 expect(container).toContainHTML('<ul class="nav nav-pills"></ul>');
38 });
39
40 it('should handle pills prop with card prop', () => {
41 let { container } = render(<Nav pills card />);
42 expect(container).toContainHTML(
43 '<ul class="nav nav-pills card-header-pills"></ul>',
44 );
45 });
46
47 it('should handle tabs prop', () => {
48 let { container } = render(<Nav tabs />);
49 expect(container).toContainHTML('<ul class="nav nav-tabs"></ul>');
50 });
51
52 it('should handle tabs prop with card prop', () => {
53 let { container } = render(<Nav tabs card />);
54 expect(container).toContainHTML(
55 '<ul class="nav nav-tabs card-header-tabs"></ul>',
56 );
57 });
58
59 it('should handle vertical prop', () => {
60 let { container } = render(<Nav vertical />);
61 expect(container).toContainHTML('<ul class="nav flex-column"></ul>');
62 });
63
64 it('should handle vertical prop with string', () => {
65 let { container } = render(<Nav vertical="sm" />);
66 expect(container).toContainHTML('<ul class="nav flex-sm-column"></ul>');
67 });
68
69 it('should handle horizontal prop with string', () => {
70 let { container } = render(<Nav horizontal="end" />);
71 expect(container).toContainHTML(
72 '<ul class="nav justify-content-end"></ul>',
73 );
74 });
75
76 it('should pass additional classNames', () => {
77 testForCustomClass(Nav);
78 });
79
80 it('should render .navbar-nav class only', () => {
81 let { container } = render(<Nav navbar>Children</Nav>);
82 expect(container).toContainHTML('<ul class="navbar-nav">Children</ul>');
83 });
84});