diff options
-rw-r--r-- | test/js/node/fs/fs.test.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/js/node/fs/fs.test.ts b/test/js/node/fs/fs.test.ts index ec2cd1398..e2de62480 100644 --- a/test/js/node/fs/fs.test.ts +++ b/test/js/node/fs/fs.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from "bun:test"; +import { dirname } from "node:path"; import { gc } from "harness"; import fs, { closeSync, @@ -31,6 +32,7 @@ import fs, { symlinkSync, writevSync, readvSync, + fstatSync, } from "node:fs"; import _promises from "node:fs/promises"; @@ -1432,6 +1434,26 @@ describe("fs/promises", () => { }); }); +it("stat on a large file", () => { + var dest: string = "", + fd; + try { + dest = `${tmpdir()}/fs.test.js/${Math.trunc(Math.random() * 10000000000).toString(32)}.stat.txt`; + mkdirSync(dirname(dest), { recursive: true }); + const bigBuffer = new Uint8Array(1024 * 1024 * 1024); + fd = openSync(dest, "w"); + let offset = 0; + while (offset < 5 * 1024 * 1024 * 1024) { + offset += writeSync(fd, bigBuffer, 0, bigBuffer.length, offset); + } + + expect(fstatSync(fd).size).toEqual(offset); + } finally { + if (fd) closeSync(fd); + unlinkSync(dest); + } +}); + it("fs.constants", () => { expect(constants).toBeDefined(); expect(constants.F_OK).toBeDefined(); |