-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathPluginHook.test.jsx
More file actions
42 lines (36 loc) · 1.43 KB
/
PluginHook.test.jsx
File metadata and controls
42 lines (36 loc) · 1.43 KB
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 { render, screen } from '@tests/utils/test-utils';
import { PluginHook } from '../../../src/components/PluginHook';
import { usePlugins } from '../../../src/extend/usePlugins';
vi.mock('../../../src/extend/usePlugins');
/** */
const mockComponentA = () => (
<div data-testid="testA" />
);
/** */
const mockComponentB = () => (
<div data-testid="testB" />
);
describe('WindowTopBarPluginArea', () => {
it('renders nothing when no plugins passed', () => {
vi.mocked(usePlugins).mockReturnValue({ PluginComponents: [] });
render(<PluginHook />);
expect(screen.queryByTestId('testA')).not.toBeInTheDocument();
expect(screen.queryByTestId('testB')).not.toBeInTheDocument();
});
it('renders plugin components if some passed', () => {
vi.mocked(usePlugins).mockReturnValue({ PluginComponents: [mockComponentA, mockComponentB] });
render(<PluginHook />);
expect(screen.getByTestId('testA')).toBeInTheDocument();
expect(screen.getByTestId('testB')).toBeInTheDocument();
});
it('does not pass classes to PluginComponents (which will throw warnings for styles plugins)', () => {
vi.mocked(usePlugins).mockReturnValue({ PluginComponents: [mockComponentA] });
render(
<PluginHook
classes={{ someLocal: 'classes' }}
/>,
);
// if called with nothing passed as args, .toHaveClass checks for existence of any classes
expect(screen.getByTestId('testA')).not.toHaveClass();
});
});