mirror of
https://github.com/strapi/strapi.git
synced 2025-08-08 08:46:42 +00:00
20 lines
585 B
JavaScript
20 lines
585 B
JavaScript
![]() |
import React from 'react';
|
||
|
import { mount } from 'enzyme';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import { IntlProvider, intlShape } from 'react-intl';
|
||
|
|
||
|
const mountWithIntl = (componentToMount, pluginTrads, context = {}) => {
|
||
|
const intlProvider = new IntlProvider(
|
||
|
{ locale: 'en', messages: pluginTrads },
|
||
|
{},
|
||
|
);
|
||
|
const { intl } = intlProvider.getChildContext();
|
||
|
|
||
|
return mount(React.cloneElement(componentToMount, { intl }), {
|
||
|
context: { intl, ...context },
|
||
|
childContextTypes: { intl: intlShape, emitEvent: PropTypes.func },
|
||
|
});
|
||
|
};
|
||
|
|
||
|
export default mountWithIntl;
|