diff --git a/tests/main.ts b/tests/main.ts index c48acc04..7639655e 100644 --- a/tests/main.ts +++ b/tests/main.ts @@ -1,7 +1,7 @@ import { assert } from "https://deno.land/std@0.200.0/assert/mod.ts"; import { walk } from "https://deno.land/std@0.200.0/fs/walk.ts"; -const getFilesInDirectory = async (directory: string): Promise => { +async function getFilesInDirectory(directory: string): Promise { const files = []; for await (const walkEntry of walk(directory)) { @@ -14,7 +14,7 @@ const getFilesInDirectory = async (directory: string): Promise => { return files } -const getImportsInFile = async (file: string): Promise => { +async function getImportsInFile(file: string): Promise { const text = await Deno.readTextFile(file); const lines = text.split("\n") const imports = []; @@ -28,14 +28,18 @@ const getImportsInFile = async (file: string): Promise => { return imports } -Deno.test("imports all modules in ./packages", async () => { - const packageFiles = await getFilesInDirectory("./packages") - const packageImports = await getImportsInFile("./packages/default.nix") +async function assertAllModulesInDirectory(directory: string) { + const files = await getFilesInDirectory(`./${directory}`) + const imports = await getImportsInFile(`./${directory}/default.nix`) - console.log(packageFiles) - console.log(packageImports) + console.log(files) + console.log(imports) - for (const file of packageFiles) { - assert(packageImports.includes(file)) + for (const file of files) { + assert(imports.includes(file)) } +} + +Deno.test("imports all modules in ./packages", async () => { + await assertAllModulesInDirectory("packages") })