-
Notifications
You must be signed in to change notification settings - Fork 298
Expand file tree
/
Copy pathChannelListHeader.test.tsx
More file actions
53 lines (45 loc) · 1.86 KB
/
ChannelListHeader.test.tsx
File metadata and controls
53 lines (45 loc) · 1.86 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
43
44
45
46
47
48
49
50
51
52
53
import React from 'react';
import { cleanup, render, screen } from '@testing-library/react';
import { ChatProvider, WithComponents } from '../../../context';
import { TranslationProvider } from '../../../context/TranslationContext';
import { mockChatContext, mockTranslationContextValue } from '../../../mock-builders';
import { ChannelListHeader } from '../ChannelListHeader';
const t = vi.fn((key: string) => key);
const SidebarToggle = () => <div data-testid='sidebar-toggle' />;
afterEach(cleanup);
describe('ChannelListHeader', () => {
it('should not render SidebarToggle when not provided via ComponentContext', () => {
render(
<ChatProvider value={mockChatContext()}>
<TranslationProvider value={mockTranslationContextValue({ t })}>
<ChannelListHeader />
</TranslationProvider>
</ChatProvider>,
);
expect(screen.queryByTestId('sidebar-toggle')).not.toBeInTheDocument();
});
it('should render SidebarToggle when a channel is active', () => {
render(
<WithComponents overrides={{ SidebarToggle }}>
<ChatProvider value={mockChatContext({ channel: {} })}>
<TranslationProvider value={mockTranslationContextValue({ t })}>
<ChannelListHeader />
</TranslationProvider>
</ChatProvider>
</WithComponents>,
);
expect(screen.getByTestId('sidebar-toggle')).toBeInTheDocument();
});
it('should not render SidebarToggle when no channel is active', () => {
render(
<WithComponents overrides={{ SidebarToggle }}>
<ChatProvider value={mockChatContext({ channel: undefined })}>
<TranslationProvider value={mockTranslationContextValue({ t })}>
<ChannelListHeader />
</TranslationProvider>
</ChatProvider>
</WithComponents>,
);
expect(screen.queryByTestId('sidebar-toggle')).not.toBeInTheDocument();
});
});