summaryrefslogtreecommitdiff
path: root/std/node/_fs/_fs_appendFile_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/node/_fs/_fs_appendFile_test.ts')
-rw-r--r--std/node/_fs/_fs_appendFile_test.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/std/node/_fs/_fs_appendFile_test.ts b/std/node/_fs/_fs_appendFile_test.ts
index ca48dc5d3..402ac1c10 100644
--- a/std/node/_fs/_fs_appendFile_test.ts
+++ b/std/node/_fs/_fs_appendFile_test.ts
@@ -2,6 +2,7 @@
const { test } = Deno;
import { assertEquals, assertThrows, fail } from "../../testing/asserts.ts";
import { appendFile, appendFileSync } from "./_fs_appendFile.ts";
+import { fromFileUrl } from "../path.ts";
const decoder = new TextDecoder("utf-8");
@@ -110,6 +111,31 @@ test({
});
test({
+ name: "Async: Data is written to passed in URL",
+ async fn() {
+ const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources();
+ const fileURL = new URL("_fs_appendFile_test_file.txt", import.meta.url);
+ await new Promise((resolve, reject) => {
+ appendFile(fileURL, "hello world", (err) => {
+ if (err) reject(err);
+ else resolve();
+ });
+ })
+ .then(async () => {
+ assertEquals(Deno.resources(), openResourcesBeforeAppend);
+ const data = await Deno.readFile(fromFileUrl(fileURL));
+ assertEquals(decoder.decode(data), "hello world");
+ })
+ .catch((err) => {
+ fail("No error was expected: " + err);
+ })
+ .finally(async () => {
+ await Deno.remove(fromFileUrl(fileURL));
+ });
+ },
+});
+
+test({
name:
"Async: Callback is made with error if attempting to append data to an existing file with 'ax' flag",
async fn() {