Repository navigation
Commit 3928202
authored
test(teeny-request): add multi-byte UTF-8 Content-Length unit test (#9763)
## Description
Adds a multi-byte UTF-8 string `Content-Length` unit test for
`bunFetch`.
## Impact
Verifies byte-accurate `Content-Length` headers for non-ASCII string
request bodies.
## Changes
- Follow up on review feedback in
#9748
(`b/578941498`).
- Add a unit test case in `core/packages/teeny-request/test/index.ts`
sending a multi-byte UTF-8 string body (`'hello 🌍'`, 8 UTF-16 code units
/ 10 UTF-8 bytes) via `bunFetch` and asserting that `Content-Length` is
`'10'`.
## Testing
- Ran `core/packages/teeny-request` unit tests 5 consecutive times on
Node.js (`pnpm --dir core/packages/teeny-request test`) and 5
consecutive times on Bun (`JS_RUNTIME=bun MOCHA_PARALLEL=false bun --bun
run --cwd core/packages/teeny-request test`).
- Verified `GIT_DIFF_ARG="upstream/main...HEAD -- :!packages" node
./bin/linter.mjs --strict` and `ci/run_conditional_tests.sh --strict`
pass.
## Alternatives
- Relying solely on the existing ASCII `'hello'` test was considered and
rejected because ASCII strings have identical character length and UTF-8
byte length (`5`), which would not catch regressions that use
`body.length` instead of `Buffer.byteLength(body)`.
- Not merging this PR was considered, which would leave multi-byte UTF-8
string `Content-Length` calculation in `bunFetch` without regression
coverage.1 parent 2762a27 commit 3928202
1 file changed
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
707 | 707 | | |
708 | 708 | | |
709 | 709 | | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
710 | 735 | | |
711 | 736 | | |
712 | 737 | | |
| |||
0 commit comments