refactor(cli/tests): remove unnecessary void return types (#11577)

This commit is contained in:
Leo K 2021-08-05 13:08:58 +02:00 committed by GitHub
parent 299c7cfe54
commit 3f0cf9619f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
121 changed files with 1095 additions and 1177 deletions

View file

@ -8,7 +8,7 @@ import {
unitTest,
} from "./test_util.ts";
function assertSameContent(files: Deno.DirEntry[]): void {
function assertSameContent(files: Deno.DirEntry[]) {
let counter = 0;
for (const entry of files) {
@ -21,37 +21,35 @@ function assertSameContent(files: Deno.DirEntry[]): void {
assertEquals(counter, 1);
}
unitTest({ perms: { read: true } }, function readDirSyncSuccess(): void {
unitTest({ perms: { read: true } }, function readDirSyncSuccess() {
const files = [...Deno.readDirSync("cli/tests/")];
assertSameContent(files);
});
unitTest({ perms: { read: true } }, function readDirSyncWithUrl(): void {
unitTest({ perms: { read: true } }, function readDirSyncWithUrl() {
const files = [...Deno.readDirSync(pathToAbsoluteFileUrl("cli/tests"))];
assertSameContent(files);
});
unitTest({ perms: { read: false } }, function readDirSyncPerm(): void {
unitTest({ perms: { read: false } }, function readDirSyncPerm() {
assertThrows(() => {
Deno.readDirSync("tests/");
}, Deno.errors.PermissionDenied);
});
unitTest({ perms: { read: true } }, function readDirSyncNotDir(): void {
unitTest({ perms: { read: true } }, function readDirSyncNotDir() {
assertThrows(() => {
Deno.readDirSync("cli/tests/fixture.json");
}, Error);
});
unitTest({ perms: { read: true } }, function readDirSyncNotFound(): void {
unitTest({ perms: { read: true } }, function readDirSyncNotFound() {
assertThrows(() => {
Deno.readDirSync("bad_dir_name");
}, Deno.errors.NotFound);
});
unitTest({ perms: { read: true } }, async function readDirSuccess(): Promise<
void
> {
unitTest({ perms: { read: true } }, async function readDirSuccess() {
const files = [];
for await (const dirEntry of Deno.readDir("cli/tests/")) {
files.push(dirEntry);
@ -59,9 +57,7 @@ unitTest({ perms: { read: true } }, async function readDirSuccess(): Promise<
assertSameContent(files);
});
unitTest({ perms: { read: true } }, async function readDirWithUrl(): Promise<
void
> {
unitTest({ perms: { read: true } }, async function readDirWithUrl() {
const files = [];
for await (
const dirEntry of Deno.readDir(pathToAbsoluteFileUrl("cli/tests"))
@ -71,9 +67,7 @@ unitTest({ perms: { read: true } }, async function readDirWithUrl(): Promise<
assertSameContent(files);
});
unitTest({ perms: { read: false } }, async function readDirPerm(): Promise<
void
> {
unitTest({ perms: { read: false } }, async function readDirPerm() {
await assertThrowsAsync(async () => {
await Deno.readDir("tests/")[Symbol.asyncIterator]().next();
}, Deno.errors.PermissionDenied);
@ -92,7 +86,7 @@ unitTest(
unitTest(
{ perms: { read: true }, ignore: Deno.build.os == "windows" },
function readDirDevFdSync(): void {
function readDirDevFdSync() {
for (const _ of Deno.readDirSync("/dev/fd")) {
// We don't actually care whats in here; just that we don't panic on non regular file entries
}