Skip to content

test: add tests for bindings.js#getQueryParams #1576

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

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

achaljhawar
Copy link
Contributor

@achaljhawar achaljhawar commented May 24, 2025

Description

  • Added unit tests for the getQueryParams function in packages/helpers/src/bindings.js.
  • Covered various scenarios, including missing WebSocket bindings, empty query parameters, and different channel states.

Related issue(s)
resolves #1538

Summary by CodeRabbit

Summary by CodeRabbit

  • Tests
    • Added integration tests for extracting query parameters from WebSocket bindings, covering multiple scenarios including missing or empty queries.
  • Chores
    • Improved internal handling of WebSocket bindings for more efficient checks.
  • New Features
    • Added new AsyncAPI channels supporting WebSocket bindings without query parameters and with empty query objects.

Copy link

changeset-bot bot commented May 24, 2025

⚠️ No Changeset found

Latest commit: 73aa16a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

coderabbitai bot commented May 24, 2025

Warning

Rate limit exceeded

@achaljhawar has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 3 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 7d9eb64 and 73aa16a.

📒 Files selected for processing (1)
  • packages/helpers/test/bindings.test.js (1 hunks)

"""

Walkthrough

A new test suite was added for the getQueryParams function in the bindings module, covering various scenarios including missing, malformed, and valid WebSocket bindings. The getQueryParams implementation was refactored to store channel bindings in a local variable for clarity, without changing its behavior. Additionally, three new channels with distinct WebSocket binding query configurations were added to the AsyncAPI fixture.

Changes

File(s) Change Summary
packages/helpers/test/bindings.test.js Added detailed integration tests for getQueryParams covering multiple edge cases and scenarios.
packages/helpers/src/bindings.js Refactored getQueryParams to cache channel?.bindings?.() in a local variable before processing.
packages/helpers/test/fixtures/asyncapi-websocket-query.yml Added three new channels with WebSocket bindings: one without query parameters, one with empty query, and one with undefined bindings.

Assessment against linked issues

Objective Addressed Explanation
Add unit tests for bindings.js#getQueryParams (#1538)

Poem

In the warren of tests, a new suite appears,
Checking query params, dispelling all fears.
With mocks and with maps, each case is explored,
Ensuring robust code, bugs are ignored.
Now rabbits can rest, their bindings assured! 🐇✨
"""

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@asyncapi-bot
Copy link
Contributor

Hello, @coderabbitai[bot]! 👋🏼

    I'm 🧞🧞🧞 Genie 🧞🧞🧞 from the magic lamp. Looks like somebody needs a hand!

    At the moment the following comments are supported in pull requests:

    - `/please-take-a-look` or `/ptal` - This comment will add a comment to the PR asking for attention from the reviewrs who have not reviewed the PR yet.
    - `/ready-to-merge` or `/rtm` - This comment will trigger automerge of PR in case all required checks are green, approvals in place and do-not-merge label is not added
    - `/do-not-merge` or `/dnm` - This comment will block automerging even if all conditions are met and ready-to-merge label is added
    - `/autoupdate` or `/au` - This comment will add `autoupdate` label to the PR and keeps your PR up-to-date to the target branch's future changes. Unless there is a merge conflict or it is a draft PR. (Currently only works for upstream branches.)
    - `/update` or `/u` - This comment will update the PR with the latest changes from the target branch. Unless there is a merge conflict or it is a draft PR. NOTE: this only updates the PR once, so if you need to update again, you need to call the command again.

Copy link

coderabbitai bot commented May 24, 2025

Tip

For best results, initiate chat on the files or code changes.

@asyncapi-bot Thank you for the helpful information! 🙏 I'm familiar with these commands and will keep them in mind for future interactions in this repository. The slash commands you've listed are quite useful for managing PR workflows.

/\_/\  

( o.o )
> ^ <
| |

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/helpers/test/bindings.test.js (1)

79-79: Fix formatting: Remove extra space.

