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", () => {
6060 ReactDOM . unmountComponentAtNode ( div ) ;
6161} ) ;
6262
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+
6395it ( "renders collapsed contents with defaultExpanded from uiSchema" , ( ) => {
6496 const div = document . createElement ( "div" ) ;
6597 const schema = {
Original file line number Diff line number Diff line change @@ -72,8 +72,13 @@ class Methods extends Component<IProps> {
7272 id = { method . name }
7373 key = { i + method . name }
7474 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+ } >
7782 < ExpansionPanelSummary expandIcon = { < ExpandMoreIcon /> } >
7883 < Typography key = { method . name } className = { classes . heading } > { method . name } </ Typography >
7984 < Typography key = { method . summary } className = { classes . secondaryHeading } > { method . summary } </ Typography >
You can’t perform that action at this time.
0 commit comments