mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 12:11:24 +00:00
test: dedupe and optimize test suites
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Command } from "commander";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { runRegisteredCli } from "../test-utils/command-runner.js";
|
||||
|
||||
const updateCommand = vi.fn(async (_opts: unknown) => {});
|
||||
const updateStatusCommand = vi.fn(async (_opts: unknown) => {});
|
||||
@@ -28,6 +29,12 @@ vi.mock("../runtime.js", () => ({
|
||||
}));
|
||||
|
||||
describe("update cli option collisions", () => {
|
||||
let registerUpdateCli: typeof import("./update-cli.js").registerUpdateCli;
|
||||
|
||||
beforeAll(async () => {
|
||||
({ registerUpdateCli } = await import("./update-cli.js"));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
updateCommand.mockClear();
|
||||
updateStatusCommand.mockClear();
|
||||
@@ -38,11 +45,10 @@ describe("update cli option collisions", () => {
|
||||
});
|
||||
|
||||
it("forwards parent-captured --json/--timeout to `update status`", async () => {
|
||||
const { registerUpdateCli } = await import("./update-cli.js");
|
||||
const program = new Command();
|
||||
registerUpdateCli(program);
|
||||
|
||||
await program.parseAsync(["update", "status", "--json", "--timeout", "9"], { from: "user" });
|
||||
await runRegisteredCli({
|
||||
register: registerUpdateCli as (program: Command) => void,
|
||||
argv: ["update", "status", "--json", "--timeout", "9"],
|
||||
});
|
||||
|
||||
expect(updateStatusCommand).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
@@ -53,11 +59,10 @@ describe("update cli option collisions", () => {
|
||||
});
|
||||
|
||||
it("forwards parent-captured --timeout to `update wizard`", async () => {
|
||||
const { registerUpdateCli } = await import("./update-cli.js");
|
||||
const program = new Command();
|
||||
registerUpdateCli(program);
|
||||
|
||||
await program.parseAsync(["update", "wizard", "--timeout", "13"], { from: "user" });
|
||||
await runRegisteredCli({
|
||||
register: registerUpdateCli as (program: Command) => void,
|
||||
argv: ["update", "wizard", "--timeout", "13"],
|
||||
});
|
||||
|
||||
expect(updateWizardCommand).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
|
||||
Reference in New Issue
Block a user