Skip to content

Commit 966f4db

Browse files
committed
Add test snapshot for displayName bug
1 parent 8465469 commit 966f4db

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from "react";
2+
3+
interface ButtonComponentProps {
4+
text: string;
5+
}
6+
7+
export const Button = (props: ButtonComponentProps) => (
8+
<button>{props.text}</button>
9+
);
10+
11+
Button.displayName = "MyButtonDisplayName";

src/__tests__/__snapshots__/generateDocgenCodeBlock.test.ts.snap

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,28 @@ try {
7676
catch (__react_docgen_typescript_loader_error) { }"
7777
`;
7878
79+
exports[`component fixture DisplayName.tsx has code block generated 1`] = `
80+
"import * as React from \\"react\\";
81+
82+
interface ButtonComponentProps {
83+
text: string;
84+
}
85+
86+
export const Button = (props: ButtonComponentProps) => (
87+
<button>{props.text}</button>
88+
);
89+
90+
Button.displayName = \\"MyButtonDisplayName\\";
91+
92+
try {
93+
// @ts-ignore
94+
MyButtonDisplayName.displayName = \\"MyButtonDisplayName\\";
95+
// @ts-ignore
96+
MyButtonDisplayName.__docgenInfo = { \\"description\\": \\"\\", \\"displayName\\": \\"MyButtonDisplayName\\", \\"props\\": { \\"text\\": { \\"defaultValue\\": null, \\"description\\": \\"\\", \\"name\\": \\"text\\", \\"required\\": true, \\"type\\": { \\"name\\": \\"string\\" } } } };
97+
}
98+
catch (__react_docgen_typescript_loader_error) { }"
99+
`;
100+
79101
exports[`component fixture HyphenatedPropName.tsx has code block generated 1`] = `
80102
"import * as React from \\"react\\";
81103

0 commit comments

Comments
 (0)