mirror of
https://github.com/strapi/strapi.git
synced 2025-07-16 13:32:05 +00:00
35 lines
697 B
JavaScript
35 lines
697 B
JavaScript
![]() |
/**
|
||
|
*
|
||
|
* Strapi
|
||
|
* This file allow to mock any key that is in the global strapi variable
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
// Setup the strapi functioon global variable
|
||
|
|
||
|
const React = require('react');
|
||
|
const hoistNonReactStatics = require('hoist-non-react-statics');
|
||
|
|
||
|
const hoc = () => WrappedComponent => {
|
||
|
class HocInjector extends React.Component {
|
||
|
static WrappedComponent = WrappedComponent;
|
||
|
|
||
|
render() {
|
||
|
return <WrappedComponent {...this.props} />;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return hoistNonReactStatics(HocInjector, WrappedComponent);
|
||
|
};
|
||
|
|
||
|
global.strapi = {
|
||
|
injectReducer: hoc,
|
||
|
injectSaga: hoc,
|
||
|
notification: {
|
||
|
error: jest.fn(),
|
||
|
info: jest.fn(),
|
||
|
success: jest.fn(),
|
||
|
warning: jest.fn(),
|
||
|
},
|
||
|
};
|