-
-
Notifications
You must be signed in to change notification settings - Fork 392
test: add component tests for ConnectorFields #2205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
asyncapi-bot
merged 5 commits into
asyncapi:master
from
SushanthMusham:test/connector-fields-component-tests
Aug 26, 2026
+74
−0
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cdefeee
test: add component tests for ConnectorFields
SushanthMusham edb8005
Remove React import from ConnectorFields.test.js
SushanthMusham 9a06b49
Merge branch 'master' into test/connector-fields-component-tests
SushanthMusham b19fd5e
Used Fixtures
SushanthMusham da754f2
test: fix ConnectorFields test - resolve merge conflict and remove un…
SushanthMusham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
packages/templates/clients/websocket/java/quarkus/test/components/ConnectorFields.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import path from 'path'; | ||
| import { render } from '@asyncapi/generator-react-sdk'; | ||
| import { Parser, fromFile } from '@asyncapi/parser'; | ||
| import { getQueryParams } from '@asyncapi/generator-helpers'; | ||
|
|
||
| import { ConnectorFields } from '../../components/ConnectorFields.js'; | ||
|
|
||
| const parser = new Parser(); | ||
| const asyncapiFilePath = path.resolve(__dirname, '../../../../test/__fixtures__/asyncapi-websocket-components.yml'); | ||
|
|
||
| describe('ConnectorFields component (Quarkus WebSocket)', () => { | ||
| let queryParamsArray = []; | ||
|
|
||
| beforeAll(async () => { | ||
| const parseResult = await fromFile(parser, asyncapiFilePath).parse(); | ||
| const parsedAsyncAPIDocument = parseResult.document; | ||
| const channels = parsedAsyncAPIDocument.channels(); | ||
| const queryParamsMap = getQueryParams(channels); | ||
|
|
||
| queryParamsArray = queryParamsMap ? Array.from(queryParamsMap.entries()) : []; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| expect(queryParamsArray.length).toBeGreaterThan(0); | ||
| }); | ||
|
|
||
| test('no query params (undefined) - snapshot', () => { | ||
| const result = render(<ConnectorFields clientName="NotificationsClient" queryParamsArray={undefined} />); | ||
| expect(result.trim()).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test('no query params (empty array) - snapshot', () => { | ||
| const result = render(<ConnectorFields clientName="NotificationsClient" queryParamsArray={[]} />); | ||
| expect(result.trim()).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test('with query params - snapshot', () => { | ||
| const result = render(<ConnectorFields clientName="NotificationsClient" queryParamsArray={queryParamsArray} />); | ||
| expect(result.trim()).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test('robustness: empty clientName - snapshot', () => { | ||
| const result = render(<ConnectorFields clientName="" queryParamsArray={queryParamsArray} />); | ||
| expect(result.trim()).toMatchSnapshot(); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| }); | ||
| }); | ||
31 changes: 31 additions & 0 deletions
31
...clients/websocket/java/quarkus/test/components/__snapshots__/ConnectorFields.test.js.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`ConnectorFields component (Quarkus WebSocket) no query params (empty array) - snapshot 1`] = ` | ||
| "@Inject | ||
| WebSocketConnector<NotificationsClient> connector;" | ||
| `; | ||
|
|
||
| exports[`ConnectorFields component (Quarkus WebSocket) no query params (undefined) - snapshot 1`] = ` | ||
| "@Inject | ||
| WebSocketConnector<NotificationsClient> connector;" | ||
| `; | ||
|
|
||
| exports[`ConnectorFields component (Quarkus WebSocket) robustness: empty clientName - snapshot 1`] = ` | ||
| "@Inject | ||
| WebSocketConnector<> connector; | ||
|
|
||
|
|
||
| @Inject | ||
| @ConfigProperty(name = \\"com.asyncapi..base-uri\\") | ||
| String baseURI;" | ||
| `; | ||
|
|
||
| exports[`ConnectorFields component (Quarkus WebSocket) with query params - snapshot 1`] = ` | ||
| "@Inject | ||
| WebSocketConnector<NotificationsClient> connector; | ||
|
|
||
|
|
||
| @Inject | ||
| @ConfigProperty(name = \\"com.asyncapi.NotificationsClient.base-uri\\") | ||
| String baseURI;" | ||
| `; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.