aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/bun-write.test.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-10-10 21:01:06 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-10-10 21:01:06 -0700
commite4bf189e9dc1589eff9e72333ef41ab181d86da3 (patch)
tree804225c868d6fe0dc88615c00a8afcc84bf20021 /test/bun.js/bun-write.test.js
parent2292ef8d0e2c0f5ac5523dfb919c4156ad4ea4fb (diff)
downloadbun-e4bf189e9dc1589eff9e72333ef41ab181d86da3.tar.gz
bun-e4bf189e9dc1589eff9e72333ef41ab181d86da3.tar.zst
bun-e4bf189e9dc1589eff9e72333ef41ab181d86da3.zip
Change behavior of Bun.write
Diffstat (limited to 'test/bun.js/bun-write.test.js')
-rw-r--r--test/bun.js/bun-write.test.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/bun.js/bun-write.test.js b/test/bun.js/bun-write.test.js
index b14a0ed14..9355b04bf 100644
--- a/test/bun.js/bun-write.test.js
+++ b/test/bun.js/bun-write.test.js
@@ -56,7 +56,8 @@ describe("large file", () => {
unlinkSync(filename + ".bytes");
} catch (e) {}
var bytes = new TextEncoder().encode(content);
- await Bun.write(filename + ".bytes", bytes);
+ const written = await Bun.write(filename + ".bytes", bytes);
+ expect(written).toBe(bytes.byteLength);
expect(
new Buffer(await Bun.file(filename + ".bytes").arrayBuffer()).equals(
bytes
@@ -247,11 +248,10 @@ it("Response -> Bun.file -> Response -> text", async () => {
await gcTick();
});
-// If you write nothing to a file, it shouldn't modify it
-// If you want to truncate a file, it should be more explicit
it("Bun.write('output.html', '')", async () => {
await Bun.write("/tmp/output.html", "lalalala");
expect(await Bun.write("/tmp/output.html", "")).toBe(0);
+ await Bun.write("/tmp/output.html", "lalalala");
expect(await Bun.file("/tmp/output.html").text()).toBe("lalalala");
});