-
-
Notifications
You must be signed in to change notification settings - Fork 382
test: add tests for overview component #1947
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 4 commits into
asyncapi:master
from
batchu5:test/add-tests-overview-component
Feb 8, 2026
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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,69 @@ | ||
| import path from 'path'; | ||
| import { render } from '@asyncapi/generator-react-sdk'; | ||
| import { Parser, fromFile } from '@asyncapi/parser'; | ||
| import { getServer, getServerUrl } from '@asyncapi/generator-helpers'; | ||
| import { Overview } from '../../src/components/readme/Overview'; | ||
|
|
||
| const parser = new Parser(); | ||
| const asyncapi_websocket_query = path.resolve(__dirname, '../../../helpers/test/__fixtures__/asyncapi-websocket-query.yml'); | ||
|
|
||
| describe('Testing of Overview component', () => { | ||
| let parsedAsyncAPIDocument; | ||
| let info; | ||
| let title; | ||
| let serverUrl; | ||
|
|
||
| beforeAll(async () => { | ||
| const parseResult = await fromFile(parser, asyncapi_websocket_query).parse(); | ||
| parsedAsyncAPIDocument = parseResult.document; | ||
|
|
||
| info = parsedAsyncAPIDocument.info(); | ||
| title = info.title(); | ||
|
|
||
| const server = getServer(parsedAsyncAPIDocument.servers(), 'withHostDuplicatingProtocol'); | ||
| serverUrl = getServerUrl(server); | ||
| }); | ||
|
|
||
| test('render overview component with all parameters', () => { | ||
| const result = render( | ||
| <Overview | ||
| info={info} | ||
| title={title} | ||
| serverUrl={serverUrl} | ||
| /> | ||
| ); | ||
|
|
||
| const actual = result.trim(); | ||
| expect(actual).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test('throws error when info is missing', () => { | ||
| expect(() => { | ||
| render(<Overview title={title} serverUrl={serverUrl}/>); | ||
| }).toThrow(TypeError); | ||
| }); | ||
|
|
||
| test('render overview component when title is missing', () => { | ||
| const result = render( | ||
| <Overview | ||
| info={info} | ||
| serverUrl={serverUrl} | ||
| /> | ||
| ); | ||
|
|
||
| const actual = result.trim(); | ||
| expect(actual).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test('render overview component when serverUrl is missing', () => { | ||
| const result = render( | ||
| <Overview | ||
| info={info} | ||
| title={title} | ||
| /> | ||
| ); | ||
|
|
||
| const actual = result.trim(); | ||
| expect(actual).toMatchSnapshot(); | ||
| }); | ||
| }); | ||
31 changes: 31 additions & 0 deletions
31
packages/components/test/components/__snapshots__/Overview.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[`Testing of Overview component render overview component when serverUrl is missing 1`] = ` | ||
| "## Overview | ||
|
|
||
| Market data is a public API that streams all the market data on a given symbol. | ||
|
|
||
|
|
||
| - **Version:** 1.0.0 | ||
| - **Server URL:** undefined" | ||
| `; | ||
|
|
||
| exports[`Testing of Overview component render overview component when title is missing 1`] = ` | ||
| "## Overview | ||
|
|
||
| Market data is a public API that streams all the market data on a given symbol. | ||
|
|
||
|
|
||
| - **Version:** 1.0.0 | ||
| - **Server URL:** wss://api.gemini.com" | ||
| `; | ||
|
|
||
| exports[`Testing of Overview component render overview component with all parameters 1`] = ` | ||
| "## Overview | ||
|
|
||
| Market data is a public API that streams all the market data on a given symbol. | ||
|
|
||
|
|
||
| - **Version:** 1.0.0 | ||
| - **Server URL:** wss://api.gemini.com" | ||
| `; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah some other components incorrectly uses this fixture but this should be actually one inside components https://github.com/asyncapi/generator/blob/master/packages/components/test/__fixtures__/asyncapi-v3.yml
please use this one. you can make changes in fixtures only if testing requires.