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
|
|
|
|
import { configure, render } from "enzyme";
|
2022-10-11 10:01:17 +00:00
|
|
|
import Adapter from "enzyme-adapter-react-16";
|
2019-06-19 14:40:52 +00:00
|
|
|
import toJSON from "enzyme-to-json";
|
2022-10-18 09:10:15 +00:00
|
|
|
import { mockRandomForEach } from "jest-mock-random";
|
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
|
|
|
|
2019-11-05 10:59:21 +00:00
|
|
|
jest.mock("@material-ui/styles/createGenerateClassName");
|
|
|
|
(createGenerateClassName as any).mockImplementation(() => (rule, stylesheet) =>
|
2022-06-21 09:36:55 +00:00
|
|
|
[stylesheet.options.meta, rule.key, "id"].join("-"),
|
2019-11-05 10:59:21 +00:00
|
|
|
);
|
|
|
|
|
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 }) {
|
2022-10-18 09:10:15 +00:00
|
|
|
mockRandomForEach(
|
|
|
|
Array.from(Array(25).keys()).map(x => parseFloat(`0.${x + 1}`)),
|
|
|
|
);
|
|
|
|
|
2019-06-19 14:40:52 +00:00
|
|
|
const result = render(story.render() as any);
|
|
|
|
expect(toJSON(result)).toMatchSnapshot();
|
2022-06-21 09:36:55 +00:00
|
|
|
},
|
2019-06-19 14:40:52 +00:00
|
|
|
});
|