Skip to content

Commit 690b3b6

Browse files
committed
test: add tests for overview component
1 parent 92de9ee commit 690b3b6

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import path from 'path';
2+
import { render } from '@asyncapi/generator-react-sdk';
3+
import { Parser, fromFile } from '@asyncapi/parser';
4+
import { getServer, getServerUrl } from '@asyncapi/generator-helpers';
5+
import { Overview } from '../../src/components/readme/Overview';
6+
7+
const parser = new Parser();
8+
const asyncapi_websocket_query = path.resolve(__dirname, '../../../helpers/test/__fixtures__/asyncapi-websocket-query.yml');
9+
10+
describe('Testing of Overview component', () => {
11+
let parsedAsyncAPIDocument;
12+
let info;
13+
let title;
14+
let serverUrl;
15+
16+
beforeAll(async () => {
17+
const parseResult = await fromFile(parser, asyncapi_websocket_query).parse();
18+
parsedAsyncAPIDocument = parseResult.document;
19+
20+
info = parsedAsyncAPIDocument.info();
21+
title = info.title();
22+
23+
const server = getServer(parsedAsyncAPIDocument.servers(), 'withHostDuplicatingProtocol');
24+
serverUrl = getServerUrl(server);
25+
});
26+
27+
test('render overview with description correctly', () => {
28+
const result = render(
29+
<Overview
30+
info={info}
31+
title={title}
32+
serverUrl={serverUrl}
33+
/>
34+
);
35+
36+
const actual = result.trim();
37+
expect(actual).toMatchSnapshot();
38+
});
39+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Testing of Overview component render overview with description correctly 1`] = `
4+
"## Overview
5+
6+
Market data is a public API that streams all the market data on a given symbol.
7+
8+
9+
- **Version:** 1.0.0
10+
- **Server URL:** wss://api.gemini.com"
11+
`;

0 commit comments

Comments
 (0)