Skip to content

Commit ca80867

Browse files
karinasigartau0798cipak
authored andcommitted
feat(MeetingsSdkAdapter): move proceed without microphone control in its own file and create tests
1 parent 6ac8ebf commit ca80867

File tree

5 files changed

+99
-59
lines changed

5 files changed

+99
-59
lines changed

src/MeetingsSDKAdapter.js

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import AudioControl from './MeetingsSDKAdapter/controls/AudioControl';
2424
import ExitControl from './MeetingsSDKAdapter/controls/ExitControl';
2525
import JoinControl from './MeetingsSDKAdapter/controls/JoinControl';
2626
import ProceedWithoutCameraControl from './MeetingsSDKAdapter/controls/ProceedWithoutCameraControl';
27+
import ProceedWithoutMicrophoneControl from './MeetingsSDKAdapter/controls/ProceedWithoutMicrophoneControl';
2728
import RosterControl from './MeetingsSDKAdapter/controls/RosterControl';
2829
import SettingsControl from './MeetingsSDKAdapter/controls/SettingsControl';
2930
import SwitchCameraControl from './MeetingsSDKAdapter/controls/SwitchCameraControl';
@@ -138,16 +139,13 @@ export default class MeetingsSDKAdapter extends MeetingsAdapter {
138139
SwitchCameraControl(this, SWITCH_CAMERA_CONTROL);
139140
this.meetingControls[SWITCH_SPEAKER_CONTROL] = new
140141
SwitchSpeakerControl(this, SWITCH_SPEAKER_CONTROL);
142+
this.meetingControls[PROCEED_WITHOUT_MICROPHONE_CONTROL] = new
143+
ProceedWithoutMicrophoneControl(this, PROCEED_WITHOUT_MICROPHONE_CONTROL);
144+
141145
this.meetingControls[SWITCH_MICROPHONE_CONTROL] = new
142146
SwitchMicrophoneControl(this, SWITCH_MICROPHONE_CONTROL);
143147
this.meetingControls[PROCEED_WITHOUT_CAMERA_CONTROL] = new
144148
ProceedWithoutCameraControl(this, PROCEED_WITHOUT_CAMERA_CONTROL);
145-
146-
this.meetingControls[PROCEED_WITHOUT_MICROPHONE_CONTROL] = {
147-
ID: PROCEED_WITHOUT_MICROPHONE_CONTROL,
148-
action: this.ignoreAudioAccessPrompt.bind(this),
149-
display: this.proceedWithoutMicrophoneControl.bind(this),
150-
};
151149
}
152150

153151
/**
@@ -1042,37 +1040,10 @@ export default class MeetingsSDKAdapter extends MeetingsAdapter {
10421040
}
10431041
}
10441042

1045-
/**
1046-
* Returns an observable that emits the display data of the proceed without microphone control.
1047-
*
1048-
* @param {string} ID Meeting ID
1049-
* @returns {Observable.<MeetingControlDisplay>} Observable that emits control display data of proceed without microphone control
1050-
* @private
1051-
*/
1052-
proceedWithoutMicrophoneControl(ID) {
1053-
const sdkMeeting = this.fetchMeeting(ID);
1054-
1055-
const control$ = new Observable((observer) => {
1056-
if (sdkMeeting) {
1057-
observer.next({
1058-
ID: PROCEED_WITHOUT_MICROPHONE_CONTROL,
1059-
type: 'JOIN',
1060-
text: 'Proceed without microphone',
1061-
tooltip: 'Ignore media access prompt and proceed without microphone',
1062-
});
1063-
observer.complete();
1064-
} else {
1065-
observer.error(new Error(`Could not find meeting with ID "${ID}" to add proceed without microphone control`));
1066-
}
1067-
});
1068-
1069-
return control$;
1070-
}
1071-
10721043
/**
10731044
* Allows user to join meeting without allowing microphone access
10741045
*
1075-
* @param {string} ID Meeting ID
1046+
* @param {string} ID Meeting ID
10761047
*/
10771048
ignoreAudioAccessPrompt(ID) {
10781049
const meeting = this.meetings[ID];

src/MeetingsSDKAdapter.test.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -944,31 +944,6 @@ describe('Meetings SDK Adapter', () => {
944944
});
945945
});
946946

