mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
console: fix printing of Response(Bun.file()) (#20933)
This commit is contained in:
@@ -3,7 +3,7 @@ const Body = @This();
|
||||
|
||||
value: Value, // = Value.empty,
|
||||
|
||||
pub inline fn len(this: *const Body) Blob.SizeType {
|
||||
pub fn len(this: *Body) Blob.SizeType {
|
||||
return this.value.size();
|
||||
}
|
||||
|
||||
@@ -366,9 +366,9 @@ pub const Value = union(Tag) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn size(this: *const Value) Blob.SizeType {
|
||||
pub fn size(this: *Value) Blob.SizeType {
|
||||
return switch (this.*) {
|
||||
.Blob => this.Blob.size,
|
||||
.Blob => @truncate(this.Blob.getSizeForBindings()),
|
||||
.InternalBlob => @as(Blob.SizeType, @truncate(this.InternalBlob.sliceConst().len)),
|
||||
.WTFStringImpl => @as(Blob.SizeType, @truncate(this.WTFStringImpl.utf8ByteLength())),
|
||||
.Locked => this.Locked.sizeHint(),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { sep } from "node:path";
|
||||
|
||||
test("zero args returns an otherwise empty 200 response", () => {
|
||||
const response = new Response();
|
||||
@@ -44,3 +45,22 @@ describe("2-arg form", () => {
|
||||
expect(response.statusText).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
test("print size", () => {
|
||||
expect(Bun.inspect(new Response(Bun.file(import.meta.filename)))).toMatchInlineSnapshot(`
|
||||
"Response (1.81 KB) {
|
||||
ok: true,
|
||||
url: "",
|
||||
status: 200,
|
||||
statusText: "",
|
||||
headers: Headers {
|
||||
"content-type": "text/javascript;charset=utf-8",
|
||||
},
|
||||
redirected: false,
|
||||
bodyUsed: false,
|
||||
FileRef ("${import.meta.dir}${sep}response.test.ts") {
|
||||
type: "text/javascript;charset=utf-8"
|
||||
}
|
||||
}"
|
||||
`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user