summaryrefslogtreecommitdiff
path: root/js/write_file_test.ts
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-03-06 20:48:46 -0500
committerGitHub <noreply@github.com>2019-03-06 20:48:46 -0500
commitc42a9d737081fb8ee768c7178dae0e1f19c0f343 (patch)
tree9ffb7e502da62793ea099c34bd7b29c8a7a19b19 /js/write_file_test.ts
parentde1a10e5f7afe793a66b2349642ea135fc066104 (diff)
Upgrade deno_std (#1892)
A major API change was that asserts are imported from testing/asserts.ts now rather than testing/mod.ts and assertEqual as renamed to assertEquals to conform to what is most common in JavaScript.
Diffstat (limited to 'js/write_file_test.ts')
-rw-r--r--js/write_file_test.ts54
1 files changed, 27 insertions, 27 deletions
diff --git a/js/write_file_test.ts b/js/write_file_test.ts
index 67419a7f6..07f8dca7a 100644
--- a/js/write_file_test.ts
+++ b/js/write_file_test.ts
@@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import { testPerm, assert, assertEqual } from "./test_util.ts";
+import { testPerm, assert, assertEquals } from "./test_util.ts";
testPerm({ read: true, write: true }, function writeFileSyncSuccess() {
const enc = new TextEncoder();
@@ -9,7 +9,7 @@ testPerm({ read: true, write: true }, function writeFileSyncSuccess() {
const dataRead = Deno.readFileSync(filename);
const dec = new TextDecoder("utf-8");
const actual = dec.decode(dataRead);
- assertEqual("Hello", actual);
+ assertEquals("Hello", actual);
});
testPerm({ write: true }, function writeFileSyncFail() {
@@ -22,8 +22,8 @@ testPerm({ write: true }, function writeFileSyncFail() {
Deno.writeFileSync(filename, data);
} catch (e) {
caughtError = true;
- assertEqual(e.kind, Deno.ErrorKind.NotFound);
- assertEqual(e.name, "NotFound");
+ assertEquals(e.kind, Deno.ErrorKind.NotFound);
+ assertEquals(e.name, "NotFound");
}
assert(caughtError);
});
@@ -38,8 +38,8 @@ testPerm({ write: false }, function writeFileSyncPerm() {
Deno.writeFileSync(filename, data);
} catch (e) {
caughtError = true;
- assertEqual(e.kind, Deno.ErrorKind.PermissionDenied);
- assertEqual(e.name, "PermissionDenied");
+ assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
+ assertEquals(e.name, "PermissionDenied");
}
assert(caughtError);
});
@@ -50,9 +50,9 @@ testPerm({ read: true, write: true }, function writeFileSyncUpdatePerm() {
const data = enc.encode("Hello");
const filename = Deno.makeTempDirSync() + "/test.txt";
Deno.writeFileSync(filename, data, { perm: 0o755 });
- assertEqual(Deno.statSync(filename).mode & 0o777, 0o755);
+ assertEquals(Deno.statSync(filename).mode & 0o777, 0o755);
Deno.writeFileSync(filename, data, { perm: 0o666 });
- assertEqual(Deno.statSync(filename).mode & 0o777, 0o666);
+ assertEquals(Deno.statSync(filename).mode & 0o777, 0o666);
}
});
@@ -66,8 +66,8 @@ testPerm({ read: true, write: true }, function writeFileSyncCreate() {
Deno.writeFileSync(filename, data, { create: false });
} catch (e) {
caughtError = true;
- assertEqual(e.kind, Deno.ErrorKind.NotFound);
- assertEqual(e.name, "NotFound");
+ assertEquals(e.kind, Deno.ErrorKind.NotFound);
+ assertEquals(e.name, "NotFound");
}
assert(caughtError);
@@ -77,7 +77,7 @@ testPerm({ read: true, write: true }, function writeFileSyncCreate() {
const dataRead = Deno.readFileSync(filename);
const dec = new TextDecoder("utf-8");
const actual = dec.decode(dataRead);
- assertEqual("Hello", actual);
+ assertEquals("Hello", actual);
});
testPerm({ read: true, write: true }, function writeFileSyncAppend() {
@@ -89,17 +89,17 @@ testPerm({ read: true, write: true }, function writeFileSyncAppend() {
let dataRead = Deno.readFileSync(filename);
const dec = new TextDecoder("utf-8");
let actual = dec.decode(dataRead);
- assertEqual("HelloHello", actual);
+ assertEquals("HelloHello", actual);
// Now attempt overwrite
Deno.writeFileSync(filename, data, { append: false });
dataRead = Deno.readFileSync(filename);
actual = dec.decode(dataRead);
- assertEqual("Hello", actual);
+ assertEquals("Hello", actual);
// append not set should also overwrite
Deno.writeFileSync(filename, data);
dataRead = Deno.readFileSync(filename);
actual = dec.decode(dataRead);
- assertEqual("Hello", actual);
+ assertEquals("Hello", actual);
});
testPerm({ read: true, write: true }, async function writeFileSuccess() {
@@ -110,7 +110,7 @@ testPerm({ read: true, write: true }, async function writeFileSuccess() {
const dataRead = Deno.readFileSync(filename);
const dec = new TextDecoder("utf-8");
const actual = dec.decode(dataRead);
- assertEqual("Hello", actual);
+ assertEquals("Hello", actual);
});
testPerm({ read: true, write: true }, async function writeFileNotFound() {
@@ -123,8 +123,8 @@ testPerm({ read: true, write: true }, async function writeFileNotFound() {
await Deno.writeFile(filename, data);
} catch (e) {
caughtError = true;
- assertEqual(e.kind, Deno.ErrorKind.NotFound);
- assertEqual(e.name, "NotFound");
+ assertEquals(e.kind, Deno.ErrorKind.NotFound);
+ assertEquals(e.name, "NotFound");
}
assert(caughtError);
});
@@ -139,8 +139,8 @@ testPerm({ read: true, write: false }, async function writeFilePerm() {
await Deno.writeFile(filename, data);
} catch (e) {
caughtError = true;
- assertEqual(e.kind, Deno.ErrorKind.PermissionDenied);
- assertEqual(e.name, "PermissionDenied");
+ assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
+ assertEquals(e.name, "PermissionDenied");
}
assert(caughtError);
});
@@ -151,9 +151,9 @@ testPerm({ read: true, write: true }, async function writeFileUpdatePerm() {
const data = enc.encode("Hello");
const filename = Deno.makeTempDirSync() + "/test.txt";
await Deno.writeFile(filename, data, { perm: 0o755 });
- assertEqual(Deno.statSync(filename).mode & 0o777, 0o755);
+ assertEquals(Deno.statSync(filename).mode & 0o777, 0o755);
await Deno.writeFile(filename, data, { perm: 0o666 });
- assertEqual(Deno.statSync(filename).mode & 0o777, 0o666);
+ assertEquals(Deno.statSync(filename).mode & 0o777, 0o666);
}
});
@@ -167,8 +167,8 @@ testPerm({ read: true, write: true }, async function writeFileCreate() {
await Deno.writeFile(filename, data, { create: false });
} catch (e) {
caughtError = true;
- assertEqual(e.kind, Deno.ErrorKind.NotFound);
- assertEqual(e.name, "NotFound");
+ assertEquals(e.kind, Deno.ErrorKind.NotFound);
+ assertEquals(e.name, "NotFound");
}
assert(caughtError);
@@ -178,7 +178,7 @@ testPerm({ read: true, write: true }, async function writeFileCreate() {
const dataRead = Deno.readFileSync(filename);
const dec = new TextDecoder("utf-8");
const actual = dec.decode(dataRead);
- assertEqual("Hello", actual);
+ assertEquals("Hello", actual);
});
testPerm({ read: true, write: true }, async function writeFileAppend() {
@@ -190,15 +190,15 @@ testPerm({ read: true, write: true }, async function writeFileAppend() {
let dataRead = Deno.readFileSync(filename);
const dec = new TextDecoder("utf-8");
let actual = dec.decode(dataRead);
- assertEqual("HelloHello", actual);
+ assertEquals("HelloHello", actual);
// Now attempt overwrite
await Deno.writeFile(filename, data, { append: false });
dataRead = Deno.readFileSync(filename);
actual = dec.decode(dataRead);
- assertEqual("Hello", actual);
+ assertEquals("Hello", actual);
// append not set should also overwrite
await Deno.writeFile(filename, data);
dataRead = Deno.readFileSync(filename);
actual = dec.decode(dataRead);
- assertEqual("Hello", actual);
+ assertEquals("Hello", actual);
});