Skip to content

Commit 280b8c0

Browse files
authored
Merge branch 'master' into ishi
2 parents 7469b85 + 3d9534e commit 280b8c0

File tree

4 files changed

+146
-0
lines changed

4 files changed

+146
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { render } from '@asyncapi/generator-react-sdk';
2+
import { Installation } from '../../src/components/readme/Installation';
3+
4+
describe('Installation component', () => {
5+
test('renders javascript installation command', () => {
6+
const result = render(<Installation language="javascript" />);
7+
expect(result.trim()).toMatchSnapshot();
8+
});
9+
10+
test('renders python installation command', () => {
11+
const result = render(<Installation language="python" />);
12+
expect(result.trim()).toMatchSnapshot();
13+
});
14+
15+
test('renders installation section when language is undefined', () => {
16+
const result = render(<Installation />);
17+
const output = result.trim();
18+
19+
// Explicitly document current behavior
20+
expect(output).toContain('## Installation');
21+
expect(output).toContain('Install dependencies');
22+
expect(output).toContain('undefined');
23+
});
24+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Installation component renders javascript installation command 1`] = `
4+
"## Installation
5+
6+
Install dependencies:
7+
8+
\`\`\`bash
9+
npm install
10+
\`\`\`"
11+
`;
12+
13+
exports[`Installation component renders python installation command 1`] = `
14+
"## Installation
15+
16+
Install dependencies:
17+
18+
\`\`\`bash
19+
pip install -r requirements.txt
20+
\`\`\`"
21+
`;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 { ClientDependencies } from '../../components/dependencies/ClientDependencies';
6+
7+
const parser = new Parser();
8+
const asyncapiFilePath = path.resolve(__dirname, '../../../../test/__fixtures__/asyncapi-websocket-components.yml');
9+
10+
describe('ClientDependencies component (integration with AsyncAPI document)', () => {
11+
let parsedAsyncAPIDocument;
12+
let channels;
13+
let queryParams;
14+
15+
beforeAll(async () => {
16+
const parseResult = await fromFile(parser, asyncapiFilePath).parse();
17+
parsedAsyncAPIDocument = parseResult.document;
18+
channels = parsedAsyncAPIDocument.channels();
19+
queryParams = getQueryParams(channels);
20+
});
21+
22+
test('renders base dependencies without HashMap import when queryParams is null', () => {
23+
const result = render(<ClientDependencies queryParams={null} />);
24+
expect(result.trim()).toMatchSnapshot();
25+
});
26+
27+
test('renders base dependencies without HashMap import when queryParams is undefined', () => {
28+
const result = render(<ClientDependencies />);
29+
expect(result.trim()).toMatchSnapshot();
30+
});
31+
32+
test('renders dependencies with HashMap import when queryParams is empty Map', () => {
33+
const emptyMap = new Map();
34+
const result = render(<ClientDependencies queryParams={emptyMap} />);
35+
expect(result.trim()).toMatchSnapshot();
36+
});
37+
38+
test('renders dependencies with HashMap import when queryParams has data from fixture', () => {
39+
const result = render(<ClientDependencies queryParams={queryParams} />);
40+
expect(result.trim()).toMatchSnapshot();
41+
});
42+
});
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`ClientDependencies component (integration with AsyncAPI document) renders base dependencies without HashMap import when queryParams is null 1`] = `
4+
"package com.asyncapi;
5+
6+
import io.quarkus.websockets.next.WebSocketClient;
7+
import io.quarkus.websockets.next.WebSocketClientConnection;
8+
import io.quarkus.websockets.next.OnOpen;
9+
import io.quarkus.websockets.next.OnClose;
10+
import io.quarkus.websockets.next.OnError;
11+
import io.quarkus.websockets.next.OnTextMessage;
12+
import io.quarkus.websockets.next.CloseReason;
13+
import jakarta.inject.Inject;
14+
import org.jboss.logging.Logger;"
15+
`;
16+
17+
exports[`ClientDependencies component (integration with AsyncAPI document) renders base dependencies without HashMap import when queryParams is undefined 1`] = `
18+
"package com.asyncapi;
19+
20+
import io.quarkus.websockets.next.WebSocketClient;
21+
import io.quarkus.websockets.next.WebSocketClientConnection;
22+
import io.quarkus.websockets.next.OnOpen;
23+
import io.quarkus.websockets.next.OnClose;
24+
import io.quarkus.websockets.next.OnError;
25+
import io.quarkus.websockets.next.OnTextMessage;
26+
import io.quarkus.websockets.next.CloseReason;
27+
import jakarta.inject.Inject;
28+
import org.jboss.logging.Logger;"
29+
`;
30+
31+
exports[`ClientDependencies component (integration with AsyncAPI document) renders dependencies with HashMap import when queryParams has data from fixture 1`] = `
32+
"package com.asyncapi;
33+
34+
import io.quarkus.websockets.next.WebSocketClient;
35+
import io.quarkus.websockets.next.WebSocketClientConnection;
36+
import io.quarkus.websockets.next.OnOpen;
37+
import io.quarkus.websockets.next.OnClose;
38+
import io.quarkus.websockets.next.OnError;
39+
import io.quarkus.websockets.next.OnTextMessage;
40+
import io.quarkus.websockets.next.CloseReason;
41+
import jakarta.inject.Inject;
42+
import org.jboss.logging.Logger;
43+
import java.util.HashMap;"
44+
`;
45+
46+
exports[`ClientDependencies component (integration with AsyncAPI document) renders dependencies with HashMap import when queryParams is empty Map 1`] = `
47+
"package com.asyncapi;
48+
49+
import io.quarkus.websockets.next.WebSocketClient;
50+
import io.quarkus.websockets.next.WebSocketClientConnection;
51+
import io.quarkus.websockets.next.OnOpen;
52+
import io.quarkus.websockets.next.OnClose;
53+
import io.quarkus.websockets.next.OnError;
54+
import io.quarkus.websockets.next.OnTextMessage;
55+
import io.quarkus.websockets.next.CloseReason;
56+
import jakarta.inject.Inject;
57+
import org.jboss.logging.Logger;
58+
import java.util.HashMap;"
59+
`;

0 commit comments

Comments
 (0)