1 | import React from 'react';
|
2 | import { render, screen } from '@testing-library/react';
|
3 | import '@testing-library/jest-dom';
|
4 | import Tooltip from '../Tooltip';
|
5 |
|
6 | describe('Tooltip', () => {
|
7 | let element;
|
8 | beforeEach(() => {
|
9 | element = document.createElement('div');
|
10 | element.setAttribute('id', 'tooltip-target');
|
11 | document.body.appendChild(element);
|
12 | });
|
13 |
|
14 | afterEach(() => {
|
15 | document.body.removeChild(element);
|
16 | });
|
17 |
|
18 | it('should apply popperClassName to popper component', () => {
|
19 | render(
|
20 | <Tooltip target="tooltip-target" popperClassName="boba-was-here" isOpen>
|
21 | Bo-Katan Kryze
|
22 | </Tooltip>,
|
23 | );
|
24 |
|
25 | expect(screen.queryByText('Bo-Katan Kryze')?.parentElement).toHaveClass(
|
26 | 'tooltip show boba-was-here',
|
27 | );
|
28 | });
|
29 |
|
30 | it('should apply arrowClassName to arrow', () => {
|
31 | render(
|
32 | <Tooltip target="tooltip-target" arrowClassName="boba-was-here" isOpen>
|
33 | Bo-Katan Kryze
|
34 | </Tooltip>,
|
35 | );
|
36 | expect(document.querySelector('.arrow')).toHaveClass('boba-was-here');
|
37 | });
|
38 | });
|