From ea42973ace6699b31eaec46fdb34f3ead55f4e8a Mon Sep 17 00:00:00 2001 From: Wei Zhu Date: Wed, 11 Jul 2018 11:16:37 +0800 Subject: [PATCH] mock React.createContext --- tests/__mocks__/react.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tests/__mocks__/react.js diff --git a/tests/__mocks__/react.js b/tests/__mocks__/react.js new file mode 100644 index 0000000000..072da8061c --- /dev/null +++ b/tests/__mocks__/react.js @@ -0,0 +1,11 @@ +const React = require.requireActual('react'); + +if (!React.createContext) { + React.createContext = () => { + const Provider = ({ children }) => children; + const Consumer = ({ children }) => children(); + return { Provider, Consumer }; + }; +} + +module.exports = React;