[next] Support server side jest testing (#1747)

* Support server side jest testing

* feat: more tests
This commit is contained in:
Kiwi
2018-07-13 16:57:25 +00:00
committed by Wyatt Johnson
parent cf1c5c58c2
commit cac0afa61e
8 changed files with 121 additions and 51 deletions
+24
View File
@@ -0,0 +1,24 @@
import "./enzyme";
import "./jsdom";
// TODO: Remove when fixed.
// Mock React.createContext because of https://github.com/airbnb/enzyme/issues/1509.
function mockReact() {
const originalReact = require.requireActual("react");
return {
...originalReact,
createContext: jest.fn(defaultValue => {
let value = defaultValue;
const Provider = (props: any) => {
value = props.value;
return props.children;
};
const Consumer = (props: any) => props.children(value);
return {
Provider,
Consumer,
};
}),
};
}
jest.mock("react", () => mockReact());