@@ -36,6 +36,16 @@ vi.mock("../../plugins/hook-runner-global.js", () => ({
|
36 | 36 | |
37 | 37 | const { emitResetCommandHooks } = await import("./commands-reset-hooks.js"); |
38 | 38 | |
| 39 | +function firstBeforeResetCall() { |
| 40 | +const call = hookRunnerMocks.runBeforeReset.mock.calls[0] as |
| 41 | +| [Record<string, unknown>, Record<string, unknown>] |
| 42 | +| undefined; |
| 43 | +if (!call) { |
| 44 | +throw new Error("expected before reset hook call"); |
| 45 | +} |
| 46 | +return call; |
| 47 | +} |
| 48 | + |
39 | 49 | describe("emitResetCommandHooks", () => { |
40 | 50 | async function runBeforeResetContext(sessionKey?: string) { |
41 | 51 | const command = { |
@@ -60,7 +70,7 @@ describe("emitResetCommandHooks", () => {
|
60 | 70 | }); |
61 | 71 | |
62 | 72 | expect(hookRunnerMocks.runBeforeReset).toHaveBeenCalledTimes(1); |
63 | | -const [, ctx] = hookRunnerMocks.runBeforeReset.mock.calls.at(0) ?? []; |
| 73 | +const [, ctx] = firstBeforeResetCall(); |
64 | 74 | return ctx; |
65 | 75 | } |
66 | 76 | |
@@ -136,10 +146,7 @@ describe("emitResetCommandHooks", () => {
|
136 | 146 | }); |
137 | 147 | |
138 | 148 | await vi.waitFor(() => expect(hookRunnerMocks.runBeforeReset).toHaveBeenCalledTimes(1)); |
139 | | -const [event, ctx] = hookRunnerMocks.runBeforeReset.mock.calls.at(0) as unknown as [ |
140 | | -Record<string, unknown>, |
141 | | -Record<string, unknown>, |
142 | | -]; |
| 149 | +const [event, ctx] = firstBeforeResetCall(); |
143 | 150 | expect(event.sessionFile).toBe("/tmp/prev-session.jsonl.reset.2026-02-16T22-26-33.000Z"); |
144 | 151 | expect(event.messages).toEqual([{ role: "user", content: "Recovered from archive" }]); |
145 | 152 | expect(event.reason).toBe("new"); |
|