summaryrefslogtreecommitdiff
path: root/cli/tests/unit_node/_fs/_fs_appendFile_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/unit_node/_fs/_fs_appendFile_test.ts')
-rw-r--r--cli/tests/unit_node/_fs/_fs_appendFile_test.ts20
1 files changed, 2 insertions, 18 deletions
diff --git a/cli/tests/unit_node/_fs/_fs_appendFile_test.ts b/cli/tests/unit_node/_fs/_fs_appendFile_test.ts
index 33c99414f..e70d3401f 100644
--- a/cli/tests/unit_node/_fs/_fs_appendFile_test.ts
+++ b/cli/tests/unit_node/_fs/_fs_appendFile_test.ts
@@ -97,7 +97,6 @@ Deno.test({
Deno.test({
name: "Async: Data is written to passed in file path",
async fn() {
- const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources();
await new Promise<void>((resolve, reject) => {
appendFile("_fs_appendFile_test_file.txt", "hello world", (err) => {
if (err) reject(err);
@@ -105,7 +104,6 @@ Deno.test({
});
})
.then(async () => {
- assertEquals(Deno.resources(), openResourcesBeforeAppend);
const data = await Deno.readFile("_fs_appendFile_test_file.txt");
assertEquals(decoder.decode(data), "hello world");
}, (err) => {
@@ -120,7 +118,6 @@ Deno.test({
Deno.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<void>((resolve, reject) => {
appendFile(fileURL, "hello world", (err) => {
@@ -129,7 +126,6 @@ Deno.test({
});
})
.then(async () => {
- assertEquals(Deno.resources(), openResourcesBeforeAppend);
const data = await Deno.readFile(fromFileUrl(fileURL));
assertEquals(decoder.decode(data), "hello world");
}, (err) => {
@@ -145,7 +141,6 @@ Deno.test({
name:
"Async: Callback is made with error if attempting to append data to an existing file with 'ax' flag",
async fn() {
- const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources();
const tempFile: string = await Deno.makeTempFile();
await new Promise<void>((resolve, reject) => {
appendFile(tempFile, "hello world", { flag: "ax" }, (err) => {
@@ -153,11 +148,8 @@ Deno.test({
else resolve();
});
})
- .then(() => {
- fail("Expected error to be thrown");
- }, () => {
- assertEquals(Deno.resources(), openResourcesBeforeAppend);
- })
+ .then(() => fail("Expected error to be thrown"))
+ .catch(() => {})
.finally(async () => {
await Deno.remove(tempFile);
});
@@ -184,9 +176,7 @@ Deno.test({
Deno.test({
name: "Sync: Data is written to passed in file path",
fn() {
- const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources();
appendFileSync("_fs_appendFile_test_file_sync.txt", "hello world");
- assertEquals(Deno.resources(), openResourcesBeforeAppend);
const data = Deno.readFileSync("_fs_appendFile_test_file_sync.txt");
assertEquals(decoder.decode(data), "hello world");
Deno.removeSync("_fs_appendFile_test_file_sync.txt");
@@ -197,14 +187,12 @@ Deno.test({
name:
"Sync: error thrown if attempting to append data to an existing file with 'ax' flag",
fn() {
- const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources();
const tempFile: string = Deno.makeTempFileSync();
assertThrows(
() => appendFileSync(tempFile, "hello world", { flag: "ax" }),
Error,
"",
);
- assertEquals(Deno.resources(), openResourcesBeforeAppend);
Deno.removeSync(tempFile);
},
});
@@ -212,10 +200,8 @@ Deno.test({
Deno.test({
name: "Sync: Data is written in Uint8Array to passed in file path",
fn() {
- const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources();
const testData = new TextEncoder().encode("hello world");
appendFileSync("_fs_appendFile_test_file_sync.txt", testData);
- assertEquals(Deno.resources(), openResourcesBeforeAppend);
const data = Deno.readFileSync("_fs_appendFile_test_file_sync.txt");
assertEquals(data, testData);
Deno.removeSync("_fs_appendFile_test_file_sync.txt");
@@ -225,7 +211,6 @@ Deno.test({
Deno.test({
name: "Async: Data is written in Uint8Array to passed in file path",
async fn() {
- const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources();
const testData = new TextEncoder().encode("hello world");
await new Promise<void>((resolve, reject) => {
appendFile("_fs_appendFile_test_file.txt", testData, (err) => {
@@ -234,7 +219,6 @@ Deno.test({
});
})
.then(async () => {
- assertEquals(Deno.resources(), openResourcesBeforeAppend);
const data = await Deno.readFile("_fs_appendFile_test_file.txt");
assertEquals(data, testData);
}, (err) => {