diff --git a/library/src/__tests__/index.test.tsx b/library/src/__tests__/index.test.tsx index 05912ca2d..70a8c0951 100644 --- a/library/src/__tests__/index.test.tsx +++ b/library/src/__tests__/index.test.tsx @@ -155,4 +155,63 @@ describe('AsyncAPI component', () => { expect(result.container.querySelector('#introduction')).toBeDefined(), ); }); + + test('should work with all options', async () => { + const schema = { + asyncapi: '2.0.0', + info: { + title: 'Example AsyncAPI', + version: '0.1.0', + }, + servers: { + 'example-server': { + url: 'test.example.org', + protocol: 'mqtt', + }, + }, + channels: { + 'example-channel': { + subscribe: { + message: { + payload: { + type: 'object', + properties: { + exampleField: { + type: 'string', + }, + exampleNumber: { + type: 'number', + }, + exampleDate: { + type: 'string', + format: 'date-time', + }, + }, + }, + }, + }, + }, + }, + }; + const result = render( + , + ); + + await waitFor(() => + expect(result.container.querySelector('#introduction')).toBeDefined(), + ); + }); }); diff --git a/library/src/containers/Sidebar/Sidebar.tsx b/library/src/containers/Sidebar/Sidebar.tsx index f8c42503d..92b3d2df8 100644 --- a/library/src/containers/Sidebar/Sidebar.tsx +++ b/library/src/containers/Sidebar/Sidebar.tsx @@ -23,15 +23,11 @@ export const Sidebar: React.FunctionComponent = () => { .get('x-logo') ?.value(); const components = asyncapi.components(); - const messages = components && components.messages(); - const schemas = components && components.schemas(); - const hasOperations = - asyncapi.channels().length > 0 && - Object.values(asyncapi.channels()).some( - channel => channel.operations().length > 0, - ); + const messages = components?.messages().all(); + const schemas = components?.schemas().all(); + const hasOperations = asyncapi.operations().length > 0; - const messagesList = messages && Object.keys(messages).length > 0 && ( + const messagesList = messages?.length > 0 && (
  • { Messages