File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -274,3 +274,55 @@ it("renders schema methods tags", () => {
274274 expect ( div . innerHTML . includes ( "Object" ) ) . toBe ( true ) ;
275275 ReactDOM . unmountComponentAtNode ( div ) ;
276276} ) ;
277+
278+ it ( "renders schema methods examples" , ( ) => {
279+ const div = document . createElement ( "div" ) ;
280+ const schema = {
281+ methods : [
282+ {
283+ examples : [
284+ {
285+ name : "foo" ,
286+ } ,
287+ ] ,
288+ } ,
289+ ] ,
290+ } ;
291+ ReactDOM . render ( < Methods schema = { schema as any } disableTransitionProps = { true } /> , div ) ;
292+ expect ( div . innerHTML . includes ( "foo" ) ) . toBe ( true ) ;
293+ ReactDOM . unmountComponentAtNode ( div ) ;
294+ } ) ;
295+
296+ it ( "renders schema methods examples with schema.examples fallback" , ( ) => {
297+ const div = document . createElement ( "div" ) ;
298+ const schema : OpenrpcDocument = {
299+ info : {
300+ title : "test" ,
301+ version : "0.0.0" ,
302+ } ,
303+ methods : [
304+ {
305+ name : "test-method" ,
306+ params : [ {
307+ name : "testparam1" ,
308+ schema : {
309+ examples : [ "bob" ] ,
310+ type : "string" ,
311+ } ,
312+ } ] ,
313+ result : {
314+ name : "test-method-result" ,
315+ schema : {
316+ examples : [ "potato" ] ,
317+ type : "string" ,
318+ } ,
319+ } ,
320+ } ,
321+ ] ,
322+ openrpc : "1.0.0" ,
323+ } ;
324+ ReactDOM . render ( < Methods schema = { schema as any } disableTransitionProps = { true } /> , div ) ;
325+ expect ( div . innerHTML . includes ( "potato" ) ) . toBe ( true ) ;
326+ expect ( div . innerHTML . includes ( "bob" ) ) . toBe ( true ) ;
327+ ReactDOM . unmountComponentAtNode ( div ) ;
328+ } ) ;
You can’t perform that action at this time.
0 commit comments