2020-01-20 04:33:14 +08:00
|
|
|
import { execute, stdout } from "../src/execute";
|
2020-01-19 03:41:49 +08:00
|
|
|
import { exec } from "@actions/exec";
|
2020-01-12 09:26:08 +08:00
|
|
|
|
2020-01-19 03:41:49 +08:00
|
|
|
jest.mock("@actions/exec", () => ({
|
2020-01-12 09:26:08 +08:00
|
|
|
exec: jest.fn()
|
2020-01-19 03:41:49 +08:00
|
|
|
}));
|
2020-01-12 09:26:08 +08:00
|
|
|
|
2020-01-19 03:41:49 +08:00
|
|
|
describe("execute", () => {
|
|
|
|
it("should be called with the correct arguments", async () => {
|
2020-01-20 04:33:14 +08:00
|
|
|
await stdout("hello");
|
2020-01-19 03:41:49 +08:00
|
|
|
await execute("echo Montezuma", "./");
|
|
|
|
|
|
|
|
expect(exec).toBeCalledWith("echo Montezuma", [], {
|
|
|
|
cwd: "./",
|
|
|
|
listeners: {
|
|
|
|
stdout: expect.any(Function)
|
|
|
|
}
|
2020-01-12 09:26:08 +08:00
|
|
|
});
|
2020-01-19 03:41:49 +08:00
|
|
|
});
|
|
|
|
});
|