947-
describe('proceedWithoutMicrophoneControl()', () => {
948-
test('returns the display data of a meeting control in a proper shape', (done) => {
949-
meetingsSDKAdapter.proceedWithoutMicrophoneControl(meetingID)
950-
.pipe(first()).subscribe((dataDisplay) => {
951-
expect(dataDisplay).toMatchObject({
952-
ID: 'proceed-without-microphone',
953-
type: 'JOIN',
954-
text: 'Proceed without microphone',
955-
tooltip: 'Ignore media access prompt and proceed without microphone',
956-
});
957-
done();
958-
});
959-
});
960-
961-
test('throws errors if sdk meeting object is not defined', (done) => {
962-
meetingsSDKAdapter.proceedWithoutMicrophoneControl('inexistent').subscribe(
963-
() => {},
964-
(error) => {
965-
expect(error.message).toBe('Could not find meeting with ID "inexistent" to add proceed without microphone control');
966-
done();
967-
},
968-
);
969-
});
970-
});
971-
972947
describe('ignoreAudioAccessPrompt()', () => {
973948
test('calls ignoreAudioAccessPrompt() on the meeting object if defined', () => {
974949
meetingsSDKAdapter.meetings[meetingID].localAudio.ignoreMediaAccessPrompt = jest.fn();
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import {
2+
Observable,
3+
} from 'rxjs';
4+
import MeetingControl from './MeetingControl';
5+
6+
/**
7+
* Display options of a meeting control.
8+
*
9+
* @external MeetingControlDisplay
10+
* @see {@link https://github.com/webex/component-adapter-interfaces/blob/master/src/MeetingsAdapter.js#L58}
11+
*/
12+
13+
export default class ProceedWithoutMicrophoneControl extends MeetingControl {
14+
/**
15+
* Calls the adapter ignoreAudioAccessPrompt method.
16+
*
17+
* @param {string} meetingID Meeting ID
18+
*/
19+
async action(meetingID) {
20+
await this.adapter.ignoreAudioAccessPrompt(meetingID);
21+
}
22+
23+
/**
24+
* Returns an observable that emits the display data of the proceed without microphone control.
25+
*
26+
* @param {string} meetingID Meeting ID
27+
* @returns {Observable.<MeetingControlDisplay>} Observable that emits control display data of proceed without microphone control
28+
*/
29+
display(meetingID) {
30+
const sdkMeeting = this.adapter.fetchMeeting(meetingID);
31+
32+
const control$ = new Observable((observer) => {
33+
if (sdkMeeting) {
34+
observer.next({
35+
ID: this.ID,
36+
text: 'Proceed without microphone',
37+
tooltip: 'Ignore media access prompt and proceed without microphone',
38+
});
39+
observer.complete();
40+
} else {
41+
observer.error(new Error(`Could not find meeting with ID "${meetingID}" to add proceed without microphone control`));
42+
}
43+
});
44+
45+
return control$;
46+
}
47+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import {first} from 'rxjs/operators';
2+
import {meetingID, createTestMeetingsSDKAdapter} from '../testHelper';
3+
4+
describe('Proceed Without Microphone Control', () => {
5+
let meetingsSDKAdapter;
6+
7+
beforeEach(() => {
8+
meetingsSDKAdapter = createTestMeetingsSDKAdapter();
9+
});
10+
11+
afterEach(() => {
12+
meetingsSDKAdapter = null;
13+
});
14+
15+
describe('display()', () => {
16+
test('returns the display of a meeting control in a proper shape', (done) => {
17+
meetingsSDKAdapter.meetingControls['proceed-without-microphone'].display(meetingID)
18+
.pipe(first()).subscribe((display) => {
19+
expect(display).toMatchObject({
20+
ID: 'proceed-without-microphone',
21+
text: 'Proceed without microphone',
22+
tooltip: 'Ignore media access prompt and proceed without microphone',
23+
});
24+
done();
25+
});
26+
});
27+
28+
test('throws errors if sdk meeting object is not defined', (done) => {
29+
meetingsSDKAdapter.meetingControls['proceed-without-microphone'].display('inexistent').subscribe(
30+
() => {},
31+
(error) => {
32+
expect(error.message).toBe('Could not find meeting with ID "inexistent" to add proceed without microphone control');
33+
done();
34+
},
35+
);
36+
});
37+
});
38+
39+
describe('action()', () => {
40+
test('calls ignoreAudioAccessPrompt() SDK adapter method', async () => {
41+
meetingsSDKAdapter.ignoreAudioAccessPrompt = jest.fn();
42+
await meetingsSDKAdapter.meetingControls['proceed-without-microphone'].action(meetingID);
43+
expect(meetingsSDKAdapter.ignoreAudioAccessPrompt).toHaveBeenCalledWith(meetingID);
44+
});
45+
});
46+
});

src/MeetingsSDKAdapter/controls/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export {default as ExitControl} from './ExitControl';
44
export {default as JoinControl} from './JoinControl';
55
export {default as MeetingControl} from './MeetingControl';
66
export {default as ProceedWithoutCameraControl} from './ProceedWithoutCameraControl';
7+
export {default as ProceedWithoutMicrophoneControl} from './ProceedWithoutMicrophoneControl';
78
export {default as RosterControl} from './RosterControl';
89
export {default as SettingsControl} from './SettingsControl';
910
export {default as SwitchCameraControl} from './SwitchCameraControl';

0 commit comments

Comments
 (0)