softphone-vendor-headsets 2.4.3 → 2.4.5-develop.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/1.softhphone-vendor-headsets.js +1 -1
- package/dist/2.softhphone-vendor-headsets.js +1 -1
- package/dist/3.softhphone-vendor-headsets.js +1 -1
- package/dist/cjs/src/library/index.d.ts +1 -0
- package/dist/cjs/src/library/index.js +1 -0
- package/dist/cjs/src/library/index.js.map +1 -1
- package/dist/cjs/src/library/services/headset.d.ts +3 -1
- package/dist/cjs/src/library/services/headset.js +10 -7
- package/dist/cjs/src/library/services/headset.js.map +1 -1
- package/dist/cjs/src/library/services/headset.test.js +2 -2
- package/dist/cjs/src/library/services/vendor-implementations/plantronics/plantronics.d.ts +2 -1
- package/dist/cjs/src/library/services/vendor-implementations/plantronics/plantronics.js +4 -2
- package/dist/cjs/src/library/services/vendor-implementations/plantronics/plantronics.js.map +1 -1
- package/dist/cjs/src/library/services/vendor-implementations/plantronics/plantronics.test.js +11 -0
- package/dist/cjs/src/library/services/vendor-implementations/plantronics/plantronics.test.js.map +1 -1
- package/dist/cjs/src/library/services/vendor-implementations/vbet/vbet.d.ts +34 -0
- package/dist/cjs/src/library/services/vendor-implementations/vbet/vbet.js +399 -0
- package/dist/cjs/src/library/services/vendor-implementations/vbet/vbet.js.map +1 -0
- package/dist/cjs/src/library/services/vendor-implementations/vbet/vbet.test.d.ts +1 -0
- package/dist/cjs/src/library/services/vendor-implementations/vbet/vbet.test.js +679 -0
- package/dist/cjs/src/library/services/vendor-implementations/vbet/vbet.test.js.map +1 -0
- package/dist/cjs/src/library/services/vendor-implementations/vendor-implementation.d.ts +2 -1
- package/dist/cjs/src/library/services/vendor-implementations/vendor-implementation.js +1 -1
- package/dist/cjs/src/library/services/vendor-implementations/vendor-implementation.js.map +1 -1
- package/dist/cjs/src/library/types/headset-states.d.ts +1 -0
- package/dist/deploy-info.json +57 -21
- package/dist/es/src/library/index.d.ts +1 -0
- package/dist/es/src/library/index.js +1 -0
- package/dist/es/src/library/index.js.map +1 -1
- package/dist/es/src/library/services/headset.d.ts +3 -1
- package/dist/es/src/library/services/headset.js +10 -7
- package/dist/es/src/library/services/headset.js.map +1 -1
- package/dist/es/src/library/services/headset.test.js +2 -2
- package/dist/es/src/library/services/vendor-implementations/plantronics/plantronics.d.ts +2 -1
- package/dist/es/src/library/services/vendor-implementations/plantronics/plantronics.js +4 -2
- package/dist/es/src/library/services/vendor-implementations/plantronics/plantronics.js.map +1 -1
- package/dist/es/src/library/services/vendor-implementations/plantronics/plantronics.test.js +11 -0
- package/dist/es/src/library/services/vendor-implementations/plantronics/plantronics.test.js.map +1 -1
- package/dist/es/src/library/services/vendor-implementations/vbet/vbet.d.ts +34 -0
- package/dist/es/src/library/services/vendor-implementations/vbet/vbet.js +396 -0
- package/dist/es/src/library/services/vendor-implementations/vbet/vbet.js.map +1 -0
- package/dist/es/src/library/services/vendor-implementations/vbet/vbet.test.d.ts +1 -0
- package/dist/es/src/library/services/vendor-implementations/vbet/vbet.test.js +674 -0
- package/dist/es/src/library/services/vendor-implementations/vbet/vbet.test.js.map +1 -0
- package/dist/es/src/library/services/vendor-implementations/vendor-implementation.d.ts +2 -1
- package/dist/es/src/library/services/vendor-implementations/vendor-implementation.js +1 -1
- package/dist/es/src/library/services/vendor-implementations/vendor-implementation.js.map +1 -1
- package/dist/es/src/library/types/headset-states.d.ts +1 -0
- package/dist/softhphone-vendor-headsets.js +4 -4
- package/dist/softhphone-vendor-headsets.js.map +1 -1
- package/package.json +81 -79
|
@@ -0,0 +1,679 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const vbet_1 = __importDefault(require("./vbet"));
|
|
16
|
+
const mockTestDevName = 'Test VBet Dev';
|
|
17
|
+
const mockDeviceList0 = [];
|
|
18
|
+
const mockDeviceList1 = [
|
|
19
|
+
{
|
|
20
|
+
open: jest.fn(),
|
|
21
|
+
close: jest.fn(),
|
|
22
|
+
sendReport: jest.fn(),
|
|
23
|
+
addEventListener: jest.fn((name, callback) => {
|
|
24
|
+
callback({
|
|
25
|
+
reportId: 0x08,
|
|
26
|
+
data: {
|
|
27
|
+
getUint8: jest.fn(),
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}),
|
|
31
|
+
productName: mockTestDevName,
|
|
32
|
+
productId: 0x0001,
|
|
33
|
+
collections: [
|
|
34
|
+
{
|
|
35
|
+
usage: 0x0005,
|
|
36
|
+
usagePage: 0x000b,
|
|
37
|
+
inputReports: [
|
|
38
|
+
{
|
|
39
|
+
reportId: 0x08,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
const mockDeviceList2 = [
|
|
47
|
+
{
|
|
48
|
+
open: jest.fn(),
|
|
49
|
+
close: jest.fn(),
|
|
50
|
+
addEventListener: jest.fn((name, callback) => {
|
|
51
|
+
callback({
|
|
52
|
+
reportId: 0x01,
|
|
53
|
+
data: {
|
|
54
|
+
getUint8: jest.fn(),
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}),
|
|
58
|
+
productName: mockTestDevName,
|
|
59
|
+
collections: [
|
|
60
|
+
{
|
|
61
|
+
usage: 0,
|
|
62
|
+
usagePage: 0,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
const mockDeviceList3 = [
|
|
68
|
+
{
|
|
69
|
+
open: jest.fn(),
|
|
70
|
+
close: jest.fn(),
|
|
71
|
+
addEventListener: jest.fn((name, callback) => {
|
|
72
|
+
callback({
|
|
73
|
+
reportId: 0x01,
|
|
74
|
+
data: {
|
|
75
|
+
getUint8: jest.fn(),
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
}),
|
|
79
|
+
productName: mockTestDevName,
|
|
80
|
+
collections: [
|
|
81
|
+
{
|
|
82
|
+
usage: 0x0005,
|
|
83
|
+
usagePage: 0x000b,
|
|
84
|
+
inputReports: [],
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
const mockDeviceList5 = [
|
|
90
|
+
{
|
|
91
|
+
open: jest.fn(),
|
|
92
|
+
close: jest.fn(),
|
|
93
|
+
sendReport: jest.fn(),
|
|
94
|
+
addEventListener: jest.fn((name, callback) => {
|
|
95
|
+
callback({
|
|
96
|
+
reportId: 0x01,
|
|
97
|
+
data: {
|
|
98
|
+
getUint8: jest.fn(),
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}),
|
|
102
|
+
productName: mockTestDevName,
|
|
103
|
+
productId: 0x0020,
|
|
104
|
+
collections: [
|
|
105
|
+
{
|
|
106
|
+
usage: 0x0005,
|
|
107
|
+
usagePage: 0x000b,
|
|
108
|
+
inputReports: [
|
|
109
|
+
{
|
|
110
|
+
reportId: 0x01,
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
const mockDeviceList6 = [
|
|
118
|
+
{
|
|
119
|
+
open: jest.fn(),
|
|
120
|
+
close: jest.fn(),
|
|
121
|
+
sendReport: jest.fn(),
|
|
122
|
+
addEventListener: jest.fn((name, callback) => {
|
|
123
|
+
callback({
|
|
124
|
+
reportId: 0x01,
|
|
125
|
+
data: {
|
|
126
|
+
getUint8: jest.fn(),
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}),
|
|
130
|
+
productName: mockTestDevName,
|
|
131
|
+
productId: 0x0014,
|
|
132
|
+
collections: [
|
|
133
|
+
{
|
|
134
|
+
usage: 0x0005,
|
|
135
|
+
usagePage: 0x000b,
|
|
136
|
+
inputReports: [
|
|
137
|
+
{
|
|
138
|
+
reportId: 0x01,
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
];
|
|
145
|
+
const mockDeviceList7 = [
|
|
146
|
+
{
|
|
147
|
+
open: jest.fn(),
|
|
148
|
+
close: jest.fn(),
|
|
149
|
+
sendReport: jest.fn(),
|
|
150
|
+
addEventListener: jest.fn((name, callback) => {
|
|
151
|
+
callback({
|
|
152
|
+
reportId: 0x05,
|
|
153
|
+
data: {
|
|
154
|
+
getUint8: jest.fn(),
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
}),
|
|
158
|
+
productName: mockTestDevName,
|
|
159
|
+
productId: 0x0040,
|
|
160
|
+
collections: [
|
|
161
|
+
{
|
|
162
|
+
usage: 0x0005,
|
|
163
|
+
usagePage: 0x000b,
|
|
164
|
+
inputReports: [
|
|
165
|
+
{
|
|
166
|
+
reportId: 0x05,
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
const mockOffhookFlag = {
|
|
174
|
+
BT100USeries: 0x04,
|
|
175
|
+
CMEDIASeries: 0x01,
|
|
176
|
+
DECTSeries: 0x02,
|
|
177
|
+
ACTIONSeries: 0x20,
|
|
178
|
+
};
|
|
179
|
+
const mockOnhookFlag = {
|
|
180
|
+
BT100USeries: 0x00,
|
|
181
|
+
CMEDIASeries: 0x00,
|
|
182
|
+
DECTSeries: 0x00,
|
|
183
|
+
ACTIONSeries: 0x00,
|
|
184
|
+
};
|
|
185
|
+
const mockMuteFlag = {
|
|
186
|
+
BT100USeries: 0x0c,
|
|
187
|
+
CMEDIASeries: 0x14,
|
|
188
|
+
DECTSeries: [0x03, 0x04],
|
|
189
|
+
ACTIONSeries: [0x05, 0x01],
|
|
190
|
+
};
|
|
191
|
+
const mockReject = { BT100USeries: 0x10, ACTIONSeries: 0x08 };
|
|
192
|
+
describe('VBetservice', () => {
|
|
193
|
+
let vbetService;
|
|
194
|
+
let mockDeviceList = mockDeviceList0;
|
|
195
|
+
let mockReqDeviceList = mockDeviceList0;
|
|
196
|
+
Object.defineProperty(window.navigator, 'hid', {
|
|
197
|
+
get: () => ({
|
|
198
|
+
getDevices: () => {
|
|
199
|
+
return mockDeviceList;
|
|
200
|
+
},
|
|
201
|
+
requestDevice: () => {
|
|
202
|
+
mockDeviceList = mockReqDeviceList;
|
|
203
|
+
},
|
|
204
|
+
}),
|
|
205
|
+
});
|
|
206
|
+
beforeEach(() => {
|
|
207
|
+
mockDeviceList = mockDeviceList0;
|
|
208
|
+
mockReqDeviceList = mockDeviceList0;
|
|
209
|
+
vbetService = vbet_1.default.getInstance({ logger: console });
|
|
210
|
+
});
|
|
211
|
+
afterEach(() => {
|
|
212
|
+
vbetService = null;
|
|
213
|
+
jest.restoreAllMocks();
|
|
214
|
+
});
|
|
215
|
+
describe('instantiation', () => {
|
|
216
|
+
it('should be a singleton', () => {
|
|
217
|
+
const vbetService2 = vbet_1.default.getInstance({ logger: console });
|
|
218
|
+
expect(vbetService).not.toBeFalsy();
|
|
219
|
+
expect(vbetService2).not.toBeFalsy();
|
|
220
|
+
expect(vbetService).toBe(vbetService2);
|
|
221
|
+
});
|
|
222
|
+
it('should have the correct vendorName', () => {
|
|
223
|
+
expect(vbetService.vendorName).toEqual('VBet');
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
describe('isSupported', () => {
|
|
227
|
+
it('should return true if proper values are met', () => {
|
|
228
|
+
expect(vbetService.isSupported()).toBe(true);
|
|
229
|
+
});
|
|
230
|
+
it('should return false if proper values are not met', () => {
|
|
231
|
+
Object.defineProperty(window, '_HostedContextFunctions', { get: () => true });
|
|
232
|
+
expect(vbetService.isSupported()).toBe(false);
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
describe('deviceLabelMatchesVendor', () => {
|
|
236
|
+
it('deviceLabelMatchesVendor', () => {
|
|
237
|
+
let result;
|
|
238
|
+
result = vbetService.deviceLabelMatchesVendor('Test vt Label');
|
|
239
|
+
expect(result).toBe(true);
|
|
240
|
+
result = vbetService.deviceLabelMatchesVendor('Something test');
|
|
241
|
+
expect(result).toBe(false);
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
describe('connect', () => {
|
|
245
|
+
afterEach(() => {
|
|
246
|
+
vbetService.disconnect();
|
|
247
|
+
});
|
|
248
|
+
it('should connect with previouslyConnectedDevice', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
249
|
+
const statusChangeSpy = jest.spyOn(vbetService, 'changeConnectionStatus');
|
|
250
|
+
mockDeviceList = mockDeviceList1;
|
|
251
|
+
yield vbetService.connect(mockTestDevName);
|
|
252
|
+
const devName = vbetService.deviceInfo;
|
|
253
|
+
expect(devName.ProductName).toBe(mockTestDevName);
|
|
254
|
+
expect(statusChangeSpy).toHaveBeenCalledWith({ isConnected: true, isConnecting: false });
|
|
255
|
+
}));
|
|
256
|
+
it('already have active device', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
257
|
+
const statusChangeSpy = jest.spyOn(vbetService, 'changeConnectionStatus');
|
|
258
|
+
mockDeviceList = mockDeviceList1;
|
|
259
|
+
yield vbetService.connect(mockTestDevName);
|
|
260
|
+
yield vbetService.connect(mockTestDevName);
|
|
261
|
+
expect(statusChangeSpy).toHaveBeenCalledWith({ isConnected: true, isConnecting: false });
|
|
262
|
+
}));
|
|
263
|
+
it('device usage not match', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
264
|
+
const statusChangeSpy = jest.spyOn(vbetService, 'changeConnectionStatus');
|
|
265
|
+
vbetService.requestWebHidPermissions = jest.fn((callback) => {
|
|
266
|
+
mockReqDeviceList = mockDeviceList0;
|
|
267
|
+
callback();
|
|
268
|
+
});
|
|
269
|
+
mockDeviceList = mockDeviceList2;
|
|
270
|
+
yield vbetService.connect(mockTestDevName);
|
|
271
|
+
expect(statusChangeSpy).toHaveBeenCalledWith({ isConnected: false, isConnecting: false });
|
|
272
|
+
}));
|
|
273
|
+
it('device inputReports is empty', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
274
|
+
vbetService.requestWebHidPermissions = jest.fn((callback) => {
|
|
275
|
+
mockReqDeviceList = mockDeviceList0;
|
|
276
|
+
callback();
|
|
277
|
+
});
|
|
278
|
+
mockDeviceList = mockDeviceList3;
|
|
279
|
+
yield vbetService.connect(mockTestDevName);
|
|
280
|
+
expect(vbetService.isConnected).toBe(true);
|
|
281
|
+
expect(vbetService.isConnecting).toBe(false);
|
|
282
|
+
}));
|
|
283
|
+
it('previouslyConnectedDevice not have device', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
284
|
+
const statusChangeSpy = jest.spyOn(vbetService, 'changeConnectionStatus');
|
|
285
|
+
vbetService.requestWebHidPermissions = jest.fn((callback) => {
|
|
286
|
+
mockReqDeviceList = mockDeviceList0;
|
|
287
|
+
callback();
|
|
288
|
+
});
|
|
289
|
+
mockDeviceList = mockDeviceList1;
|
|
290
|
+
yield vbetService.connect('test');
|
|
291
|
+
expect(statusChangeSpy).toHaveBeenCalledWith({ isConnected: false, isConnecting: false });
|
|
292
|
+
}));
|
|
293
|
+
it('webhidRequest, 30s timeout, failed to connect', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
294
|
+
const statusChangeSpy = jest.spyOn(vbetService, 'changeConnectionStatus');
|
|
295
|
+
jest.useFakeTimers();
|
|
296
|
+
const requestSpy = (vbetService.requestWebHidPermissions = jest.fn(() => {
|
|
297
|
+
jest.advanceTimersByTime(30100);
|
|
298
|
+
}));
|
|
299
|
+
yield vbetService.connect(mockTestDevName);
|
|
300
|
+
expect(requestSpy).toHaveBeenCalled();
|
|
301
|
+
expect(statusChangeSpy).toHaveBeenCalledWith({ isConnected: false, isConnecting: true });
|
|
302
|
+
jest.clearAllTimers();
|
|
303
|
+
jest.useRealTimers();
|
|
304
|
+
}));
|
|
305
|
+
it('webhidRequest, connect success', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
306
|
+
const statusChangeSpy = jest.spyOn(vbetService, 'changeConnectionStatus');
|
|
307
|
+
const requestSpy = (vbetService.requestWebHidPermissions = jest.fn((callback) => {
|
|
308
|
+
mockReqDeviceList = mockDeviceList1;
|
|
309
|
+
callback();
|
|
310
|
+
}));
|
|
311
|
+
yield vbetService.connect(mockTestDevName);
|
|
312
|
+
expect(requestSpy).toHaveBeenCalled();
|
|
313
|
+
expect(statusChangeSpy).toHaveBeenCalledWith({ isConnected: true, isConnecting: false });
|
|
314
|
+
}));
|
|
315
|
+
it('webhidRequest, connect fail', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
316
|
+
const statusChangeSpy = jest.spyOn(vbetService, 'changeConnectionStatus');
|
|
317
|
+
const requestSpy = (vbetService.requestWebHidPermissions = jest.fn((callback) => {
|
|
318
|
+
callback();
|
|
319
|
+
}));
|
|
320
|
+
yield vbetService.connect(mockTestDevName);
|
|
321
|
+
expect(requestSpy).toHaveBeenCalled();
|
|
322
|
+
expect(statusChangeSpy).toHaveBeenCalledWith({ isConnected: false, isConnecting: false });
|
|
323
|
+
}));
|
|
324
|
+
it('webhidRequest, connect fail, device name error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
325
|
+
const statusChangeSpy = jest.spyOn(vbetService, 'changeConnectionStatus');
|
|
326
|
+
const requestSpy = (vbetService.requestWebHidPermissions = jest.fn((callback) => {
|
|
327
|
+
mockReqDeviceList = mockDeviceList1;
|
|
328
|
+
callback();
|
|
329
|
+
}));
|
|
330
|
+
yield vbetService.connect('test');
|
|
331
|
+
expect(requestSpy).toHaveBeenCalled();
|
|
332
|
+
expect(statusChangeSpy).toHaveBeenCalledWith({ isConnected: false, isConnecting: false });
|
|
333
|
+
}));
|
|
334
|
+
it('webhidRequest, connect fail, device usage error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
335
|
+
const statusChangeSpy = jest.spyOn(vbetService, 'changeConnectionStatus');
|
|
336
|
+
const requestSpy = (vbetService.requestWebHidPermissions = jest.fn((callback) => {
|
|
337
|
+
mockReqDeviceList = mockDeviceList2;
|
|
338
|
+
callback();
|
|
339
|
+
}));
|
|
340
|
+
yield vbetService.connect(mockTestDevName);
|
|
341
|
+
expect(requestSpy).toHaveBeenCalled();
|
|
342
|
+
expect(statusChangeSpy).toHaveBeenCalledWith({ isConnected: false, isConnecting: false });
|
|
343
|
+
}));
|
|
344
|
+
it('webhidRequest, device inputReports is empty', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
345
|
+
vbetService.requestWebHidPermissions = jest.fn((callback) => {
|
|
346
|
+
mockReqDeviceList = mockDeviceList3;
|
|
347
|
+
callback();
|
|
348
|
+
});
|
|
349
|
+
yield vbetService.connect(mockTestDevName);
|
|
350
|
+
expect(vbetService.isConnected).toBe(true);
|
|
351
|
+
expect(vbetService.isConnecting).toBe(false);
|
|
352
|
+
}));
|
|
353
|
+
});
|
|
354
|
+
describe('disconnect', () => {
|
|
355
|
+
it('test disconnect', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
356
|
+
mockDeviceList = mockDeviceList1;
|
|
357
|
+
vbetService.isConnecting = true;
|
|
358
|
+
yield vbetService.connect(mockTestDevName);
|
|
359
|
+
yield vbetService.disconnect();
|
|
360
|
+
expect(vbetService.isConnecting).toBe(false);
|
|
361
|
+
expect(vbetService.isConnected).toBe(false);
|
|
362
|
+
}));
|
|
363
|
+
});
|
|
364
|
+
describe('processBtnPress BT100USeries', () => {
|
|
365
|
+
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
366
|
+
mockDeviceList = mockDeviceList1;
|
|
367
|
+
yield vbetService.connect(mockTestDevName);
|
|
368
|
+
}));
|
|
369
|
+
afterEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
370
|
+
yield vbetService.endAllCalls();
|
|
371
|
+
yield vbetService.disconnect();
|
|
372
|
+
}));
|
|
373
|
+
it('activeDevice is null', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
374
|
+
const ansFun = jest.spyOn(vbetService, 'answerCall');
|
|
375
|
+
yield vbetService.disconnect();
|
|
376
|
+
yield vbetService.processBtnPress(mockOffhookFlag.BT100USeries);
|
|
377
|
+
expect(ansFun).not.toHaveBeenCalled();
|
|
378
|
+
}));
|
|
379
|
+
it('test offhook', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
380
|
+
const ansFun = jest.spyOn(vbetService, 'answerCall');
|
|
381
|
+
const devAnsFun = jest.spyOn(vbetService, 'deviceAnsweredCall');
|
|
382
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
383
|
+
yield vbetService.processBtnPress(mockOffhookFlag.BT100USeries);
|
|
384
|
+
expect(ansFun).toHaveBeenCalled();
|
|
385
|
+
expect(devAnsFun).toHaveBeenCalled();
|
|
386
|
+
}));
|
|
387
|
+
it('test offhook but no active conversion id', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
388
|
+
const ansFun = jest.spyOn(vbetService, 'sendOpToDevice');
|
|
389
|
+
const devAnsFun = jest.spyOn(vbetService, 'deviceAnsweredCall');
|
|
390
|
+
yield vbetService.processBtnPress(mockOffhookFlag.BT100USeries);
|
|
391
|
+
expect(ansFun).not.toHaveBeenCalledWith('offHook');
|
|
392
|
+
expect(devAnsFun).not.toHaveBeenCalled();
|
|
393
|
+
}));
|
|
394
|
+
it('test onhook', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
395
|
+
const ansFun = jest.spyOn(vbetService, 'endCallFromDevice');
|
|
396
|
+
const devAnsFun = jest.spyOn(vbetService, 'deviceEndedCall');
|
|
397
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
398
|
+
yield vbetService.processBtnPress(mockOffhookFlag.BT100USeries);
|
|
399
|
+
yield vbetService.processBtnPress(mockOnhookFlag.BT100USeries);
|
|
400
|
+
expect(ansFun).toHaveBeenCalled();
|
|
401
|
+
expect(devAnsFun).toHaveBeenCalled();
|
|
402
|
+
}));
|
|
403
|
+
it('test onhook but no active conversion id', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
404
|
+
const ansFun = jest.spyOn(vbetService, 'sendOpToDevice');
|
|
405
|
+
const devAnsFun = jest.spyOn(vbetService, 'deviceEndedCall');
|
|
406
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
407
|
+
yield vbetService.processBtnPress(mockOffhookFlag.BT100USeries);
|
|
408
|
+
vbetService.activeConversationId = null;
|
|
409
|
+
yield vbetService.processBtnPress(mockOnhookFlag.BT100USeries);
|
|
410
|
+
expect(ansFun).not.toHaveBeenCalledWith('onHook');
|
|
411
|
+
expect(devAnsFun).not.toHaveBeenCalled();
|
|
412
|
+
}));
|
|
413
|
+
it('test mute', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
414
|
+
const setMuteFun = jest.spyOn(vbetService, 'setMute');
|
|
415
|
+
const devMuteFun = jest.spyOn(vbetService, 'deviceMuteChanged');
|
|
416
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
417
|
+
yield vbetService.processBtnPress(mockOffhookFlag.BT100USeries);
|
|
418
|
+
yield vbetService.processBtnPress(mockMuteFlag.BT100USeries);
|
|
419
|
+
expect(setMuteFun).toHaveBeenCalledWith(true);
|
|
420
|
+
expect(devMuteFun).toHaveBeenCalledWith({
|
|
421
|
+
isMuted: true,
|
|
422
|
+
name: 'CallMuted',
|
|
423
|
+
conversationId: 'id',
|
|
424
|
+
});
|
|
425
|
+
}));
|
|
426
|
+
it('test unmute', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
427
|
+
const setMuteFun = jest.spyOn(vbetService, 'setMute');
|
|
428
|
+
const devMuteFun = jest.spyOn(vbetService, 'deviceMuteChanged');
|
|
429
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
430
|
+
yield vbetService.processBtnPress(mockOffhookFlag.BT100USeries);
|
|
431
|
+
yield vbetService.processBtnPress(mockMuteFlag.BT100USeries);
|
|
432
|
+
yield vbetService.processBtnPress(mockMuteFlag.BT100USeries);
|
|
433
|
+
expect(setMuteFun).toHaveBeenCalledTimes(2);
|
|
434
|
+
expect(devMuteFun).toHaveBeenCalledTimes(2);
|
|
435
|
+
}));
|
|
436
|
+
it('test rejectCall', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
437
|
+
const devRejectFun = jest.spyOn(vbetService, 'deviceRejectedCall');
|
|
438
|
+
const setRejectFun = jest.spyOn(vbetService, 'rejectCall');
|
|
439
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
440
|
+
yield vbetService.processBtnPress(mockReject.BT100USeries);
|
|
441
|
+
expect(devRejectFun).toHaveBeenCalledWith({ name: 'Reject', conversationId: 'id' });
|
|
442
|
+
expect(setRejectFun).toHaveBeenCalled();
|
|
443
|
+
}));
|
|
444
|
+
it('test outgoing call', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
445
|
+
const ansFun = jest.spyOn(vbetService, 'endCallFromDevice');
|
|
446
|
+
const devAnsFun = jest.spyOn(vbetService, 'deviceEndedCall');
|
|
447
|
+
yield vbetService.outgoingCall({ conversationId: 'id' });
|
|
448
|
+
yield vbetService.processBtnPress(mockOnhookFlag.BT100USeries);
|
|
449
|
+
expect(ansFun).toHaveBeenCalled();
|
|
450
|
+
expect(devAnsFun).toHaveBeenCalled();
|
|
451
|
+
}));
|
|
452
|
+
it('test auto answer call', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
453
|
+
const ansFun = jest.spyOn(vbetService, 'sendOpToDevice');
|
|
454
|
+
yield vbetService.answerCall('id', true);
|
|
455
|
+
expect(ansFun).toHaveBeenCalledWith('ring');
|
|
456
|
+
expect(ansFun).toHaveBeenCalledWith('offHook');
|
|
457
|
+
}));
|
|
458
|
+
});
|
|
459
|
+
describe('processBtnPress CMEDIASeries', () => {
|
|
460
|
+
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
461
|
+
mockDeviceList = mockDeviceList5;
|
|
462
|
+
yield vbetService.connect(mockTestDevName);
|
|
463
|
+
}));
|
|
464
|
+
afterEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
465
|
+
yield vbetService.endAllCalls();
|
|
466
|
+
yield vbetService.disconnect();
|
|
467
|
+
}));
|
|
468
|
+
it('activeDevice is null', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
469
|
+
yield vbetService.disconnect();
|
|
470
|
+
const ansFun = jest.spyOn(vbetService, 'answerCall');
|
|
471
|
+
yield vbetService.processBtnPress(mockOffhookFlag.CMEDIASeries);
|
|
472
|
+
expect(ansFun).not.toHaveBeenCalled();
|
|
473
|
+
}));
|
|
474
|
+
it('test offhook', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
475
|
+
const ansFun = jest.spyOn(vbetService, 'answerCall');
|
|
476
|
+
const devAnsFun = jest.spyOn(vbetService, 'deviceAnsweredCall');
|
|
477
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
478
|
+
yield vbetService.processBtnPress(mockOffhookFlag.CMEDIASeries);
|
|
479
|
+
expect(ansFun).toHaveBeenCalled();
|
|
480
|
+
expect(devAnsFun).toHaveBeenCalled();
|
|
481
|
+
}));
|
|
482
|
+
it('test mute', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
483
|
+
const setMuteFun = jest.spyOn(vbetService, 'setMute');
|
|
484
|
+
const devMuteFun = jest.spyOn(vbetService, 'deviceMuteChanged');
|
|
485
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
486
|
+
yield vbetService.processBtnPress(mockOffhookFlag.CMEDIASeries);
|
|
487
|
+
yield vbetService.processBtnPress(mockMuteFlag.CMEDIASeries);
|
|
488
|
+
expect(setMuteFun).toHaveBeenCalledWith(true);
|
|
489
|
+
expect(devMuteFun).toHaveBeenCalledWith({
|
|
490
|
+
isMuted: true,
|
|
491
|
+
name: 'CallMuted',
|
|
492
|
+
conversationId: 'id',
|
|
493
|
+
});
|
|
494
|
+
}));
|
|
495
|
+
it('test mute', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
496
|
+
const setMuteFun = jest.spyOn(vbetService, 'setMute');
|
|
497
|
+
const devMuteFun = jest.spyOn(vbetService, 'deviceMuteChanged');
|
|
498
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
499
|
+
yield vbetService.processBtnPress(mockOffhookFlag.CMEDIASeries);
|
|
500
|
+
yield vbetService.processBtnPress(0x08);
|
|
501
|
+
yield vbetService.processBtnPress(0x00);
|
|
502
|
+
expect(setMuteFun).toHaveBeenCalledWith(true);
|
|
503
|
+
expect(devMuteFun).toHaveBeenCalledWith({
|
|
504
|
+
isMuted: true,
|
|
505
|
+
name: 'CallMuted',
|
|
506
|
+
conversationId: 'id',
|
|
507
|
+
});
|
|
508
|
+
}));
|
|
509
|
+
it('test outgoing call', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
510
|
+
const ansFun = jest.spyOn(vbetService, 'endCallFromDevice');
|
|
511
|
+
const devAnsFun = jest.spyOn(vbetService, 'deviceEndedCall');
|
|
512
|
+
yield vbetService.outgoingCall({ conversationId: 'id' });
|
|
513
|
+
yield vbetService.processBtnPress(mockOnhookFlag.CMEDIASeries);
|
|
514
|
+
expect(ansFun).toHaveBeenCalled();
|
|
515
|
+
expect(devAnsFun).toHaveBeenCalled();
|
|
516
|
+
}));
|
|
517
|
+
});
|
|
518
|
+
describe('processBtnPress DECTSeries', () => {
|
|
519
|
+
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
520
|
+
mockDeviceList = mockDeviceList6;
|
|
521
|
+
yield vbetService.connect(mockTestDevName);
|
|
522
|
+
}));
|
|
523
|
+
afterEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
524
|
+
yield vbetService.endAllCalls();
|
|
525
|
+
yield vbetService.disconnect();
|
|
526
|
+
}));
|
|
527
|
+
it('activeDevice is null', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
528
|
+
yield vbetService.disconnect();
|
|
529
|
+
const ansFun = jest.spyOn(vbetService, 'answerCall');
|
|
530
|
+
yield vbetService.processBtnPress(mockOffhookFlag.DECTSeries);
|
|
531
|
+
expect(ansFun).not.toHaveBeenCalled();
|
|
532
|
+
}));
|
|
533
|
+
it('test offhook', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
534
|
+
const ansFun = jest.spyOn(vbetService, 'answerCall');
|
|
535
|
+
const devAnsFun = jest.spyOn(vbetService, 'deviceAnsweredCall');
|
|
536
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
537
|
+
yield vbetService.processBtnPress(mockOffhookFlag.DECTSeries);
|
|
538
|
+
expect(ansFun).toHaveBeenCalled();
|
|
539
|
+
expect(devAnsFun).toHaveBeenCalled();
|
|
540
|
+
}));
|
|
541
|
+
it('test mute', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
542
|
+
const setMuteFun = jest.spyOn(vbetService, 'setMute');
|
|
543
|
+
const devMuteFun = jest.spyOn(vbetService, 'deviceMuteChanged');
|
|
544
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
545
|
+
yield vbetService.processBtnPress(mockOffhookFlag.DECTSeries);
|
|
546
|
+
yield vbetService.processBtnPress(mockMuteFlag.DECTSeries[0]);
|
|
547
|
+
expect(setMuteFun).toHaveBeenCalledWith(true);
|
|
548
|
+
expect(devMuteFun).toHaveBeenCalledWith({
|
|
549
|
+
isMuted: true,
|
|
550
|
+
name: 'CallMuted',
|
|
551
|
+
conversationId: 'id',
|
|
552
|
+
});
|
|
553
|
+
}));
|
|
554
|
+
it('test unmute', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
555
|
+
const setMuteFun = jest.spyOn(vbetService, 'setMute');
|
|
556
|
+
const devMuteFun = jest.spyOn(vbetService, 'deviceMuteChanged');
|
|
557
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
558
|
+
yield vbetService.processBtnPress(mockOffhookFlag.DECTSeries);
|
|
559
|
+
yield vbetService.processBtnPress(mockMuteFlag.DECTSeries[1]);
|
|
560
|
+
expect(setMuteFun).toHaveBeenCalledWith(false);
|
|
561
|
+
expect(devMuteFun).toHaveBeenCalledWith({
|
|
562
|
+
isMuted: false,
|
|
563
|
+
name: 'CallUnmuted',
|
|
564
|
+
conversationId: 'id',
|
|
565
|
+
});
|
|
566
|
+
}));
|
|
567
|
+
it('test outgoing call', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
568
|
+
const ansFun = jest.spyOn(vbetService, 'endCallFromDevice');
|
|
569
|
+
const devAnsFun = jest.spyOn(vbetService, 'deviceEndedCall');
|
|
570
|
+
yield vbetService.outgoingCall({ conversationId: 'id' });
|
|
571
|
+
yield vbetService.processBtnPress(mockOnhookFlag.DECTSeries);
|
|
572
|
+
expect(ansFun).toHaveBeenCalled();
|
|
573
|
+
expect(devAnsFun).toHaveBeenCalled();
|
|
574
|
+
}));
|
|
575
|
+
});
|
|
576
|
+
describe('processBtnPress ACTIONSeries', () => {
|
|
577
|
+
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
578
|
+
mockDeviceList = mockDeviceList7;
|
|
579
|
+
yield vbetService.connect(mockTestDevName);
|
|
580
|
+
}));
|
|
581
|
+
afterEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
582
|
+
yield vbetService.endAllCalls();
|
|
583
|
+
yield vbetService.disconnect();
|
|
584
|
+
}));
|
|
585
|
+
it('activeDevice is null', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
586
|
+
yield vbetService.disconnect();
|
|
587
|
+
const ansFun = jest.spyOn(vbetService, 'answerCall');
|
|
588
|
+
yield vbetService.processBtnPress(mockOffhookFlag.ACTIONSeries);
|
|
589
|
+
expect(ansFun).not.toHaveBeenCalled();
|
|
590
|
+
}));
|
|
591
|
+
it('test offhook', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
592
|
+
const ansFun = jest.spyOn(vbetService, 'answerCall');
|
|
593
|
+
const devAnsFun = jest.spyOn(vbetService, 'deviceAnsweredCall');
|
|
594
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
595
|
+
yield vbetService.processBtnPress(mockOffhookFlag.ACTIONSeries);
|
|
596
|
+
expect(ansFun).toHaveBeenCalled();
|
|
597
|
+
expect(devAnsFun).toHaveBeenCalled();
|
|
598
|
+
}));
|
|
599
|
+
it('test reject', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
600
|
+
const ansFun = jest.spyOn(vbetService, 'rejectCall');
|
|
601
|
+
const devAnsFun = jest.spyOn(vbetService, 'deviceRejectedCall');
|
|
602
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
603
|
+
yield vbetService.processBtnPress(mockReject.ACTIONSeries);
|
|
604
|
+
expect(ansFun).toHaveBeenCalled();
|
|
605
|
+
expect(devAnsFun).toHaveBeenCalled();
|
|
606
|
+
}));
|
|
607
|
+
it('test mute', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
608
|
+
const setMuteFun = jest.spyOn(vbetService, 'setMute');
|
|
609
|
+
const devMuteFun = jest.spyOn(vbetService, 'deviceMuteChanged');
|
|
610
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
611
|
+
yield vbetService.processBtnPress(mockOffhookFlag.ACTIONSeries);
|
|
612
|
+
yield vbetService.processBtnPress(mockMuteFlag.ACTIONSeries[0]);
|
|
613
|
+
expect(setMuteFun).toHaveBeenCalledWith(true);
|
|
614
|
+
expect(devMuteFun).toHaveBeenCalledWith({
|
|
615
|
+
isMuted: true,
|
|
616
|
+
name: 'CallMuted',
|
|
617
|
+
conversationId: 'id',
|
|
618
|
+
});
|
|
619
|
+
}));
|
|
620
|
+
it('test unmute', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
621
|
+
const setMuteFun = jest.spyOn(vbetService, 'setMute');
|
|
622
|
+
const devMuteFun = jest.spyOn(vbetService, 'deviceMuteChanged');
|
|
623
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
624
|
+
yield vbetService.processBtnPress(mockOffhookFlag.ACTIONSeries);
|
|
625
|
+
yield vbetService.processBtnPress(mockMuteFlag.ACTIONSeries[1]);
|
|
626
|
+
expect(setMuteFun).toHaveBeenCalledWith(false);
|
|
627
|
+
expect(devMuteFun).toHaveBeenCalledWith({
|
|
628
|
+
isMuted: false,
|
|
629
|
+
name: 'CallUnmuted',
|
|
630
|
+
conversationId: 'id',
|
|
631
|
+
});
|
|
632
|
+
}));
|
|
633
|
+
it('test outgoing call', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
634
|
+
const ansFun = jest.spyOn(vbetService, 'endCallFromDevice');
|
|
635
|
+
const devAnsFun = jest.spyOn(vbetService, 'deviceEndedCall');
|
|
636
|
+
yield vbetService.outgoingCall({ conversationId: 'id' });
|
|
637
|
+
yield vbetService.processBtnPress(mockOnhookFlag.ACTIONSeries);
|
|
638
|
+
expect(ansFun).toHaveBeenCalled();
|
|
639
|
+
expect(devAnsFun).toHaveBeenCalled();
|
|
640
|
+
}));
|
|
641
|
+
});
|
|
642
|
+
describe('endcall from user interface', () => {
|
|
643
|
+
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
644
|
+
mockDeviceList = mockDeviceList1;
|
|
645
|
+
yield vbetService.connect(mockTestDevName);
|
|
646
|
+
}));
|
|
647
|
+
afterEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
648
|
+
yield vbetService.disconnect();
|
|
649
|
+
}));
|
|
650
|
+
it('test onhook', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
651
|
+
const ansFun = jest.spyOn(vbetService, 'sendOpToDevice');
|
|
652
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
653
|
+
yield vbetService.processBtnPress(mockOffhookFlag.BT100USeries);
|
|
654
|
+
yield vbetService.endCall('id', false);
|
|
655
|
+
expect(ansFun).toHaveBeenCalledWith('onHook');
|
|
656
|
+
}));
|
|
657
|
+
it('test onhook with other active calls', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
658
|
+
const ansFun = jest.spyOn(vbetService, 'sendOpToDevice');
|
|
659
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
660
|
+
yield vbetService.processBtnPress(mockOffhookFlag.BT100USeries);
|
|
661
|
+
yield vbetService.endCall('id', true);
|
|
662
|
+
expect(ansFun).not.toHaveBeenCalledWith('onHook');
|
|
663
|
+
}));
|
|
664
|
+
it('test onhook but no matching conversion id', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
665
|
+
const ansFun = jest.spyOn(vbetService, 'sendOpToDevice');
|
|
666
|
+
yield vbetService.incomingCall({ conversationId: 'id' });
|
|
667
|
+
yield vbetService.processBtnPress(mockOffhookFlag.BT100USeries);
|
|
668
|
+
yield vbetService.endCall('dif', false);
|
|
669
|
+
expect(ansFun).not.toHaveBeenCalledWith('onHook');
|
|
670
|
+
}));
|
|
671
|
+
it('test reject call but no pending conversion id', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
672
|
+
const ansFun = jest.spyOn(vbetService, 'sendOpToDevice');
|
|
673
|
+
yield vbetService.incomingCall({ conversationId: '' });
|
|
674
|
+
yield vbetService.rejectCall();
|
|
675
|
+
expect(ansFun).not.toHaveBeenCalledWith('onHook');
|
|
676
|
+
}));
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
//# sourceMappingURL=vbet.test.js.map
|