Skip to content
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

Fix status code and json request normalization #213

Merged

Conversation

maxb08
Copy link
Contributor

@maxb08 maxb08 commented Aug 7, 2023

Description

Two fixes:

  1. Status code was not being passed along due to improper nesting + parameters to the Request constructor.
  2. Change normalize request so that any application/json request types send the body to mock handler as an object instead of a string. Express sends as an object so there's a discrepancy where the mocks receive two different data types depending on where they're run.

Motivation and Context

Ensure compatibility of mocks written for parrot-middleware with parrot-fetch.

How Has This Been Tested?

Unit tests + manual verification

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (adding or updating documentation)
  • Dependency update

Checklist:

  • My change requires a change to the documentation and I have updated the documentation accordingly.
  • My changes are in sync with the code style of this project.
  • There aren't any other open Pull Requests for the same issue/update.
  • These changes should be applied to a maintenance branch.
  • This change requires cross browser checks.
  • This change impacts caching for client browsers.
  • I have added the Apache 2.0 license header to any new files created.

What is the Impact to Developers Using parrot?

parrot-fetch should now be more compatible with parrot-middleware mocks.

@maxb08 maxb08 requested a review from a team as a code owner August 7, 2023 15:16
@CLAassistant
Copy link

CLAassistant commented Aug 7, 2023

CLA assistant check
All committers have signed the CLA.

@maxb08
Copy link
Contributor Author

maxb08 commented Aug 7, 2023

Can't reproduce the node 16 runner result locally while trying to match all versions, very odd (same node+npm & npm ci)

edit: found it. Must be that we're failing on unhandled promise rejections (iirc it's opt in for node 16), and I forgot to await on expect(...).resolves.toBe

@maxb08 maxb08 force-pushed the bugfix/incorrect-status-code branch from b717eb4 to 2e7a1f2 Compare August 7, 2023 20:28
@Matthew-Mallimo Matthew-Mallimo merged commit 43c15f7 into americanexpress:main Aug 17, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants