1 | import React from 'react';
|
2 | import { render, screen } from '@testing-library/react';
|
3 | import '@testing-library/jest-dom';
|
4 | import { FormText } from '..';
|
5 | import {
|
6 | testForChildrenInComponent,
|
7 | testForCustomClass,
|
8 | testForCustomTag,
|
9 | testForDefaultClass,
|
10 | testForDefaultTag,
|
11 | } from '../testUtils';
|
12 |
|
13 | describe('FormText', () => {
|
14 | it('should render with "form" tag', () => {
|
15 | testForDefaultTag(FormText, 'small');
|
16 | });
|
17 |
|
18 | it('should render children', () => {
|
19 | testForChildrenInComponent(FormText);
|
20 | });
|
21 |
|
22 | it('should render with "form-text" class when not inline', () => {
|
23 | testForDefaultClass(FormText, 'form-text');
|
24 | });
|
25 |
|
26 | it('should not render with "form-text" class when inline', () => {
|
27 | render(<FormText inline>Yo!</FormText>);
|
28 |
|
29 | expect(screen.getByText('Yo!')).not.toHaveClass('form-text');
|
30 | });
|
31 |
|
32 | it('should render with "text-muted" class by default', () => {
|
33 | render(<FormText>Yo!</FormText>);
|
34 |
|
35 | expect(screen.getByText('Yo!')).toHaveClass('text-muted');
|
36 | });
|
37 |
|
38 | it('should render without "text-*" class when color is and empty string', () => {
|
39 | render(<FormText color="">Yo!</FormText>);
|
40 |
|
41 | expect(screen.getByText('Yo!')).not.toHaveClass('text-*');
|
42 | });
|
43 |
|
44 | it('should render with "text-${color}" class when color is provided', () => {
|
45 | render(<FormText color="yoyo">Yo!</FormText>);
|
46 |
|
47 | expect(screen.getByText('Yo!')).toHaveClass('text-yoyo');
|
48 | });
|
49 |
|
50 | it('should render additional classes', () => {
|
51 | testForCustomClass(FormText);
|
52 | });
|
53 |
|
54 | it('should render custom tag', () => {
|
55 | testForCustomTag(FormText);
|
56 | });
|
57 | });
|