Skip to content

fix(webex): fix numerous missing awaits in unit tests #4113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('http-core', () => {
},
};

assert.isRejected(interceptor.onResponse({}, response));
return assert.isRejected(interceptor.onResponse({}, response));
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('plugin-conversation', function () {
},
};

assert.isRejected(webex.internal.conversation.download(item));
return assert.isRejected(webex.internal.conversation.download(item));
}));

it('downloads and decrypts an encrypted file', () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('plugin-device', () => {
});

it('should return a rejected promise', () => {
assert.isRejected(device.canRegister());
return assert.isRejected(device.canRegister());
});
});
});
Expand All @@ -121,7 +121,7 @@ describe('plugin-device', () => {
});

it('should return a rejected promise', () => {
assert.isRejected(device.canRegister());
return assert.isRejected(device.canRegister());
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ describe('plugin-device', () => {
it('returns an error', () => {
const promise = interceptor.onRequest(options);

assert.isRejected(promise);
return assert.isRejected(promise);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('plugin-user', () => {

describe('#activate()', () => {
it('requires a `verificationToken` or a confirmationCode + user id', () => {
assert.isRejected(
return assert.isRejected(
userService.activate(),
/either options.verificationToken is required or both options.confirmationCode and options.id are required/
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ describe('plugin-meetings', () => {

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('rejects when correct display hint is not present enabled=true', () => {
const result = manager.setMuteOnEntry(true);

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('can set mute on entry when the display hint is available enabled=true', () => {
Expand Down Expand Up @@ -84,15 +84,15 @@ describe('plugin-meetings', () => {

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('rejects when correct display hint is not present enabled=true', () => {
const result = manager.setDisallowUnmute(true);

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('can set disallow unmute when ENABLE_HARD_MUTE display hint is available', () => {
Expand Down Expand Up @@ -223,15 +223,15 @@ describe('plugin-meetings', () => {

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('rejects when correct display hint is not present mutedEnabled=true', () => {
const result = manager.setMuteAll(true, false, false);

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('can set mute all when the display hint is available mutedEnabled=true', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe('plugin-meetings', () => {
it('should throw a rejection if there is no locus url', async () => {
const members = createMembers({url: false});

assert.isRejected(members.addMember({email: '[email protected]'}));
await assert.isRejected(members.addMember({email: '[email protected]'}));
});
});

Expand Down Expand Up @@ -285,13 +285,13 @@ describe('plugin-meetings', () => {
it('should throw a rejection when calling sendDialPadKey with no tones', async () => {
const members = createMembers({url: url1});

assert.isRejected(members.sendDialPadKey());
await assert.isRejected(members.sendDialPadKey());
});

it('should throw a rejection when calling sendDialPadKey with no member is found', async () => {
const members = createMembers({url: url1});

assert.isRejected(members.sendDialPadKey('1', '1234'));
await assert.isRejected(members.sendDialPadKey('1', '1234'));
});

it('should call genderateSendDTMFOptions with proper options on Members util if we the member is valid', async () => {
Expand Down Expand Up @@ -338,7 +338,7 @@ describe('plugin-meetings', () => {
it('should throw a rejection if there is no locus url', async () => {
const members = createMembers({url: false});

assert.isRejected(members.cancelPhoneInvite({phoneNumber: '+18578675309'}));
await assert.isRejected(members.cancelPhoneInvite({phoneNumber: '+18578675309'}));
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('ReceiveSlotManager', () => {
it('rejects if there is no media connection', async () => {
createSlotCallbackStub.rejects(new Error('Webrtc media connection is missing'));

assert.isRejected(
await assert.isRejected(
receiveSlotManager.allocateSlot(MediaType.VideoMain),
'Webrtc media connection is missing'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1823,9 +1823,9 @@ describe('RemoteMediaManager', () => {
});

describe('addMemberVideoPane()', () => {
it('fails if there is no current layout', () => {
it('fails if there is no current layout', async () => {
// we haven't called start() so there is no layout set, yet
assert.isRejected(
await assert.isRejected(
remoteMediaManager.addMemberVideoPane({id: 'newPane', size: 'best', csi: 54321})
);
});
Expand All @@ -1834,7 +1834,7 @@ describe('RemoteMediaManager', () => {
await remoteMediaManager.start();
await remoteMediaManager.setLayout('Stage');

assert.isRejected(
await assert.isRejected(
remoteMediaManager.addMemberVideoPane({id: 'stage-3', size: 'best', csi: 54321})
);
});
Expand Down Expand Up @@ -1886,9 +1886,9 @@ describe('RemoteMediaManager', () => {
});

describe('removeMemberVideoPane()', () => {
it('fails if there is no current layout', () => {
it('fails if there is no current layout', async () => {
// we haven't called start() so there is no layout set, yet
assert.isRejected(remoteMediaManager.removeMemberVideoPane('newPane'));
await assert.isRejected(remoteMediaManager.removeMemberVideoPane('newPane'));
});

it('does nothing when called for a pane not in the current layout', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,22 +427,22 @@ describe('plugin-meetings', () => {
clock.restore();
});

it('should set the disconnected state to true', () => {
it('should set the disconnected state to true', async () => {
const promise = reconnectionManager.waitForIceReconnect();

assert.isTrue(reconnectionManager.iceState.disconnected);

// we let the timer expire
clock.tick(reconnectionManager.iceState.timeoutDuration);
assert.isRejected(promise);
await assert.isRejected(promise);
});

it('should return a promise that rejects after a duration', async () => {
const promise = reconnectionManager.waitForIceReconnect();

// we let the timer expire
clock.tick(reconnectionManager.iceState.timeoutDuration);
assert.isRejected(promise);
await assert.isRejected(promise);
});

it('should resolve when ICE is reconnected', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('plugin-meetings', () => {

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('rejects when correct display hint is present but the policy is false', () => {
Expand All @@ -61,7 +61,7 @@ describe('plugin-meetings', () => {

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('can start recording when the correct display hint is present', () => {
Expand All @@ -85,7 +85,7 @@ describe('plugin-meetings', () => {

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('rejects when correct display hint is present but the policy is false', () => {
Expand All @@ -95,7 +95,7 @@ describe('plugin-meetings', () => {

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('can stop recording when the correct display hint is present', () => {
Expand All @@ -119,7 +119,7 @@ describe('plugin-meetings', () => {

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('rejects when correct display hint is present but the policy is false', () => {
Expand All @@ -131,7 +131,7 @@ describe('plugin-meetings', () => {

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('can pause recording when the correct display hint is present', () => {
Expand All @@ -155,7 +155,7 @@ describe('plugin-meetings', () => {

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('rejects when correct display hint is present but the policy is false', () => {
Expand All @@ -167,7 +167,7 @@ describe('plugin-meetings', () => {

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});


Expand Down Expand Up @@ -211,7 +211,7 @@ describe('plugin-meetings', () => {

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('can start recording when the correct display hint is present', () => {
Expand Down Expand Up @@ -249,7 +249,7 @@ describe('plugin-meetings', () => {

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('can stop recording when the correct display hint is present', () => {
Expand Down Expand Up @@ -287,7 +287,7 @@ describe('plugin-meetings', () => {

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('can pause recording when the correct display hint is present', () => {
Expand Down Expand Up @@ -325,7 +325,7 @@ describe('plugin-meetings', () => {

assert.notCalled(request.request);

assert.isRejected(result);
return assert.isRejected(result);
});

it('can resume recording when the correct display hint is present', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('plugin-presence', () => {

describe('#get()', () => {
it('requires a person id parameter', () => {
assert.isRejected(webex.presence.get(), /A person id is required/);
return assert.isRejected(webex.presence.get(), /A person id is required/);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1025,25 +1025,25 @@ describe('webex-core', () => {
});

describe('when using the name parameter property', () => {
it('should return a rejected promise', () => {
it('should return a rejected promise', async () => {
const submitMetrics = sinon.stub(webex.internal.metrics, 'submitClientMetrics');
const waitForService = services.waitForService({name, timeout});

assert.called(submitMetrics);
assert.isRejected(waitForService);
await assert.isRejected(waitForService);
assert.isTrue(catalog.isReady);
});
});

describe('when using the name and url parameter properties', () => {
it('should return a rejected promise', () => {
it('should return a rejected promise', async () => {
const waitForService = services.waitForService({
name,
url,
timeout,
});

assert.isRejected(waitForService);
await assert.isRejected(waitForService);
assert.isTrue(catalog.isReady);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('webex-core', () => {
});
});

it('does not redirect on reaching max redirects', () => {
it('does not redirect on reaching max redirects', async () => {
const response = {
statusCode: 404,
headers: {},
Expand All @@ -78,7 +78,7 @@ describe('webex-core', () => {
},
};

assert.isRejected(interceptor.onResponse({$redirectCount: 5}, response));
await assert.isRejected(interceptor.onResponse({$redirectCount: 5}, response));
});

it('returns when locus redirect is not encountered', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ describe('webex-core', () => {
waitForService.rejects();
});

it('should return a rejected promise', () => {
it('should return a rejected promise', async () => {
const promise = interceptor.onRequest(options);

assert.isRejected(promise);
await assert.isRejected(promise);
});
});
});
Expand Down
Loading