mirror of
https://github.com/threeal/cmake-action.git
synced 2025-04-21 02:51:21 +00:00
Some checks are pending
Build / Build Package (push) Waiting to run
Check / Check Package (push) Waiting to run
Test / Test Package (push) Waiting to run
Test / Test Action (macos-14) (push) Waiting to run
Test / Test Action (ubuntu-24.04) (push) Waiting to run
Test / Test Action (windows-2022) (push) Waiting to run
Test / Test Action With Specified Directories (push) Waiting to run
Test / Test Action Without Run Build (push) Waiting to run
Test / Test Action With Additional Options (push) Waiting to run
Test / Test Action With Custom Generator (push) Waiting to run
* test: use Vitest for testing Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com> * build: remove `esModuleInterop` option in TypeScript configuration Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com> --------- Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>
30 lines
869 B
TypeScript
30 lines
869 B
TypeScript
import { logCommand } from "gha-utils";
|
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { exec } from "./exec.js";
|
|
|
|
describe("execute commands", () => {
|
|
vi.mock("gha-utils", () => ({
|
|
logCommand: vi.fn<(command: string, ...args: string[]) => void>(),
|
|
}));
|
|
|
|
beforeEach(() => {
|
|
vi.mocked(logCommand).mockClear();
|
|
});
|
|
|
|
it("should successfully execute a command", async () => {
|
|
await exec("node", ["--version"]);
|
|
|
|
expect(logCommand).toHaveBeenCalledTimes(1);
|
|
expect(logCommand).toHaveBeenCalledWith("node", "--version");
|
|
});
|
|
|
|
it("should fail to execute a command", async () => {
|
|
await expect(exec("node", ["--invalid"])).rejects.toThrow(
|
|
"Command exited with status code 9",
|
|
);
|
|
|
|
expect(logCommand).toHaveBeenCalledTimes(1);
|
|
expect(logCommand).toHaveBeenCalledWith("node", "--invalid");
|
|
});
|
|
});
|