mirror of https://github.com/openclaw/openclaw.git
test(core): trim redundant test resets and use mockClear
This commit is contained in:
parent
e893157600
commit
d6d73d0ed9
|
|
@ -30,7 +30,7 @@ describe("subscribeEmbeddedPiSession", () => {
|
|||
const firstPayload = onPartialReply.mock.calls[0][0];
|
||||
expect(firstPayload.text).toBe("Hi there");
|
||||
|
||||
onPartialReply.mockReset();
|
||||
onPartialReply.mockClear();
|
||||
|
||||
emit({ type: "message_start", message: { role: "assistant" } });
|
||||
emitAssistantTextDelta({ emit, delta: "</final>Oops no start" });
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import { stageSandboxMedia } from "./reply/stage-sandbox-media.js";
|
|||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
childProcessMocks.spawn.mockReset();
|
||||
childProcessMocks.spawn.mockClear();
|
||||
});
|
||||
|
||||
describe("stageSandboxMedia", () => {
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ const { handleInlineActions } = await import("./get-reply-inline-actions.js");
|
|||
|
||||
describe("handleInlineActions", () => {
|
||||
it("skips whatsapp replies when config is empty and From !== To", async () => {
|
||||
handleCommandsMock.mockReset();
|
||||
|
||||
const typing: TypingController = {
|
||||
onReplyStart: async () => {},
|
||||
startTypingLoop: async () => {},
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ describe("noteSessionLockHealth", () => {
|
|||
let envSnapshot: ReturnType<typeof captureEnv>;
|
||||
|
||||
beforeEach(async () => {
|
||||
note.mockReset();
|
||||
note.mockClear();
|
||||
envSnapshot = captureEnv(["OPENCLAW_STATE_DIR"]);
|
||||
root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-doctor-locks-"));
|
||||
process.env.OPENCLAW_STATE_DIR = root;
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ describe("doctor state integrity oauth dir checks", () => {
|
|||
process.env.OPENCLAW_STATE_DIR = path.join(tempHome, ".openclaw");
|
||||
delete process.env.OPENCLAW_OAUTH_DIR;
|
||||
fs.mkdirSync(process.env.OPENCLAW_STATE_DIR, { recursive: true, mode: 0o700 });
|
||||
vi.mocked(note).mockReset();
|
||||
vi.mocked(note).mockClear();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ vi.mock("../infra/channel-activity.js", async (importOriginal) => {
|
|||
|
||||
describe("sendWebhookMessageDiscord activity", () => {
|
||||
beforeEach(() => {
|
||||
recordChannelActivityMock.mockReset();
|
||||
recordChannelActivityMock.mockClear();
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn(async () => {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ describe("ensureGatewayStartupAuth", () => {
|
|||
|
||||
beforeEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
mocks.writeConfigFile.mockReset();
|
||||
mocks.writeConfigFile.mockClear();
|
||||
});
|
||||
|
||||
async function expectNoTokenGeneration(cfg: OpenClawConfig, mode: string) {
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ describe("imessage targets", () => {
|
|||
|
||||
describe("createIMessageRpcClient", () => {
|
||||
beforeEach(() => {
|
||||
spawnMock.mockReset();
|
||||
spawnMock.mockClear();
|
||||
vi.stubEnv("VITEST", "true");
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ describe("ports helpers", () => {
|
|||
|
||||
describeUnix("inspectPortUsage", () => {
|
||||
beforeEach(() => {
|
||||
runCommandWithTimeoutMock.mockReset();
|
||||
runCommandWithTimeoutMock.mockClear();
|
||||
});
|
||||
|
||||
it("reports busy when lsof is missing but loopback listener exists", async () => {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ afterEach(() => {
|
|||
envSnapshot.restore();
|
||||
process.argv = [...originalArgv];
|
||||
process.execArgv = [...originalExecArgv];
|
||||
spawnMock.mockReset();
|
||||
spawnMock.mockClear();
|
||||
});
|
||||
|
||||
function clearSupervisorHints() {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ let probeLineBot: typeof import("./probe.js").probeLineBot;
|
|||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
getBotInfoMock.mockReset();
|
||||
getBotInfoMock.mockClear();
|
||||
});
|
||||
|
||||
describe("probeLineBot", () => {
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ function setRegistry(entries: MockRegistryToolEntry[]) {
|
|||
|
||||
describe("resolvePluginTools optional tools", () => {
|
||||
beforeEach(() => {
|
||||
loadOpenClawPluginsMock.mockReset();
|
||||
loadOpenClawPluginsMock.mockClear();
|
||||
});
|
||||
|
||||
it("skips optional tools without explicit allowlist", () => {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ describe("killProcessTree", () => {
|
|||
let killSpy: ReturnType<typeof vi.spyOn>;
|
||||
|
||||
beforeEach(() => {
|
||||
spawnMock.mockReset();
|
||||
spawnMock.mockClear();
|
||||
killSpy = vi.spyOn(process, "kill");
|
||||
vi.useFakeTimers();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ describe("process supervisor PTY command contract", () => {
|
|||
});
|
||||
|
||||
beforeEach(() => {
|
||||
createPtyAdapterMock.mockReset();
|
||||
createPtyAdapterMock.mockClear();
|
||||
});
|
||||
|
||||
it("passes PTY command verbatim to shell args", async () => {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ vi.mock("../logging/subsystem.js", () => ({
|
|||
|
||||
describe("resolveTelegramAccount", () => {
|
||||
afterEach(() => {
|
||||
warnMock.mockReset();
|
||||
warnMock.mockClear();
|
||||
});
|
||||
|
||||
it("falls back to the first configured account when accountId is omitted", () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue