-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(WebexMeetingControls): implement HOC
- Loading branch information
1 parent
4745a84
commit 5c89588
Showing
4 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/components/WebexMeetingControl/WebexMeetingControls.js
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,20 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export const MeetingContext = React.createContext(); | ||
|
||
/** | ||
* WebexMeetingControls is a higher-order component that pass a meeting | ||
* context to several WebexMeetingControl components. | ||
* | ||
* @param {object} props | ||
* @returns {object} JSX of the component | ||
*/ | ||
export default function WebexMeetingControls({meetingID, children}) { | ||
return <MeetingContext.Provider value={meetingID}>{children}</MeetingContext.Provider>; | ||
} | ||
|
||
WebexMeetingControls.propTypes = { | ||
meetingID: PropTypes.string.isRequired, | ||
children: PropTypes.node.isRequired, | ||
}; |
16 changes: 16 additions & 0 deletions
16
src/components/WebexMeetingControl/WebexMeetingControls.test.js
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,16 @@ | ||
import React from 'react'; | ||
|
||
import WebexMeetingControls from './WebexMeetingControls'; | ||
|
||
describe('Webex Meeting Controls component', () => { | ||
test('matches snapshot', () => { | ||
const meetingID = 'my-meeting'; | ||
const component = shallow( | ||
<WebexMeetingControls meetingID={meetingID}> | ||
<div className="test" /> | ||
</WebexMeetingControls> | ||
); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
src/components/WebexMeetingControl/__snapshots__/WebexMeetingControls.test.js.snap
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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Webex Meeting Controls component matches snapshot 1`] = ` | ||
<ContextProvider | ||
value="my-meeting" | ||
> | ||
<div | ||
className="test" | ||
/> | ||
</ContextProvider> | ||
`; |
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