-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added observability events for video detail page (#1159)
- Loading branch information
1 parent
29aeaa8
commit 272f6dd
Showing
4 changed files
with
186 additions
and
8 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
30 changes: 30 additions & 0 deletions
30
src/components/microlearning/__mocks__/@loadable/component.jsx
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,30 @@ | ||
import React from 'react'; | ||
|
||
// mock the loadable function to load the module eagarly and expose a preload() function | ||
function loadable(load) { | ||
let Component; | ||
// Capture the component from the module load function | ||
// eslint-disable-next-line no-return-assign | ||
const loadPromise = load().then((val) => (Component = val.default)); | ||
// Create a react component which renders the loaded component | ||
const payload = { | ||
on: jest.fn().mockImplementation((event, callback) => { callback(); }), | ||
}; | ||
const Loadable = (props) => { | ||
if (!Component) { | ||
throw new Error( | ||
`Bundle split module not loaded yet, import statement: ${load.toString()}`, | ||
); | ||
} | ||
// eslint-disable-next-line react/prop-types | ||
if (props.onReady) { | ||
// eslint-disable-next-line no-return-assign, react/prop-types | ||
return <Component {...props} onLoad={props.onReady(payload)} />; | ||
} | ||
return <Component {...props} />; | ||
}; | ||
Loadable.preload = () => loadPromise; | ||
return Loadable; | ||
} | ||
|
||
export default loadable; |
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