Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import { IntlProvider, intlShape } from 'react-intl';
- import { mount, render, shallow } from 'enzyme';
- const messages = {}; // en.json
- const intlProvider = new IntlProvider({ locale: 'en', messages, onError: () => '' }, {});
- const { intl } = intlProvider.getChildContext();
- function nodeWithIntlProp(node) {
- return React.cloneElement(node, { intl });
- }
- export function shallowWithIntl(node) {
- return shallow(nodeWithIntlProp(node), { context: { intl } });
- }
- export function mountWithIntl(node) {
- return mount(nodeWithIntlProp(node), {
- context: { intl },
- childContextTypes: { intl: intlShape }
- });
- }
- export function renderWithIntl(node) {
- return render(nodeWithIntlProp(node), {
- context: { intl },
- childContextTypes: { intl: intlShape }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement