summaryrefslogtreecommitdiffstats
path: root/webapp/tests/helpers/intl-test-helper.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/tests/helpers/intl-test-helper.jsx')
-rw-r--r--webapp/tests/helpers/intl-test-helper.jsx22
1 files changed, 22 insertions, 0 deletions
diff --git a/webapp/tests/helpers/intl-test-helper.jsx b/webapp/tests/helpers/intl-test-helper.jsx
new file mode 100644
index 000000000..49094f8d4
--- /dev/null
+++ b/webapp/tests/helpers/intl-test-helper.jsx
@@ -0,0 +1,22 @@
+// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+import {mount, shallow} from 'enzyme';
+import React from 'react';
+import {IntlProvider, intlShape} from 'react-intl';
+
+const intlProvider = new IntlProvider({locale: 'en'}, {});
+const {intl} = intlProvider.getChildContext();
+
+export function shallowWithIntl(node, {context} = {}) {
+ return shallow(React.cloneElement(node, {intl}), {
+ context: Object.assign({}, context, {intl})
+ });
+}
+
+export function mountWithIntl(node, {context, childContextTypes} = {}) {
+ return mount(React.cloneElement(node, {intl}), {
+ context: Object.assign({}, context, {intl}),
+ childContextTypes: Object.assign({}, {intl: intlShape}, childContextTypes)
+ });
+}