forked from webex/widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
58 lines (52 loc) · 1.78 KB
/
index.tsx
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
import React from 'react';
import {render} from '@testing-library/react';
import * as helper from '../../src/helper';
import {CallControl} from '../../src';
import '@testing-library/jest-dom';
jest.mock('@momentum-ui/react-collaboration', () => ({
ButtonPill: () => <div data-testid="ButtonPill" />,
ListItemBase: () => <div data-testid="ListItemBase" />,
ListItemBaseSection: () => <div data-testid="ListItemBaseSection" />,
Text: () => <div data-testid="Text" />,
}));
jest.mock('@momentum-design/components/dist/react', () => ({
Avatar: () => <div data-testid="Avatar" />,
}));
// Mock the store
jest.mock('@webex/cc-store', () => ({
cc: {},
deviceType: 'BROWSER',
wrapupCodes: [],
logger: {},
currentTask: {
on: jest.fn(),
off: jest.fn(),
hold: jest.fn(() => Promise.resolve()),
resume: jest.fn(() => Promise.resolve()),
pauseRecording: jest.fn(() => Promise.resolve()),
resumeRecording: jest.fn(() => Promise.resolve()),
end: jest.fn(() => Promise.resolve()),
wrapup: jest.fn(() => Promise.resolve()),
},
TASK_EVENTS: {
TASK_MEDIA: 'task:media',
},
}));
const onHoldResumeCb = jest.fn();
const onEndCb = jest.fn();
const onWrapUpCb = jest.fn();
describe('CallControl Component', () => {
it('renders CallControlPresentational with correct props', () => {
const useCallControlSpy = jest.spyOn(helper, 'useCallControl');
render(<CallControl onHoldResume={onHoldResumeCb} onEnd={onEndCb} onWrapUp={onWrapUpCb} />);
// Assert that the useIncomingTask hook is called with the correct arguments
expect(useCallControlSpy).toHaveBeenCalledWith({
currentTask: expect.any(Object),
onHoldResume: onHoldResumeCb,
onEnd: onEndCb,
onWrapUp: onWrapUpCb,
logger: {},
deviceType: 'BROWSER',
});
});
});