mirror of
https://github.com/denoland/deno.git
synced 2025-09-29 05:34:49 +00:00
make camel case readDir, readLink, realPath (#4995)
This commit is contained in:
parent
78e0ae643c
commit
bc792c0267
17 changed files with 80 additions and 80 deletions
|
@ -14,15 +14,15 @@ function assertSameContent(files: Deno.DirEntry[]): void {
|
|||
assertEquals(counter, 1);
|
||||
}
|
||||
|
||||
unitTest({ perms: { read: true } }, function readdirSyncSuccess(): void {
|
||||
const files = [...Deno.readdirSync("cli/tests/")];
|
||||
unitTest({ perms: { read: true } }, function readDirSyncSuccess(): void {
|
||||
const files = [...Deno.readDirSync("cli/tests/")];
|
||||
assertSameContent(files);
|
||||
});
|
||||
|
||||
unitTest({ perms: { read: false } }, function readdirSyncPerm(): void {
|
||||
unitTest({ perms: { read: false } }, function readDirSyncPerm(): void {
|
||||
let caughtError = false;
|
||||
try {
|
||||
Deno.readdirSync("tests/");
|
||||
Deno.readDirSync("tests/");
|
||||
} catch (e) {
|
||||
caughtError = true;
|
||||
assert(e instanceof Deno.errors.PermissionDenied);
|
||||
|
@ -30,12 +30,12 @@ unitTest({ perms: { read: false } }, function readdirSyncPerm(): void {
|
|||
assert(caughtError);
|
||||
});
|
||||
|
||||
unitTest({ perms: { read: true } }, function readdirSyncNotDir(): void {
|
||||
unitTest({ perms: { read: true } }, function readDirSyncNotDir(): void {
|
||||
let caughtError = false;
|
||||
let src;
|
||||
|
||||
try {
|
||||
src = Deno.readdirSync("cli/tests/fixture.json");
|
||||
src = Deno.readDirSync("cli/tests/fixture.json");
|
||||
} catch (err) {
|
||||
caughtError = true;
|
||||
assert(err instanceof Error);
|
||||
|
@ -44,12 +44,12 @@ unitTest({ perms: { read: true } }, function readdirSyncNotDir(): void {
|
|||
assertEquals(src, undefined);
|
||||
});
|
||||
|
||||
unitTest({ perms: { read: true } }, function readdirSyncNotFound(): void {
|
||||
unitTest({ perms: { read: true } }, function readDirSyncNotFound(): void {
|
||||
let caughtError = false;
|
||||
let src;
|
||||
|
||||
try {
|
||||
src = Deno.readdirSync("bad_dir_name");
|
||||
src = Deno.readDirSync("bad_dir_name");
|
||||
} catch (err) {
|
||||
caughtError = true;
|
||||
assert(err instanceof Deno.errors.NotFound);
|
||||
|
@ -58,22 +58,22 @@ unitTest({ perms: { read: true } }, function readdirSyncNotFound(): void {
|
|||
assertEquals(src, undefined);
|
||||
});
|
||||
|
||||
unitTest({ perms: { read: true } }, async function readdirSuccess(): Promise<
|
||||
unitTest({ perms: { read: true } }, async function readDirSuccess(): Promise<
|
||||
void
|
||||
> {
|
||||
const files = [];
|
||||
for await (const dirEntry of Deno.readdir("cli/tests/")) {
|
||||
for await (const dirEntry of Deno.readDir("cli/tests/")) {
|
||||
files.push(dirEntry);
|
||||
}
|
||||
assertSameContent(files);
|
||||
});
|
||||
|
||||
unitTest({ perms: { read: false } }, async function readdirPerm(): Promise<
|
||||
unitTest({ perms: { read: false } }, async function readDirPerm(): Promise<
|
||||
void
|
||||
> {
|
||||
let caughtError = false;
|
||||
try {
|
||||
await Deno.readdir("tests/")[Symbol.asyncIterator]().next();
|
||||
await Deno.readDir("tests/")[Symbol.asyncIterator]().next();
|
||||
} catch (e) {
|
||||
caughtError = true;
|
||||
assert(e instanceof Deno.errors.PermissionDenied);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue