Skip to content

Commit 825e566

Browse files
authored
Merge branch 'master' into review-guide
2 parents 78210e2 + 2c76665 commit 825e566

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import path from 'path';
2+
import { render } from '@asyncapi/generator-react-sdk';
3+
import { Parser, fromFile } from '@asyncapi/parser';
4+
import { getQueryParams } from '@asyncapi/generator-helpers';
5+
import { Requires } from '../../components/Requires.js';
6+
7+
const parser = new Parser();
8+
const asyncapiFilePath = path.resolve(
9+
__dirname,
10+
'../../../../../../helpers/test/__fixtures__/asyncapi-websocket-query.yml'
11+
);
12+
13+
describe('Requires component (integration with AsyncAPI document)', () => {
14+
let parsedAsyncAPIDocument;
15+
16+
beforeAll(async () => {
17+
const parseResult = await fromFile(parser, asyncapiFilePath).parse();
18+
parsedAsyncAPIDocument = parseResult.document;
19+
});
20+
21+
test('renders correctly with query params', () => {
22+
const channels = parsedAsyncAPIDocument.channels();
23+
const queryParams = getQueryParams(channels);
24+
const result = render(<Requires query={queryParams} />);
25+
expect(result.trim()).toMatchSnapshot();
26+
});
27+
28+
test('renders correctly with null query', () => {
29+
const result = render(<Requires query={null} />);
30+
expect(result.trim()).toMatchSnapshot();
31+
});
32+
33+
test('renders correctly with undefined query', () => {
34+
const result = render(<Requires />);
35+
expect(result.trim()).toMatchSnapshot();
36+
});
37+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2+
3+
exports[`Requires component (integration with AsyncAPI document) renders correctly with null query 1`] = `
4+
"import json
5+
import certifi
6+
import threading
7+
import websocket"
8+
`;
9+
10+
exports[`Requires component (integration with AsyncAPI document) renders correctly with query params 1`] = `
11+
"import json
12+
import certifi
13+
import threading
14+
import websocket
15+
import os
16+
from urllib.parse import urlencode"
17+
`;
18+
19+
exports[`Requires component (integration with AsyncAPI document) renders correctly with undefined query 1`] = `
20+
"import json
21+
import certifi
22+
import threading
23+
import websocket"
24+
`;

0 commit comments

Comments
 (0)