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
Conversation
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', |
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.
According to the undici
.editorconfig
, trimming trailing whitespace is the preferred style.
Codecov Report
@@ 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.
|
7dc1758
to
4a44a6b
Compare
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) { |
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.
Typo correction ammount
-> amount
body: JSON.stringify({ recepient }) | ||
body: JSON.stringify({ | ||
recepient, | ||
amount |
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.
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' |
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.
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.
lgtm all contributing to docs in this area are really welcomed!
Small fix to a mock request example that was broken.