@@ -18,14 +18,14 @@ it("renders empty with no schema", () => {
1818
1919it ( "renders empty with empty schema" , ( ) => {
2020 const div = document . createElement ( "div" ) ;
21- ReactDOM . render ( < Methods schema = { { } as any } /> , div ) ;
21+ ReactDOM . render ( < Methods schema = { { } as any } /> , div ) ;
2222 expect ( div . innerHTML ) . toBe ( "" ) ;
2323 ReactDOM . unmountComponentAtNode ( div ) ;
2424} ) ;
2525
2626it ( "renders empty with empty schema methods" , ( ) => {
2727 const div = document . createElement ( "div" ) ;
28- ReactDOM . render ( < Methods schema = { { methods : [ ] } as any } /> , div ) ;
28+ ReactDOM . render ( < Methods schema = { { methods : [ ] } as any } /> , div ) ;
2929 expect ( div . innerHTML ) . toBe ( "" ) ;
3030 ReactDOM . unmountComponentAtNode ( div ) ;
3131} ) ;
@@ -39,11 +39,68 @@ it("renders schema methods name", () => {
3939 } ,
4040 ] ,
4141 } ;
42- ReactDOM . render ( < Methods schema = { schema as any } /> , div ) ;
42+ ReactDOM . render ( < Methods schema = { schema as any } disableTransitionProps = { true } /> , div ) ;
4343 expect ( div . innerHTML . includes ( "get_pet" ) ) . toBe ( true ) ;
4444 ReactDOM . unmountComponentAtNode ( div ) ;
4545} ) ;
4646
47+ it ( "doesnt render collapsed contents" , ( ) => {
48+ const div = document . createElement ( "div" ) ;
49+ const schema = {
50+ methods : [
51+ {
52+ params : [ {
53+ name : "foobarz" ,
54+ } ] ,
55+ } ,
56+ ] ,
57+ } ;
58+ ReactDOM . render ( < Methods schema = { schema as any } /> , div ) ;
59+ expect ( div . innerHTML . includes ( "foobarz" ) ) . toBe ( false ) ;
60+ ReactDOM . unmountComponentAtNode ( div ) ;
61+ } ) ;
62+
63+ it ( "renders collapsed contents with defaultExpanded from uiSchema" , ( ) => {
64+ const div = document . createElement ( "div" ) ;
65+ const schema = {
66+ methods : [
67+ {
68+ params : [ {
69+ name : "foobarz" ,
70+ } ] ,
71+ } ,
72+ ] ,
73+ } ;
74+ const uiSchema = {
75+ links : {
76+ } ,
77+ methods : {
78+ "ui:defaultExpanded" : true ,
79+ } ,
80+ params : {
81+ } ,
82+ } ;
83+ ReactDOM . render ( < Methods uiSchema = { uiSchema } schema = { schema as any } disableTransitionProps = { true } /> , div ) ;
84+ expect ( div . innerHTML . includes ( "aria-expanded=\"true\"" ) ) . toBe ( true ) ;
85+ ReactDOM . unmountComponentAtNode ( div ) ;
86+ } ) ;
87+
88+ it ( "renders collapsed contents with disableTransitionProps" , ( ) => {
89+ const div = document . createElement ( "div" ) ;
90+ const schema = {
91+ methods : [
92+ {
93+ params : [ {
94+ name : "foobarz" ,
95+ } ] ,
96+ } ,
97+ ] ,
98+ } ;
99+ ReactDOM . render ( < Methods schema = { schema as any } disableTransitionProps = { true } /> , div ) ;
100+ expect ( div . innerHTML . includes ( "foobarz" ) ) . toBe ( true ) ;
101+ ReactDOM . unmountComponentAtNode ( div ) ;
102+ } ) ;
103+
47104it ( "renders schema plugin" , ( ) => {
48105 const div = document . createElement ( "div" ) ;
49106 const schema = {
@@ -61,7 +118,9 @@ it("renders schema plugin", () => {
61118 ) ;
62119 } ;
63120
64- ReactDOM . render ( < Methods schema = { schema as any } methodPlugins = { [ TestComponent ] } /> , div ) ;
121+ ReactDOM . render (
122+ < Methods schema = { schema as any } methodPlugins = { [ TestComponent ] } disableTransitionProps = { true } />
123+ , div ) ;
65124 expect ( div . innerHTML . includes ( "get_pet" ) ) . toBe ( true ) ;
66125 expect ( div . innerHTML . includes ( "Plugin Test" ) ) . toBe ( true ) ;
67126 ReactDOM . unmountComponentAtNode ( div ) ;
@@ -79,7 +138,7 @@ it("renders schema methods summary", () => {
79138 } ,
80139 ] ,
81140 } ;
82- ReactDOM . render ( < Methods schema = { schema as any } /> , div ) ;
141+ ReactDOM . render ( < Methods schema = { schema as any } disableTransitionProps = { true } /> , div ) ;
83142 expect ( div . innerHTML . includes ( "a short summary" ) ) . toBe ( true ) ;
84143 ReactDOM . unmountComponentAtNode ( div ) ;
85144} ) ;
@@ -93,7 +152,7 @@ it("renders schema methods description", () => {
93152 } ,
94153 ] ,
95154 } as OpenRPC ;
96- ReactDOM . render ( < Methods schema = { schema } /> , div ) ;
155+ ReactDOM . render ( < Methods schema = { schema } disableTransitionProps = { true } /> , div ) ;
97156 expect ( div . innerHTML . includes ( "verbose get_pet description" ) ) . toBe ( true ) ;
98157 ReactDOM . unmountComponentAtNode ( div ) ;
99158} ) ;
@@ -109,7 +168,7 @@ it("renders schema methods params", () => {
109168 } ,
110169 ] ,
111170 } ;
112- ReactDOM . render ( < Methods schema = { schema as any } /> , div ) ;
171+ ReactDOM . render ( < Methods schema = { schema as any } disableTransitionProps = { true } /> , div ) ;
113172 expect ( div . innerHTML . includes ( "foobarz" ) ) . toBe ( true ) ;
114173 ReactDOM . unmountComponentAtNode ( div ) ;
115174} ) ;
@@ -141,7 +200,7 @@ it("renders schema methods result", () => {
141200 } ,
142201 ] ,
143202 } ;
144- ReactDOM . render ( < Methods schema = { schema as any } /> , div ) ;
203+ ReactDOM . render ( < Methods schema = { schema as any } disableTransitionProps = { true } /> , div ) ;
145204 expect ( div . innerHTML . includes ( "name" ) ) . toBe ( true ) ;
146205 expect ( div . innerHTML . includes ( "tag" ) ) . toBe ( true ) ;
147206 expect ( div . innerHTML . includes ( "id" ) ) . toBe ( true ) ;
@@ -213,7 +272,7 @@ it("renders schema methods tags", () => {
213272 } ,
214273 ] ,
215274 } ;
216- ReactDOM . render ( < Methods schema = { schema as any } /> , div ) ;
275+ ReactDOM . render ( < Methods schema = { schema as any } disableTransitionProps = { true } /> , div ) ;
217276 expect ( div . innerHTML . includes ( "tag3" ) ) . toBe ( true ) ;
218277 expect ( div . innerHTML . includes ( "tag4" ) ) . toBe ( true ) ;
219278 expect ( div . innerHTML . includes ( "salad" ) ) . toBe ( true ) ;
0 commit comments