@webex/plugin-meetings 1.147.1 → 1.149.2

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.
@@ -1902,7 +1902,9 @@ describe('plugin-meetings', () => {
1902
1902
 
1903
1903
  describe('#usePhoneAudio', () => {
1904
1904
  beforeEach(() => {
1905
- meeting.meetingRequest.dialIn = sinon.stub().returns(Promise.resolve());
1905
+ meeting.meetingRequest.dialIn = sinon.stub().returns(Promise.resolve({body: {locus: 'testData'}}));
1906
+ meeting.meetingRequest.dialOut = sinon.stub().returns(Promise.resolve({body: {locus: 'testData'}}));
1907
+ meeting.locusInfo.onFullLocus = sinon.stub().returns(Promise.resolve());
1906
1908
  });
1907
1909
 
1908
1910
  it('with no parameters triggers dial-in, delegating request to meetingRequest correctly', async () => {
@@ -1915,8 +1917,11 @@ describe('plugin-meetings', () => {
1915
1917
  locusUrl: meeting.locusUrl,
1916
1918
  clientUrl: meeting.deviceUrl
1917
1919
  });
1920
+ assert.calledWith(meeting.locusInfo.onFullLocus, 'testData');
1921
+ assert.notCalled(meeting.meetingRequest.dialOut);
1918
1922
 
1919
1923
  meeting.meetingRequest.dialIn.resetHistory();
1924
+ meeting.locusInfo.onFullLocus.resetHistory();
1920
1925
 
1921
1926
  // try again. the dial in urls should match
1922
1927
  await meeting.usePhoneAudio();
@@ -1927,6 +1932,65 @@ describe('plugin-meetings', () => {
1927
1932
  locusUrl: meeting.locusUrl,
1928
1933
  clientUrl: meeting.deviceUrl
1929
1934
  });
1935
+ assert.calledWith(meeting.locusInfo.onFullLocus, 'testData');
1936
+ assert.notCalled(meeting.meetingRequest.dialOut);
1937
+ });
1938
+
1939
+ it('given a phone number, triggers dial-out, delegating request to meetingRequest correctly', async () => {
1940
+ const phoneNumber = '+442088241000';
1941
+
1942
+ await meeting.usePhoneAudio(phoneNumber);
1943
+ const DIAL_OUT_URL = meeting.dialOutUrl;
1944
+
1945
+ assert.calledWith(meeting.meetingRequest.dialOut, {
1946
+ correlationId: meeting.correlationId,
1947
+ dialOutUrl: DIAL_OUT_URL,
1948
+ locusUrl: meeting.locusUrl,
1949
+ clientUrl: meeting.deviceUrl,
1950
+ phoneNumber
1951
+ });
1952
+ assert.calledWith(meeting.locusInfo.onFullLocus, 'testData');
1953
+ assert.notCalled(meeting.meetingRequest.dialIn);
1954
+
1955
+ meeting.meetingRequest.dialOut.resetHistory();
1956
+ meeting.locusInfo.onFullLocus.resetHistory();
1957
+
1958
+ // try again. the dial out urls should match
1959
+ await meeting.usePhoneAudio(phoneNumber);
1960
+
1961
+ assert.calledWith(meeting.meetingRequest.dialOut, {
1962
+ correlationId: meeting.correlationId,
1963
+ dialOutUrl: DIAL_OUT_URL,
1964
+ locusUrl: meeting.locusUrl,
1965
+ clientUrl: meeting.deviceUrl,
1966
+ phoneNumber
1967
+ });
1968
+ assert.calledWith(meeting.locusInfo.onFullLocus, 'testData');
1969
+ assert.notCalled(meeting.meetingRequest.dialIn);
1970
+ });
1971
+
1972
+ it('rejects if the request failed (dial in)', () => {
1973
+ const error = 'something bad happened';
1974
+
1975
+ meeting.meetingRequest.dialIn = sinon.stub().returns(Promise.reject(error));
1976
+
1977
+ return meeting.usePhoneAudio().then(() => Promise.reject(new Error('Promise resolved when it should have rejected'))).catch((e) => {
1978
+ assert.equal(e, error);
1979
+
1980
+ return Promise.resolve();
1981
+ });
1982
+ });
1983
+
1984
+ it('rejects if the request failed (dial out)', async () => {
1985
+ const error = 'something bad happened';
1986
+
1987
+ meeting.meetingRequest.dialOut = sinon.stub().returns(Promise.reject(error));
1988
+
1989
+ return meeting.usePhoneAudio('+441234567890').then(() => Promise.reject(new Error('Promise resolved when it should have rejected'))).catch((e) => {
1990
+ assert.equal(e, error);
1991
+
1992
+ return Promise.resolve();
1993
+ });
1930
1994
  });
1931
1995
  });
1932
1996
 
@@ -152,23 +152,48 @@ describe('plugin-meetings', () => {
152
152
  assert.equal(requestParams.body.device.clientUrl, 'clientUrl');
153
153
  });
154
154
 
155
- it('sends leave pstn request', async () => {
155
+ it('sends dial out pstn request', async () => {
156
+ const locusUrl = 'locusUrl';
157
+ const clientUrl = 'clientUrl';
158
+ const correlationId = 'random-uuid';
159
+ const dialOutUrl = 'url';
160
+ const phoneNumber = '+442088241000';
161
+
162
+ await meetingsRequest.dialOut({
163
+ locusUrl,
164
+ clientUrl,
165
+ correlationId,
166
+ dialOutUrl,
167
+ phoneNumber
168
+ });
169
+ const requestParams = meetingsRequest.request.getCall(0).args[0];
170
+
171
+ assert.equal(requestParams.method, 'POST');
172
+ assert.equal(requestParams.uri, `${locusUrl}/participant`);
173
+ assert.equal(requestParams.body.device.url, dialOutUrl);
174
+ assert.equal(requestParams.body.device.deviceType, 'PROVISIONAL');
175
+ assert.equal(requestParams.body.device.provisionalType, 'DIAL_OUT');
176
+ assert.equal(requestParams.body.device.clientUrl, 'clientUrl');
177
+ assert.equal(requestParams.body.device.dialoutAddress, phoneNumber);
178
+ });
179
+
180
+ it('sends disconnect phone audio request', async () => {
156
181
  const locusUrl = 'locusUrl';
157
182
  const selfId = 'selfId';
158
183
  const correlationId = 'random-uuid';
159
- const dialInUrl = 'url';
184
+ const phoneUrl = 'url';
160
185
 
161
- await meetingsRequest.leavePstn({
186
+ await meetingsRequest.disconnectPhoneAudio({
162
187
  locusUrl,
163
188
  selfId,
164
189
  correlationId,
165
- dialInUrl
190
+ phoneUrl
166
191
  });
167
192
  const requestParams = meetingsRequest.request.getCall(0).args[0];
168
193
 
169
194
  assert.equal(requestParams.method, 'PUT');
170
195
  assert.equal(requestParams.uri, `${locusUrl}/participant/${selfId}/leave`);
171
- assert.equal(requestParams.body.device.url, dialInUrl);
196
+ assert.equal(requestParams.body.device.url, phoneUrl);
172
197
  assert.equal(requestParams.body.device.deviceType, 'PROVISIONAL');
173
198
  });
174
199
  });