

























@@ -68,6 +68,24 @@ async function loadGetReplyRuntimeForTest() {
6868({ runPreparedReply: runPreparedReplyMock } = await import("./get-reply-run.js"));
6969}
707071+function requirePreparedReplyParams() {
72+const preparedReplyParams = vi.mocked(runPreparedReplyMock).mock.calls[0]?.[0];
73+if (!preparedReplyParams) {
74+throw new Error("expected prepared reply params");
75+}
76+return preparedReplyParams;
77+}
78+79+function requireDirectiveParams() {
80+const directiveParams = mocks.resolveReplyDirectives.mock.calls[0]?.[0] as
81+| { sessionKey?: string; workspaceDir?: string }
82+| undefined;
83+if (!directiveParams) {
84+throw new Error("expected directive params");
85+}
86+return directiveParams;
87+}
88+7189describe("getReplyFromConfig fast test bootstrap", () => {
7290beforeAll(async () => {
7391await loadGetReplyRuntimeForTest();
@@ -133,10 +151,7 @@ describe("getReplyFromConfig fast test bootstrap", () => {
133151expect(mocks.initSessionState).not.toHaveBeenCalled();
134152expect(mocks.resolveReplyDirectives).not.toHaveBeenCalled();
135153expect(vi.mocked(runPreparedReplyMock)).toHaveBeenCalledOnce();
136-const preparedReplyParams = vi.mocked(runPreparedReplyMock).mock.calls.at(0)?.[0];
137-if (!preparedReplyParams) {
138-throw new Error("expected prepared reply params");
139-}
154+const preparedReplyParams = requirePreparedReplyParams();
140155expect(preparedReplyParams.cfg).toBe(cfg);
141156});
142157@@ -443,12 +458,7 @@ describe("getReplyFromConfig fast test bootstrap", () => {
443458expect(mocks.initSessionState).not.toHaveBeenCalled();
444459expect(vi.mocked(runPreparedReplyMock)).not.toHaveBeenCalled();
445460expect(mocks.resolveReplyDirectives).toHaveBeenCalledOnce();
446-const directiveParams = mocks.resolveReplyDirectives.mock.calls.at(0)?.[0] as
447-| { sessionKey?: string; workspaceDir?: string }
448-| undefined;
449-if (!directiveParams) {
450-throw new Error("expected directive params");
451-}
461+const directiveParams = requireDirectiveParams();
452462expect(directiveParams.sessionKey).toBe(targetSessionKey);
453463expect(directiveParams.workspaceDir).toBe("/tmp/workspace");
454464});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。