Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import path from 'path';
import { render } from '@asyncapi/generator-react-sdk';
import { Parser, fromFile } from '@asyncapi/parser';
import { getQueryParams } from '@asyncapi/generator-helpers';
import { Constructor } from '../../components/Constructor';


Check failure on line 7 in packages/templates/clients/websocket/java/quarkus/test/components/Constructor.test.js

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

More than 1 blank line not allowed
const parser = new Parser();
const asyncapiFilePath = path.resolve(__dirname, '../../../../test/__fixtures__/asyncapi-websocket-components.yml');


Check failure on line 11 in packages/templates/clients/websocket/java/quarkus/test/components/Constructor.test.js

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

More than 1 blank line not allowed
describe('Constructor component (integration with AsyncAPI document)', () => {
let parsedAsyncAPIDocument;
let channels;
let queryParams;

beforeAll(async () => {
const parseResult = await fromFile(parser, asyncapiFilePath).parse();
parsedAsyncAPIDocument = parseResult.document;
channels = parsedAsyncAPIDocument.channels();
queryParams = getQueryParams(channels);
});

test('renders nothing when query is null', () => {
const result = render(<Constructor clientName="WebSocketClient" query={null} />);
expect(result.trim()).toMatchSnapshot();
});

test('renders nothing when query has no entries', () => {
const emptyQuery = new Map();
const result = render(<Constructor clientName="WebSocketClient" query={emptyQuery} />);
expect(result.trim()).toMatchSnapshot();
});

test('renders constructor when query parameters are present', () => {
const result = render(<Constructor clientName="WebSocketClient" query={queryParams} />);
expect(result.trim()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Constructor component (integration with AsyncAPI document) renders constructor when query parameters are present 1`] = `
"public WebSocketClient(){
this(\\"false\\", \\"true\\", null);
}

public WebSocketClient(String heartbeat, String bids, String sessionId){
params = new HashMap<>();
this.heartbeat = (heartbeat != null && !heartbeat.isEmpty()) ? heartbeat : System.getenv(\\"HEARTBEAT\\");
if (this.heartbeat != null){
params.put(\\"heartbeat\\", this.heartbeat);
}
this.bids = (bids != null && !bids.isEmpty()) ? bids : System.getenv(\\"BIDS\\");
if (this.bids != null){
params.put(\\"bids\\", this.bids);
}
this.sessionId = (sessionId != null && !sessionId.isEmpty()) ? sessionId : System.getenv(\\"SESSIONID\\");
if (this.sessionId != null){
params.put(\\"sessionId\\", this.sessionId);
}
}"
`;

exports[`Constructor component (integration with AsyncAPI document) renders nothing when query has no entries 1`] = `""`;

exports[`Constructor component (integration with AsyncAPI document) renders nothing when query is null 1`] = `""`;
Loading