-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(util-body-length-browser): multi-byte body lengths for browser (#…
- Loading branch information
Showing
3 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { calculateBodyLength } from "./"; | ||
|
||
const arrayBuffer = new ArrayBuffer(1); | ||
const typedArray = new Uint8Array(1); | ||
const view = new DataView(arrayBuffer); | ||
|
||
describe("caclulateBodyLength", () => { | ||
it("should handle string inputs", () => { | ||
expect(calculateBodyLength("foo")).toEqual(3); | ||
}); | ||
|
||
it("should handle string inputs with multi-byte characters", () => { | ||
expect(calculateBodyLength("2。")).toEqual(4); | ||
}); | ||
|
||
it("should handle inputs with byteLengths", () => { | ||
expect(calculateBodyLength(arrayBuffer)).toEqual(1); | ||
}); | ||
|
||
it("should handle TypedArray inputs", () => { | ||
expect(calculateBodyLength(typedArray)).toEqual(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters