summaryrefslogtreecommitdiff
path: root/std/node/_fs/_fs_appendFile_test.ts
diff options
context:
space:
mode:
authorAli Hasani <a.hassssani@gmail.com>2020-05-03 23:44:38 +0430
committerGitHub <noreply@github.com>2020-05-03 15:14:38 -0400
commit5cc0f056d1af6f76c6ad81a6cd68dcaabba60f35 (patch)
tree4a32cb418ca84aba47e05e6dc6c98e8ef724fcd0 /std/node/_fs/_fs_appendFile_test.ts
parent7e32269f3f230c5b714bbf70aa59d74f9a867373 (diff)
[std/node] add the ability to path argument to be URL type (#5055)
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() {