-
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 join control in its own file and c…
…reate the tests accordingly
- Loading branch information
1 parent
ebed406
commit 68a4376
Showing
6 changed files
with
114 additions
and
39 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,36 @@ | ||
import {Observable, of} from 'rxjs'; | ||
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 JoinControl extends MeetingControl { | ||
/** | ||
* Calls the adapter joinMeeting method. | ||
* | ||
* @param {string} meetingID Id of the meeting to join | ||
*/ | ||
async action(meetingID) { | ||
await this.adapter.joinMeeting(meetingID); | ||
} | ||
|
||
/** | ||
* Returns an observable that emits the display data of the control. | ||
* | ||
* @returns {Observable.<MeetingControlDisplay>} Observable that emits display of the join control | ||
*/ | ||
// eslint-disable-next-line class-methods-use-this | ||
display() { | ||
return of({ | ||
ID: this.ID, | ||
text: 'Join meeting', | ||
tooltip: 'Join meeting', | ||
state: MeetingControlState.ACTIVE, | ||
}); | ||
} | ||
} |
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,36 @@ | ||
import {first} from 'rxjs/operators'; | ||
import {meetingID, createTestMeetingsSDKAdapter} from '../testHelper'; | ||
|
||
describe('Join Control', () => { | ||
let meetingsSDKAdapter; | ||
|
||
beforeEach(() => { | ||
meetingsSDKAdapter = createTestMeetingsSDKAdapter(); | ||
}); | ||
|
||
afterEach(() => { | ||
meetingsSDKAdapter = null; | ||
}); | ||
|
||
describe('display()', () => { | ||
test('returns the display data in a proper shape', (done) => { | ||
meetingsSDKAdapter.meetingControls['join-meeting'].display().pipe(first()).subscribe((display) => { | ||
expect(display).toMatchObject({ | ||
ID: 'join-meeting', | ||
text: 'Join meeting', | ||
tooltip: 'Join meeting', | ||
state: 'active', | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('action()', () => { | ||
test('calls joinMeeting() SDK adapter method', async () => { | ||
meetingsSDKAdapter.joinMeeting = jest.fn(); | ||
await meetingsSDKAdapter.meetingControls['join-meeting'].action(meetingID); | ||
expect(meetingsSDKAdapter.joinMeeting).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
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