summaryrefslogtreecommitdiff
path: root/cli/tests/unit_node/_fs/_fs_handle_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/unit_node/_fs/_fs_handle_test.ts')
-rw-r--r--cli/tests/unit_node/_fs/_fs_handle_test.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/cli/tests/unit_node/_fs/_fs_handle_test.ts b/cli/tests/unit_node/_fs/_fs_handle_test.ts
new file mode 100644
index 000000000..c1e5ef871
--- /dev/null
+++ b/cli/tests/unit_node/_fs/_fs_handle_test.ts
@@ -0,0 +1,20 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+import * as path from "../../../../test_util/std/path/mod.ts";
+import {
+ assert,
+ assertEquals,
+} from "../../../../test_util/std/testing/asserts.ts";
+
+const moduleDir = path.dirname(path.fromFileUrl(import.meta.url));
+const testData = path.resolve(moduleDir, "testdata", "hello.txt");
+
+Deno.test("readFileSuccess", async function () {
+ const fs = await import("node:fs/promises");
+ const fileHandle = await fs.open(testData);
+ const data = await fileHandle.readFile();
+
+ assert(data instanceof Uint8Array);
+ assertEquals(new TextDecoder().decode(data as Uint8Array), "hello world");
+
+ Deno.close(fileHandle.fd);
+});