fixed storyshots with react-diff-view

This commit is contained in:
Sebastian Sdorra
2020-01-06 14:48:32 +01:00
parent 04e533d92e
commit 3e1828eb12
3 changed files with 16438 additions and 4 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -16,14 +16,17 @@ storiesOf("Diff", module)
.add("Collapsed", () => <Diff diff={diffFiles} defaultCollapse={true} />)
.add("File Controls", () => <Diff diff={diffFiles} fileControlFactory={() => <Button>Custom Control</Button>} />)
.add("File Annotation", () => (
<Diff diff={diffFiles} fileAnnotationFactory={file => [<p>Custom File annotation for {file.newPath}</p>]} />
<Diff
diff={diffFiles}
fileAnnotationFactory={file => [<p key={file.newPath}>Custom File annotation for {file.newPath}</p>]}
/>
))
.add("Line Annotation", () => (
<Diff
diff={diffFiles}
annotationFactory={ctx => {
return {
N2: [<p>Line Annotation</p>]
N2: <p key="N2">Line Annotation</p>
};
}}
/>

View File

@@ -1,6 +1,22 @@
import path from "path";
import initStoryshots from "@storybook/addon-storyshots";
import initStoryshots, { snapshotWithOptions } from "@storybook/addon-storyshots";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const createNodeMock = (element: any) => {
if (element.type === "tr") {
return {
// eslint-disable-next-line @typescript-eslint/no-empty-function
querySelector: (selector: string) => {}
};
}
return null;
};
initStoryshots({
configPath: path.resolve(__dirname, "..", ".storybook")
configPath: path.resolve(__dirname, "..", ".storybook"),
// fix snapshot tests with react-diff-view which uses a ref on tr
// @see https://github.com/storybookjs/storybook/pull/1090
test: snapshotWithOptions({
createNodeMock
})
});