2019-11-05 10:59:21 +00:00
|
|
|
import createGenerateClassName from "@material-ui/styles/createGenerateClassName";
|
2019-06-19 14:40:52 +00:00
|
|
|
import initStoryshots from "@storybook/addon-storyshots";
|
|
|
|
// tslint:disable no-submodule-imports
|
2019-08-09 10:26:22 +00:00
|
|
|
import generateRandomKey from "draft-js/lib/generateRandomKey";
|
2019-06-19 14:40:52 +00:00
|
|
|
import { configure, render } from "enzyme";
|
2019-08-09 10:26:22 +00:00
|
|
|
import Adapter from "enzyme-adapter-react-16";
|
2019-06-19 14:40:52 +00:00
|
|
|
import toJSON from "enzyme-to-json";
|
2019-11-05 10:59:21 +00:00
|
|
|
import React from "react";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2019-11-05 10:59:21 +00:00
|
|
|
// Fixes useLayoutEffect warnings
|
|
|
|
React.useLayoutEffect = React.useEffect;
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2019-11-05 10:59:21 +00:00
|
|
|
configure({ adapter: new Adapter() });
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
jest.mock("draft-js/lib/generateRandomKey");
|
|
|
|
(generateRandomKey as any).mockImplementation(() => "testKey");
|
|
|
|
|
2019-11-05 10:59:21 +00:00
|
|
|
jest.mock("@material-ui/styles/createGenerateClassName");
|
|
|
|
(createGenerateClassName as any).mockImplementation(() => (rule, stylesheet) =>
|
|
|
|
[stylesheet.options.meta, rule.key, "id"].join("-")
|
|
|
|
);
|
|
|
|
|
2019-06-19 14:40:52 +00:00
|
|
|
initStoryshots({
|
2019-08-09 13:13:50 +00:00
|
|
|
configPath: "src/storybook/",
|
2019-06-19 14:40:52 +00:00
|
|
|
test({ story }) {
|
|
|
|
const result = render(story.render() as any);
|
|
|
|
expect(toJSON(result)).toMatchSnapshot();
|
|
|
|
}
|
|
|
|
});
|