forked from webex/widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
54 lines (49 loc) · 1.67 KB
/
Copy pathindex.tsx
File metadata and controls
54 lines (49 loc) · 1.67 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
import React from 'react';
import {render, screen, cleanup} from '@testing-library/react';
import '@testing-library/jest-dom';
import {TaskList} from '../../src/TaskList';
import * as helper from '../../src/helper';
import store from '@webex/cc-store';
// Mock `@webex/cc-store`.
const taskListMock = [
{id: 1, data: {interaction: {callAssociatedDetails: {ani: '1234567890'}}}},
{id: 2, data: {interaction: {callAssociatedDetails: {ani: '9876543210'}}}},
];
jest.mock('@webex/cc-store', () => ({
cc: {},
deviceType: 'BROWSER',
dialNumber: '12345',
onAccepted: jest.fn(),
onDeclined: jest.fn(),
taskList: taskListMock,
setTaskAssigned: jest.fn(),
setTaskRejected: jest.fn(),
setTaskSelected: jest.fn(),
isIncomingTask: jest.fn(),
logger: {
log: jest.fn(),
error: jest.fn(),
warn: jest.fn(),
info: jest.fn(),
},
}));
describe('TaskList Component', () => {
const helperSpy = jest.spyOn(helper, 'useTaskList');
afterEach(cleanup);
it('renders TaskListPresentational with the correct props', () => {
render(<TaskList onTaskAccepted={jest.fn()} onTaskDeclined={jest.fn()} onTaskSelected={jest.fn()} />);
// Assert that `TaskListPresentational` is rendered.
const taskListPresentational = screen.getByTestId('task-list');
expect(taskListPresentational).toBeInTheDocument();
// Verify that `useTaskList` is called with the correct arguments.
expect(helperSpy).toHaveBeenCalledWith({
cc: store.cc,
deviceType: 'BROWSER',
logger: store.logger,
onTaskAccepted: expect.any(Function),
onTaskDeclined: expect.any(Function),
onTaskSelected: expect.any(Function),
taskList: taskListMock,
});
});
});