File tree Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,38 @@ it("doesnt render collapsed contents", () => {
60
60
ReactDOM . unmountComponentAtNode ( div ) ;
61
61
} ) ;
62
62
63
+ it ( "doesnt render collapsed contents with empty uiSchema" , ( ) => {
64
+ const div = document . createElement ( "div" ) ;
65
+ const schema = {
66
+ methods : [
67
+ {
68
+ params : [ {
69
+ name : "foobarz" ,
70
+ } ] ,
71
+ } ,
72
+ ] ,
73
+ } ;
74
+ ReactDOM . render ( < Methods schema = { schema as any } uiSchema = { { } } /> , div ) ;
75
+ expect ( div . innerHTML . includes ( "foobarz" ) ) . toBe ( false ) ;
76
+ ReactDOM . unmountComponentAtNode ( div ) ;
77
+ } ) ;
78
+
79
+ it ( "doesnt render collapsed contents with empty uiSchema.methods" , ( ) => {
80
+ const div = document . createElement ( "div" ) ;
81
+ const schema = {
82
+ methods : [
83
+ {
84
+ params : [ {
85
+ name : "foobarz" ,
86
+ } ] ,
87
+ } ,
88
+ ] ,
89
+ } ;
90
+ ReactDOM . render ( < Methods schema = { schema as any } uiSchema = { { methods : { } } } /> , div ) ;
91
+ expect ( div . innerHTML . includes ( "foobarz" ) ) . toBe ( false ) ;
92
+ ReactDOM . unmountComponentAtNode ( div ) ;
93
+ } ) ;
94
+
63
95
it ( "renders collapsed contents with defaultExpanded from uiSchema" , ( ) => {
64
96
const div = document . createElement ( "div" ) ;
65
97
const schema = {
Original file line number Diff line number Diff line change @@ -72,8 +72,13 @@ class Methods extends Component<IProps> {
72
72
id = { method . name }
73
73
key = { i + method . name }
74
74
TransitionProps = { { unmountOnExit : disableTransitionProps ? false : true } }
75
- defaultExpanded = { uiSchema && ( uiSchema . methods [ "ui:defaultExpanded" ] === true || uiSchema . methods [ "ui:defaultExpanded" ] [ method . name ] === true ) }
76
- >
75
+ defaultExpanded = {
76
+ uiSchema &&
77
+ uiSchema . methods &&
78
+ ( uiSchema . methods [ "ui:defaultExpanded" ] === true ||
79
+ ( uiSchema . methods [ "ui:defaultExpanded" ] && uiSchema . methods [ "ui:defaultExpanded" ] [ method . name ] === true )
80
+ )
81
+ } >
77
82
< ExpansionPanelSummary expandIcon = { < ExpandMoreIcon /> } >
78
83
< Typography key = { method . name } className = { classes . heading } > { method . name } </ Typography >
79
84
< Typography key = { method . summary } className = { classes . secondaryHeading } > { method . summary } </ Typography >
You can’t perform that action at this time.
0 commit comments