diff --git a/deps.testing.ts b/deps.testing.ts new file mode 100644 index 0000000..878ad92 --- /dev/null +++ b/deps.testing.ts @@ -0,0 +1,6 @@ +export { + describe, + expect, + it, + mockfn, +} from "https://js.thunderk.net/testing@1.0.0/mod.ts"; diff --git a/src/normalize.test.ts b/src/normalize.test.ts index e69de29..0734bff 100644 --- a/src/normalize.test.ts +++ b/src/normalize.test.ts @@ -0,0 +1,28 @@ +import { ProjectNormalizer } from "./normalize.ts"; +import { describe, expect, it, mockfn } from "../deps.testing.ts"; + +describe(ProjectNormalizer, () => { + it("uses 'deno fmt' to format path", async () => { + const sys = { + run: mockfn(() => ({ + async status() { + return { success: true }; + }, + async output() { + return new TextEncoder().encode(""); + }, + async stderrOutput() { + return new TextEncoder().encode(""); + }, + })), + } as typeof Deno; + const normalizer = new ProjectNormalizer(sys); + await normalizer.formatPath("dist/test.js"); + expect(sys.run).toHaveBeenCalledTimes(1); + expect(sys.run).toHaveBeenCalledWith({ + cmd: ["./run", "fmt", "-q", "dist/test.js"], + stdout: "piped", + stderr: "piped", + }); + }); +});