Add unit test
This commit is contained in:
parent
6a39521a07
commit
a214d1cb86
2 changed files with 34 additions and 0 deletions
6
deps.testing.ts
Normal file
6
deps.testing.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
export {
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
mockfn,
|
||||
} from "https://js.thunderk.net/testing@1.0.0/mod.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",
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue