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

doc: fix documented mock request example #1341

Merged
merged 1 commit into from Apr 16, 2022

Conversation

austinkelleher
Copy link
Contributor

Small fix to a mock request example that was broken.

import { request } from 'undici'

export async function bankTransfer(recepient, ammount) {
const { body } = await request('http://localhost:3000/bank-transfer',
const { body } = await request('http://localhost:3000/bank-transfer',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to the undici .editorconfig, trimming trailing whitespace is the preferred style.

@codecov-commenter
Copy link

codecov-commenter commented Apr 16, 2022

Codecov Report

Merging #1341 (4a44a6b) into main (398554e) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1341   +/-   ##
=======================================
  Coverage   94.12%   94.12%           
=======================================
  Files          45       45           
  Lines        4205     4205           
=======================================
  Hits         3958     3958           
  Misses        247      247           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 398554e...4a44a6b. Read the comment docs.

import { request } from 'undici'

export async function bankTransfer(recepient, ammount) {
const { body } = await request('http://localhost:3000/bank-transfer',
export async function bankTransfer(recepient, amount) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typo correction ammount -> amount

body: JSON.stringify({ recepient })
body: JSON.stringify({
recepient,
amount
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the real fix. amount wasn't being included in the body and caused the first assertion to fail.

@@ -28,7 +31,7 @@ And this is what the test file looks like:
// index.test.mjs
import { strict as assert } from 'assert'
import { MockAgent, setGlobalDispatcher, } from 'undici'
import { bankTransfer } from './undici.mjs'
import { bankTransfer } from './bank.mjs'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm all contributing to docs in this area are really welcomed!

@mcollina mcollina merged commit 71fd87f into nodejs:main Apr 16, 2022
KhafraDev pushed a commit to KhafraDev/undici that referenced this pull request Jun 23, 2022
metcoder95 pushed a commit to metcoder95/undici that referenced this pull request Dec 26, 2022
crysmags pushed a commit to crysmags/undici that referenced this pull request Feb 27, 2024
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

3 participants