1 | import React from 'react';
|
2 | import { render, screen } from '@testing-library/react';
|
3 | import { FormFeedback } from '..';
|
4 | import {
|
5 | testForChildrenInComponent,
|
6 | testForCustomClass,
|
7 | testForCustomTag,
|
8 | testForDefaultClass,
|
9 | testForDefaultTag,
|
10 | } from '../testUtils';
|
11 |
|
12 | describe('FormFeedback', () => {
|
13 | it('should render with "div" tag by default', () => {
|
14 | testForDefaultTag(FormFeedback, 'div');
|
15 | });
|
16 |
|
17 | it('should render children', () => {
|
18 | testForChildrenInComponent(FormFeedback);
|
19 | });
|
20 |
|
21 | it('should render with "invalid-feedback" class', () => {
|
22 | testForDefaultClass(FormFeedback, 'invalid-feedback');
|
23 | });
|
24 |
|
25 | it('should render with "valid-feedback" class', () => {
|
26 | render(<FormFeedback valid>Yo!</FormFeedback>);
|
27 |
|
28 | expect(screen.getByText(/yo/i)).toHaveClass('valid-feedback');
|
29 | });
|
30 |
|
31 | it('should render with "valid-tooltip" class', () => {
|
32 | render(
|
33 | <FormFeedback valid tooltip>
|
34 | Yo!
|
35 | </FormFeedback>,
|
36 | );
|
37 |
|
38 | expect(screen.getByText(/yo/i)).toHaveClass('valid-tooltip');
|
39 | });
|
40 |
|
41 | it('should render additional classes', () => {
|
42 | testForCustomClass(FormFeedback);
|
43 | });
|
44 |
|
45 | it('should render custom tag', () => {
|
46 | testForCustomTag(FormFeedback);
|
47 | });
|
48 | });
|