saleor-dashboard/src/storybook/Stories.test.ts

26 lines
834 B
TypeScript
Raw Normal View History

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";
import Adapter from "@wojtekmaj/enzyme-adapter-react-17";
2019-06-19 14:40:52 +00:00
// tslint:disable no-submodule-imports
import { configure, render } from "enzyme";
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
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-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 }) {
const result = render(story.render() as any);
expect(toJSON(result)).toMatchSnapshot();
},
2019-06-19 14:40:52 +00:00
});