21 lines
542 B
TypeScript
21 lines
542 B
TypeScript
import { Sys } from "./deno.ts";
|
|
import { describe, expect, it, mock } from "../deps.testing.ts";
|
|
|
|
describe("Sys", () => {
|
|
it("is mockable", () => {
|
|
function runSomething() {
|
|
Sys.run({ cmd: ["echo", "test"] });
|
|
}
|
|
|
|
expect(runSomething).toThrow(
|
|
'Requires run access to "echo", run again with the --allow-run flag',
|
|
);
|
|
|
|
mock(Sys, "run", undefined, (run) => {
|
|
runSomething();
|
|
expect(run).toHaveBeenCalledTimes(1);
|
|
expect(run).toHaveBeenCalledWith({ cmd: ["echo", "test"] });
|
|
});
|
|
});
|
|
});
|