From e2f70a68ba2cdd19d14d52ccdae85f53fec424e5 Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Thu, 19 Oct 2017 16:55:22 -0400 Subject: [PATCH] Add mock for react-intl --- test/__mocks__/react-intl.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/__mocks__/react-intl.js diff --git a/test/__mocks__/react-intl.js b/test/__mocks__/react-intl.js new file mode 100644 index 00000000..7551c6a5 --- /dev/null +++ b/test/__mocks__/react-intl.js @@ -0,0 +1,24 @@ +import React from 'react'; +const Intl = require.requireActual('react-intl'); + +// Here goes intl context injected into component, feel free to extend +const intl = { + formatMessage: ({defaultMessage}) => defaultMessage, + formatDate: ({defaultMessage}) => defaultMessage, + formatTime: ({defaultMessage}) => defaultMessage, + formatRelative: ({defaultMessage}) => defaultMessage, + formatNumber: ({defaultMessage}) => defaultMessage, + formatPlural: ({defaultMessage}) => defaultMessage, + formatHTMLMessage: ({defaultMessage}) => defaultMessage, + now: () => 0 +}; + +Intl.injectIntl = Node => { + const renderWrapped = props => ; + renderWrapped.displayName = Node.displayName || + Node.name || + 'Component'; + return renderWrapped; +}; + +module.exports = Intl;