-
Notifications
You must be signed in to change notification settings - Fork 554
Expand file tree
/
Copy pathChatInlineLayout.test.tsx
More file actions
91 lines (84 loc) · 2.63 KB
/
ChatInlineLayout.test.tsx
File metadata and controls
91 lines (84 loc) · 2.63 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* @jest-environment @instantsearch/testutils/jest-environment-jsdom.ts
*/
/** @jsx createElement */
import { render } from '@testing-library/preact';
import { createElement, Fragment } from 'preact';
import { createChatInlineLayoutComponent } from '../ChatInlineLayout';
const ChatInlineLayout = createChatInlineLayoutComponent({
createElement,
Fragment,
});
describe('ChatInlineLayout', () => {
const defaultProps = {
open: true,
maximized: false,
headerElement: <div className="header">Header</div>,
messagesElement: <div className="messages">Messages</div>,
promptElement: <div className="prompt">Prompt</div>,
toggleButtonElement: <button className="toggle">Toggle</button>,
messages: [],
status: 'ready' as const,
isClearing: false,
clearMessages: jest.fn(),
onClearTransitionEnd: jest.fn(),
tools: {},
};
test('renders with default props', () => {
const { container } = render(<ChatInlineLayout {...defaultProps} />);
expect(container).toMatchInlineSnapshot(`
<div>
<div
class="ais-Chat ais-ChatInlineLayout"
>
<div
class="ais-Chat-container ais-Chat-container--open"
>
<div
class="header"
>
Header
</div>
<div
class="messages"
>
Messages
</div>
<div
class="prompt"
>
Prompt
</div>
</div>
</div>
</div>
`);
});
test('does not render toggle button', () => {
const { container } = render(<ChatInlineLayout {...defaultProps} />);
expect(container.querySelector('.toggle')).not.toBeInTheDocument();
expect(
container.querySelector('.ais-Chat-toggleButtonWrapper')
).not.toBeInTheDocument();
});
test('accepts custom classNames', () => {
const { container } = render(
<ChatInlineLayout
{...defaultProps}
classNames={{ root: 'ROOT', container: 'CONTAINER' }}
/>
);
expect(container.querySelector('.ais-Chat')!.className).toBe(
'ais-Chat ais-ChatInlineLayout ROOT'
);
expect(container.querySelector('.ais-Chat-container')!.className).toBe(
'ais-Chat-container ais-Chat-container--open CONTAINER'
);
});
test('renders all slot elements', () => {
const { container } = render(<ChatInlineLayout {...defaultProps} />);
expect(container.querySelector('.header')).toBeInTheDocument();
expect(container.querySelector('.messages')).toBeInTheDocument();
expect(container.querySelector('.prompt')).toBeInTheDocument();
});
});