Skip to content

Commit

Permalink
feat(LocalMedia): use getMe hook instead of personID prop
Browse files Browse the repository at this point in the history
  • Loading branch information
lalli-flores committed Dec 16, 2019
1 parent 89b8b6d commit 1e0c1f6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/components/WebexLocalMedia/WebexLocalMedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';

import {WebexAvatar} from '../';
import {useMeeting, useVideo} from '../hooks';
import {useMe, useMeeting, useVideo} from '../hooks';

import './WebexLocalMedia.scss';

Expand All @@ -12,18 +12,18 @@ import './WebexLocalMedia.scss';
* @param {object} props
* @returns {object} JSX of the component
*/
export default function WebexLocalMedia({meetingID, personID}) {
export default function WebexLocalMedia({meetingID}) {
const {localVideo} = useMeeting(meetingID);
const videoRef = useVideo(localVideo);
const {ID} = useMe();

return (
<div className="local-media">
{localVideo ? <video ref={videoRef} playsInline /> : <WebexAvatar personID={personID} />}
{localVideo ? <video ref={videoRef} playsInline /> : <WebexAvatar personID={ID} />}
</div>
);
}

WebexLocalMedia.propTypes = {
meetingID: PropTypes.string.isRequired,
personID: PropTypes.string.isRequired,
};
5 changes: 3 additions & 2 deletions src/components/WebexLocalMedia/WebexLocalMedia.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import React from 'react';

import WebexLocalMedia from './WebexLocalMedia';

jest.mock('../hooks/useMe');
jest.mock('../hooks/useMeeting');
jest.mock('../hooks/useVideo');

describe('Webex Local Media component', () => {
describe('snapshot', () => {
test('matches snapshot of local video', () => {
expect(shallow(<WebexLocalMedia meetingID="localVideo" personID="default" />)).toMatchSnapshot();
expect(shallow(<WebexLocalMedia meetingID="localVideo" />)).toMatchSnapshot();
});

test('matches snapshot of disabled local video', () => {
expect(shallow(<WebexLocalMedia meetingID="scheduledMeeting" personID="default" />)).toMatchSnapshot();
expect(shallow(<WebexLocalMedia meetingID="scheduledMeeting" />)).toMatchSnapshot();
});
});
});
7 changes: 7 additions & 0 deletions src/components/hooks/__mocks__/useMe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {useContext} from 'react';

export default function useMe() {
const datasource = useContext();

return {...datasource.peopleAdapter.default};
}

0 comments on commit 1e0c1f6

Please sign in to comment.