-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(MeetingSdkAdapter): implement settings control in its own file a…
…nd create the tests accordingly
- Loading branch information
1 parent
8f0e9b4
commit 9d085a2
Showing
5 changed files
with
158 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {Observable} from 'rxjs'; | ||
import {map, distinctUntilChanged} from 'rxjs/operators'; | ||
import {MeetingControlState} from '@webex/component-adapter-interfaces'; | ||
import MeetingControl from './MeetingControl'; | ||
|
||
/** | ||
* Display options of a meeting control. | ||
* | ||
* @external MeetingControlDisplay | ||
* @see {@link https://github.com/webex/component-adapter-interfaces/blob/master/src/MeetingsAdapter.js#L58} | ||
*/ | ||
|
||
export default class SettingsControl extends MeetingControl { | ||
/** | ||
* Toggles the showSettings flag of the given meeting ID. | ||
* A settings toggle event is dispatched. | ||
* | ||
* @param {string} meetingID Meeting ID | ||
*/ | ||
action(meetingID) { | ||
this.adapter.toggleSettings(meetingID); | ||
} | ||
|
||
/** | ||
* Returns an observable that emits the display data of a settings control. | ||
* | ||
* @param {string} meetingID Meeting id | ||
* @returns {Observable.<MeetingControlDisplay>} Observable stream that emits display data of the settings control | ||
*/ | ||
display(meetingID) { | ||
const active = { | ||
ID: this.ID, | ||
icon: 'settings_32', | ||
tooltip: 'Hide settings panel', | ||
state: MeetingControlState.ACTIVE, | ||
text: 'Settings', | ||
}; | ||
const inactive = { | ||
ID: this.ID, | ||
icon: 'settings_32', | ||
tooltip: 'Show settings panel', | ||
state: MeetingControlState.INACTIVE, | ||
text: 'Settings', | ||
}; | ||
|
||
return this.adapter.getMeeting(meetingID).pipe( | ||
map(({showSettings}) => (showSettings ? active : inactive)), | ||
distinctUntilChanged(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import {first} from 'rxjs/operators'; | ||
import MeetingsSDKAdapter from '../../MeetingsSDKAdapter'; | ||
import createMockSDK from '../../mockSdk'; | ||
|
||
describe('Settings Control', () => { | ||
let meeting; | ||
let meetingID; | ||
let meetingsSDKAdapter; | ||
let mockSDK; | ||
|
||
beforeEach(() => { | ||
mockSDK = createMockSDK(); | ||
meetingID = 'meetingID'; | ||
meetingsSDKAdapter = new MeetingsSDKAdapter(mockSDK); | ||
meeting = { | ||
ID: meetingID, | ||
localAudio: { | ||
stream: null, | ||
permission: null, | ||
}, | ||
localShare: { | ||
stream: null, | ||
}, | ||
localVideo: { | ||
stream: null, | ||
permission: null, | ||
}, | ||
remoteAudio: null, | ||
remoteVideo: null, | ||
remoteShare: null, | ||
showRoster: null, | ||
showSettings: false, | ||
title: 'my meeting', | ||
cameraID: null, | ||
microphoneID: null, | ||
speakerID: null, | ||
}; | ||
meetingsSDKAdapter.meetings[meetingID] = meeting; | ||
}); | ||
|
||
afterEach(() => { | ||
meeting = null; | ||
mockSDK = null; | ||
meetingsSDKAdapter = null; | ||
meetingID = null; | ||
}); | ||
|
||
describe('display()', () => { | ||
test('returns the display data of a meeting control in a proper shape', () => { | ||
meetingsSDKAdapter.meetingControls.settings.display(meetingID).pipe(first()) | ||
.subscribe((dataDisplay) => { | ||
expect(dataDisplay).toMatchObject({ | ||
ID: 'settings', | ||
icon: 'settings_32', | ||
tooltip: 'Show settings panel', | ||
state: 'inactive', | ||
text: 'Settings', | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('action()', () => { | ||
test('calls toggleSettings() SDK adapter method', async () => { | ||
meetingsSDKAdapter.toggleSettings = jest.fn(); | ||
await meetingsSDKAdapter.meetingControls.settings.action(meetingID); | ||
expect(meetingsSDKAdapter.toggleSettings).toHaveBeenCalledTimes(1); | ||
expect(meetingsSDKAdapter.toggleSettings).toHaveBeenCalledWith(meetingID); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
export {default as MeetingControl} from './MeetingControl'; | ||
export {default as RosterControl} from './RosterControl'; | ||
export {default as SettingsControl} from './SettingsControl'; |