-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathActivityRow.spec.tsx
More file actions
65 lines (55 loc) · 2.4 KB
/
ActivityRow.spec.tsx
File metadata and controls
65 lines (55 loc) · 2.4 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
/** @jest-environment @happy-dom/jest-environment */
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { act } from 'react-dom/test-utils';
import ActivityRow from './ActivityRow';
// Mock hooks
jest.mock('botframework-webchat-api', () => ({
hooks: {
useActivityKeysByRead: jest.fn(() => [[], () => { }]),
useGetHasAcknowledgedByActivityKey: jest.fn(() => () => true),
useGetKeyByActivity: jest.fn(() => (activity) => activity.id)
}
}), { virtual: true });
jest.mock('../providers/TranscriptFocus/useActiveDescendantId', () => jest.fn(() => [null]));
jest.mock('../providers/TranscriptFocus/useFocusByActivityKey', () => jest.fn(() => () => { }));
jest.mock('../providers/TranscriptFocus/useGetDescendantIdByActivityKey', () => jest.fn(() => () => 'descendant-id'));
jest.mock('./useActivityAccessibleName', () => jest.fn(() => ['Accessible Name']));
jest.mock('../hooks/internal/styleToEmotionObject', () => ({
useStyleToEmotionObject: jest.fn(() => () => 'mock-class-name')
}));
jest.mock('./TranscriptFocus', () => ({
TranscriptFocusContent: ({ children, ...props }) => <div {...props}>{children}</div>,
TranscriptFocusContentActiveDescendant: ({ children, ...props }) => <div {...props}>{children}</div>,
TranscriptFocusContentOverlay: ({ children }) => <div>{children}</div>,
TranscriptFocusIndicator: () => <div />
}));
jest.mock('./FocusTrap', () => ({ children }) => <div>{children}</div>);
jest.mock('../Activity/Speak', () => () => null);
describe('ActivityRow', () => {
let container: HTMLDivElement;
beforeEach(() => {
container = document.createElement('div');
document.body.appendChild(container);
});
afterEach(() => {
unmountComponentAtNode(container);
container.remove();
container = null;
});
it('should render an h6 header with accessible name', () => {
const activity = {
id: 'activity-1',
type: 'message',
text: 'Hello World'
};
act(() => {
render(<ActivityRow activity={activity} />, container);
});
const header = container.querySelector('h6');
expect(header).toBeTruthy();
expect(header.textContent).toBe('Accessible Name');
expect(header.getAttribute('aria-hidden')).toBeNull();
expect(header.className).toBe('mock-class-name');
});
});