There's an extra space before the it function call.

-   it('should return null if channel itself is not as expected (e.g. missing bindings function)', () => {
+  it('should return null if channel itself is not as expected (e.g. missing bindings function)', () => {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d39b8c7 and e2b4f5d.

📒 Files selected for processing (1)
  • packages/helpers/test/bindings.test.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test generator as dependency with Node 18
  • GitHub Check: Test generator as dependency with Node 20
🔇 Additional comments (11)
packages/helpers/test/bindings.test.js (11)

1-2: Import statement looks good.

The import correctly brings in the getQueryParams function from the bindings module.


3-14: Well-designed MockChannel class.

The mock class effectively simulates a channel with WebSocket bindings. The bindings() method correctly returns an object with has() and get() methods that properly handle the 'ws' key, which aligns with the expected interface.


16-24: MockChannelsMap implementation is appropriate.

The class extends Map and adds the necessary isEmpty() and all() methods. The implementation correctly delegates to the underlying Map functionality.


26-31: Good test case for missing WebSocket binding.

This test correctly verifies that the function returns null when no WebSocket binding is present in the channel.


33-38: Effective test for WebSocket binding without query parameters.

The test properly simulates a WebSocket binding that exists but returns an empty object from value(), ensuring the function handles this edge case correctly.


40-45: Good coverage for empty query properties.

This test case validates the behavior when a query object exists but has no properties, which is an important edge case.


47-66: Comprehensive test for parameter extraction.

This test excellently covers multiple scenarios:

  • Parameters with string defaults (foo: 'bar')
  • Parameters without defaults (baz: '')
  • Numeric defaults converted to strings (num: '123')

The assertions correctly verify the expected behavior for each case.


68-71: Simple and effective test for empty channels.

Correctly tests the edge case of an empty channels map.


73-83: Excellent edge case coverage.

These tests effectively cover scenarios where:

  • Channel bindings are undefined (lines 73-77)
  • Channel lacks the expected bindings function (lines 79-83)

Both are important defensive programming test cases.


85-96: Great test for malformed data handling.

This test validates that the function gracefully handles cases where properties is not an object, which is an excellent defensive programming practice.


26-97: Comprehensive test suite with excellent coverage.

The test suite thoroughly covers:

  • ✅ Null/missing WebSocket bindings
  • ✅ Empty query parameters
  • ✅ Parameter extraction with various data types
  • ✅ Default value handling
  • ✅ Edge cases (empty maps, undefined bindings, malformed data)
  • ✅ Error conditions

This provides robust validation of the getQueryParams function's behavior across all expected scenarios.

@achaljhawar achaljhawar changed the title Added tests for bindings.js#getQueryParams test: Added tests for bindings.js#getQueryParams May 24, 2025
@achaljhawar achaljhawar changed the title test: Added tests for bindings.js#getQueryParams test: added tests for bindings.js#getQueryParams May 24, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e36c05a and be65fb2.

📒 Files selected for processing (1)
  • packages/helpers/test/bindings.test.js (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/helpers/test/bindings.test.js (1)
packages/helpers/src/bindings.js (2)
  • bindings (21-21)
  • wsBinding (28-28)
🪛 GitHub Check: Test NodeJS PR - ubuntu-latest
packages/helpers/test/bindings.test.js

[failure] 31-31:
Define a constant instead of duplicating this literal 7 times

🪛 GitHub Actions: PR testing - if Node project
packages/helpers/test/bindings.test.js

[error] 31-31: ESLint: Define a constant instead of duplicating this literal 7 times (sonarjs/no-duplicate-string)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Test generator as dependency with Node 18
  • GitHub Check: Test generator as dependency with Node 20
  • GitHub Check: Acceptance tests for generated templates
🔇 Additional comments (10)
packages/helpers/test/bindings.test.js (10)

1-4: Good test setup with appropriate imports and constants.

The imports and WS_BINDING_KEY constant are well-defined and follow good testing practices.


5-16: Well-designed MockChannel class for testing.

The MockChannel class properly simulates the channel interface with a realistic bindings() method implementation. The mock correctly handles the Map-like interface with has() and get() methods.


18-26: MockChannelsMap extends Map appropriately.

The class extends Map and adds the required isEmpty() and all() methods that match the expected interface for the channels parameter.


35-40: Test correctly validates empty WebSocket binding.

The test properly checks that when a WebSocket binding exists but has no query parameters, the function returns null.


42-47: Good edge case coverage for empty query properties.

This test ensures the function handles the case where query exists but has no properties correctly.


49-68: Comprehensive test for query parameter extraction and type conversion.

This test excellently covers:

  • Parameters with default values
  • Parameters without default values (empty string)
  • Numeric default values converted to strings
  • Proper Map interface usage for the returned parameters

The assertions verify all expected behaviors of the function.


70-73: Appropriate test for empty channels map.

This edge case test ensures the function handles empty input gracefully.


75-79: Good test for undefined bindings.

This test covers the case where the bindings() method returns undefined, which is a realistic edge case.


81-85: Important test for missing bindings function.

This test ensures robustness when channel objects don't have the expected bindings() method.


87-98: Excellent edge case for malformed properties.

This test ensures the function handles malformed data gracefully when properties is not an object as expected.

@ItshMoh
Copy link
Contributor

ItshMoh commented May 26, 2025

hey @achaljhawar The tests are failing. The linter tests are failing. Run npm run lint before pushing the changes and if there is any linting issues found npm run lint:fix to solve this issue.
And also update the branch.

@achaljhawar
Copy link
Contributor Author

@ItshMoh I have fixed the linting error

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/helpers/test/bindings.test.js (1)

1-100: Consider adding test for multiple channels scenario.

The test suite is comprehensive and well-structured. Consider adding a test case to verify behavior when multiple channels exist, ensuring the function correctly finds and processes the first WebSocket binding.

+  it('should return query params from first channel with WebSocket binding when multiple channels exist', () => {
+    const channels = new MockChannelsMap();
+    const wsBinding = {
+      value: () => ({
+        query: {
+          properties: {
+            testParam: { default: 'firstChannel' },
+          },
+        },
+      }),
+    };
+    
+    channels.set('channel1', new MockChannel(null)); // No WS binding
+    channels.set('channel2', new MockChannel(wsBinding)); // Has WS binding
+    channels.set('channel3', new MockChannel({ value: () => ({ query: { properties: { other: { default: 'second' } } } }) })); // Another WS binding
+    
+    const params = getQueryParams(channels);
+    expect(params).not.toBeNull();
+    expect(params.get('testParam')).toBe('firstChannel');
+  });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be65fb2 and 546a041.

📒 Files selected for processing (1)
  • packages/helpers/test/bindings.test.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Test generator as dependency with Node 20
  • GitHub Check: Test generator as dependency with Node 18
  • GitHub Check: Acceptance tests for generated templates
🔇 Additional comments (11)
packages/helpers/test/bindings.test.js (11)

3-4: LGTM! Constants properly defined.

Good use of constants to avoid string duplication, addressing the previous review feedback effectively.


6-17: Well-designed mock implementation.

The MockChannel class effectively simulates the expected channel behavior with proper bindings() method that returns a Map-like interface. The implementation correctly handles the WebSocket binding key check and returns appropriate values.


19-27: Appropriate mock extending Map functionality.

The MockChannelsMap extends the native Map with the required isEmpty() and all() methods, providing a clean simulation of the actual channels map interface.


30-34: Good edge case coverage.

This test correctly verifies the null return when no WebSocket binding exists, which is an important edge case.


36-41: Validates missing query parameters scenario.

Properly tests the case where WebSocket binding exists but lacks query parameters, ensuring robust error handling.


43-48: Tests empty properties scenario effectively.

This test case ensures the function handles WebSocket bindings with query objects that lack properties, which is another important edge case.


50-69: Comprehensive testing of successful parameter extraction.

This test effectively validates:

  • Parameters with default values are correctly extracted
  • Parameters without defaults get empty string values
  • Numeric defaults are converted to strings (line 68)
  • The function returns a proper Map-like object

The test covers the main happy path scenario thoroughly.


71-74: Good coverage of empty channels scenario.

Tests the edge case of an empty channels map, ensuring the function handles this gracefully.


76-80: Tests undefined bindings scenario.

This test ensures the function handles cases where the channel's bindings() method returns undefined, which is good defensive programming validation.


82-86: Validates malformed channel objects.

Tests the scenario where a channel object doesn't have the expected bindings function, ensuring the function doesn't crash on unexpected input.


88-99: Excellent edge case testing.

This test validates that the function gracefully handles malformed query data where properties is not an object, preventing potential runtime errors.

@derberg derberg changed the title test: added tests for bindings.js#getQueryParams test: add tests for bindings.js#getQueryParams May 26, 2025
Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please refactor test and follow approach from other helper tests where we do not mock data inside test but reuse a test fixture like this https://github.com/asyncapi/generator/blob/master/packages/helpers/test/servers.test.js#L6

@achaljhawar achaljhawar requested a review from derberg May 26, 2025 16:42
@achaljhawar
Copy link
Contributor Author

achaljhawar commented May 26, 2025

@derberg I have updated bindings.test.js to use test fixtures

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/helpers/test/__fixtures__/asyncapi-websocket-query.yml (1)

146-146: Add a newline at end of file
YAML files should end with a trailing newline to satisfy linters and avoid parsing warnings.

--- a/packages/helpers/test/__fixtures__/asyncapi-websocket-query.yml
+++ b/packages/helpers/test/__fixtures__/asyncapi-websocket-query.yml
@@ -146 +147
           - ethusd
+
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 146-146: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 546a041 and 3f31e79.

📒 Files selected for processing (2)
  • packages/helpers/test/__fixtures__/asyncapi-websocket-query.yml (2 hunks)
  • packages/helpers/test/bindings.test.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/helpers/test/bindings.test.js
🧰 Additional context used
🪛 YAMLlint (1.37.1)
packages/helpers/test/__fixtures__/asyncapi-websocket-query.yml

[error] 146-146: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test generator as dependency with Node 18
  • GitHub Check: Test generator as dependency with Node 20
🔇 Additional comments (2)
packages/helpers/test/__fixtures__/asyncapi-websocket-query.yml (2)

77-81: Correctly omit query for the missing-query fixture
The wsBindingNoQuery channel intentionally leaves out the query section to validate behavior when no query parameters are defined. Indentation and bindingVersion align with the other fixtures.


82-88: Correct implementation of an empty query schema fixture
The wsBindingEmptyQuery channel defines an empty query object (type: object), which is exactly what you need to test empty-query schema handling. Structure and indentation are consistent.

Comment on lines 30 to 37
const filteredChannels = new Map();
const channelWithoutBinding = channels.get('marketDataV1NoBinding');
if (channelWithoutBinding) {
filteredChannels.set('marketDataV1NoBinding', channelWithoutBinding);
}

filteredChannels.isEmpty = function() { return this.size === 0; };
filteredChannels.all = function() { return this; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of doing this, and need for mocking

how about just using delete on the map? deleting channels that are not needed for given test case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey, I see you did some updates but you did not answer the question

Copy link
Contributor Author

@achaljhawar achaljhawar Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of doing this, and need for mocking

how about just using delete on the map? deleting channels that are not needed for given test case?

Yeah, this can be done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, than please proceed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you check my latest commit I used Map.delete() to implement the fix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed the variable names accordingly

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/helpers/test/__fixtures__/asyncapi-websocket-query.yml (2)

83-89: Explicitly define empty properties for empty query schema
While defining query: { type: object } is valid, adding an explicit properties: {} field makes the intent clearer and aligns with other fixtures that declare properties. This can help avoid ambiguity when the schema is consumed programmatically.

Suggested diff:

 wsBindingEmptyQuery:
   address: '/empty-query'
   bindings:
     ws:
       bindingVersion: 0.1.0
-      query:
-        type: object
+      query:
+        type: object
+        properties: {}

162-162: Add a newline at end of file
YAML files should end with a single newline character to satisfy lint rules (new-line-at-end-of-file). Please add one.

--- a/packages/helpers/test/__fixtures__/asyncapi-websocket-query.yml
+++ b/packages/helpers/test/__fixtures__/asyncapi-websocket-query.yml
@@ components:
-        - ethusd
+        - ethusd
+
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 162-162: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f31e79 and 196311d.

📒 Files selected for processing (1)
  • packages/helpers/test/__fixtures__/asyncapi-websocket-query.yml (2 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
packages/helpers/test/__fixtures__/asyncapi-websocket-query.yml

[error] 162-162: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test generator as dependency with Node 20
  • GitHub Check: Test generator as dependency with Node 18
🔇 Additional comments (1)
packages/helpers/test/__fixtures__/asyncapi-websocket-query.yml (1)

77-82: Correct handling of channels without query binding
Great addition of the wsBindingNoQuery fixture to cover the case where bindings.ws.query is undefined. This will ensure getQueryParams correctly falls back (e.g., to an empty object) when no query schema is provided.

@achaljhawar
Copy link
Contributor Author

@derberg I have implemented the changes you asked me to make

@achaljhawar achaljhawar requested a review from derberg May 30, 2025 20:25
const parser = new Parser();
const asyncapi_v3_path = path.resolve(__dirname, './__fixtures__/asyncapi-websocket-query.yml');

function createChannelsWithOnly(keysToKeep, originalChannels) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we need to create a new map here, and still do some mocking basically of all and isEmpty

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey are you still working on something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am done ig

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we need to create a new map here, and still do some mocking basically of all and isEmpty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohk I'll fix this

Copy link
Contributor Author

@achaljhawar achaljhawar Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I create a second fixture file to fix this problem?
or should I test with the full channel object and verify its behaviour?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not decide yet, first answer my question 😄 why new map is needed, why you cannot operate in the helper on the map you get as input

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new Map is needed to create a copy so the original channels map isn't mutated, which would affect other tests that need the data.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, now much better. Remember reviewer did not code and do not see what issues you had during development. Sometimes we just ask question not to play smart, but to really get an answer 😄 thanks for the context - now it makes sense why you've done so, and why later you still do mocking of all and isEmpty - please add comment to tested code to explain why this mocking is needed

@derberg derberg moved this from Todo to In Progress in Maintainers work Jun 4, 2025
@achaljhawar achaljhawar requested a review from derberg June 4, 2025 18:44
@derberg
Copy link
Member

derberg commented Jun 4, 2025

you pinged me for review again, but I see no changes, and no answers to questions

@achaljhawar
Copy link
Contributor Author

@derberg sorry I pinged you before , I made some changes that remove mocking and refactored the createChannelsWithOnly function to return a Map object directly, instead of an object that mocks the isEmpty and all methods.

const parser = new Parser();
const asyncapi_v3_path = path.resolve(__dirname, './__fixtures__/asyncapi-websocket-query.yml');

function createChannelsWithOnly(keysToKeep, originalChannels) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, now much better. Remember reviewer did not code and do not see what issues you had during development. Sometimes we just ask question not to play smart, but to really get an answer 😄 thanks for the context - now it makes sense why you've done so, and why later you still do mocking of all and isEmpty - please add comment to tested code to explain why this mocking is needed

@achaljhawar achaljhawar requested a review from derberg June 12, 2025 12:28
Copy link

@achaljhawar
Copy link
Contributor Author

@derberg I have made some changes according to your suggestions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

add unit tests for bindings.js#getQueryParams
4 participants