blob: 15966702f5caa11774641f2e3b7551ddd1e4394f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
import { describe, expect, it } from '@jest/globals';
import { render, screen as rtlScreen } from '../../../../../tests/utils';
import { Tooltip } from './tooltip';
const title = 'A custom title';
const children =
'Labore ullam delectus sit modi quam dolores. Ratione id sint aliquid facilis ipsum. Unde necessitatibus provident minus.';
describe('Tooltip', () => {
it('renders a title and a body', () => {
render(<Tooltip heading={title}>{children}</Tooltip>);
expect(rtlScreen.getByText(title)).toBeInTheDocument();
expect(rtlScreen.getByText(children)).toBeInTheDocument();
});
it('can render a hidden modal', () => {
render(
<Tooltip heading={title} isOpen={false}>
{children}
</Tooltip>
);
// Neither toBeVisible or toHaveStyle are working.
//expect(rtlScreen.getByText(children)).not.toBeVisible();
//expect(rtlScreen.getByText(children)).toHaveStyle({ visibility: 'hidden' });
expect(rtlScreen.getByText(children)).toHaveClass('tooltip--hidden');
});
it('can render a visible modal', () => {
render(
<Tooltip heading={title} isOpen>
{children}
</Tooltip>
);
expect(rtlScreen.getByText(children)).toBeVisible();
expect(rtlScreen.getByText(children)).toHaveStyle({
visibility: 'visible',
});
});
});
|