-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathAzureCommunicationCallAdapter.test.ts
More file actions
82 lines (75 loc) · 3.37 KB
/
AzureCommunicationCallAdapter.test.ts
File metadata and controls
82 lines (75 loc) · 3.37 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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/* @conditional-compile-remove(calling-sounds) */
import {
CommonCallAdapterOptions,
createAzureCommunicationCallAdapterFromClient
} from './AzureCommunicationCallAdapter';
/* @conditional-compile-remove(calling-sounds) */
import { MockCallAgent, MockCallClient } from '../../CallWithChatComposite/adapter/TestUtils';
/* @conditional-compile-remove(calling-sounds) */
import { StatefulCallClient } from '@internal/calling-stateful-client';
describe('Adapter is created as expected', () => {
test('test to fulfill no empty test runners', () => {
expect(true).toBeTruthy();
});
/* @conditional-compile-remove(calling-sounds) */
test('when cerating an adapter without sounds provided we should not see it in state', async () => {
const mockCallClient = new MockCallClient() as unknown as StatefulCallClient;
const mockCallAgent = new MockCallAgent();
const locator = { groupId: 'some group id' };
const adapter = await createAzureCommunicationCallAdapterFromClient(mockCallClient, mockCallAgent, locator);
expect(adapter).toBeDefined();
expect(adapter.getState().sounds).toBeUndefined();
});
/* @conditional-compile-remove(calling-sounds) */
test('when creating an adapter with sounds provided we should see it in state', async () => {
const mockCallClient = new MockCallClient() as unknown as StatefulCallClient;
const mockCallAgent = new MockCallAgent();
const locator = { groupId: 'some group id' };
const options: CommonCallAdapterOptions = {
callingSounds: {
callEnded: { url: 'test/url/ended' },
callRinging: { url: 'test/url/ringing' },
callBusy: { url: 'test/url/busy' }
}
};
const adapter = await createAzureCommunicationCallAdapterFromClient(
mockCallClient,
mockCallAgent,
locator,
options
);
expect(adapter).toBeDefined();
expect(adapter.getState().sounds).toBeDefined();
expect(adapter.getState().sounds?.callEnded).toBeDefined();
expect(adapter.getState().sounds?.callEnded).toEqual({ url: 'test/url/ended' });
expect(adapter.getState().sounds?.callRinging).toBeDefined();
expect(adapter.getState().sounds?.callRinging).toEqual({ url: 'test/url/ringing' });
expect(adapter.getState().sounds?.callBusy).toBeDefined();
expect(adapter.getState().sounds?.callBusy).toEqual({ url: 'test/url/busy' });
});
/* @conditional-compile-remove(calling-sounds) */
test('when creating an adapter with one sound we should see it and not the other', async () => {
const mockCallClient = new MockCallClient() as unknown as StatefulCallClient;
const mockCallAgent = new MockCallAgent();
const locator = { groupId: 'some group id' };
const options: CommonCallAdapterOptions = {
callingSounds: {
callEnded: { url: 'test/url/ended' }
}
};
const adapter = await createAzureCommunicationCallAdapterFromClient(
mockCallClient,
mockCallAgent,
locator,
options
);
expect(adapter).toBeDefined();
expect(adapter.getState().sounds).toBeDefined();
expect(adapter.getState().sounds?.callEnded).toBeDefined();
expect(adapter.getState().sounds?.callEnded).toEqual({ url: 'test/url/ended' });
expect(adapter.getState().sounds?.callRinging).toBeUndefined();
expect(adapter.getState().sounds?.callBusy).toBeUndefined();
});
});