



















@@ -79,19 +79,21 @@ describe("Feishu bot menu handler", () => {
79798080await onBotMenu(createBotMenuEvent({ eventKey: "quick-actions", timestamp: "1700000000000" }));
818182-expect(sendCardFeishuMock).toHaveBeenCalledWith(
83-expect.objectContaining({
84-to: "user:ou_user1",
85-card: expect.objectContaining({
86-config: expect.objectContaining({
87-width_mode: "fill",
88-}),
89-header: expect.objectContaining({
90-title: expect.objectContaining({ content: "Quick actions" }),
91-}),
92-}),
93-}),
94-);
82+expect(sendCardFeishuMock).toHaveBeenCalledTimes(1);
83+const sendArgs = sendCardFeishuMock.mock.calls[0]?.[0] as
84+| {
85+accountId?: string;
86+card?: {
87+config?: { width_mode?: string };
88+header?: { title?: { content?: string } };
89+};
90+to?: string;
91+}
92+| undefined;
93+expect(sendArgs?.to).toBe("user:ou_user1");
94+expect(sendArgs?.accountId).toBe("default");
95+expect(sendArgs?.card?.config?.width_mode).toBe("fill");
96+expect(sendArgs?.card?.header?.title?.content).toBe("Quick actions");
9597expect(handleFeishuMessageMock).not.toHaveBeenCalled();
9698});
9799@@ -126,15 +128,11 @@ describe("Feishu bot menu handler", () => {
126128127129await onBotMenu(createBotMenuEvent({ eventKey: "custom-key", timestamp: "1700000000002" }));
128130129-expect(handleFeishuMessageMock).toHaveBeenCalledWith(
130-expect.objectContaining({
131-event: expect.objectContaining({
132-message: expect.objectContaining({
133-content: '{"text":"/menu custom-key"}',
134-}),
135-}),
136-}),
137-);
131+expect(handleFeishuMessageMock).toHaveBeenCalledTimes(1);
132+const handleArgs = handleFeishuMessageMock.mock.calls[0]?.[0] as
133+| { event?: { message?: { content?: string } } }
134+| undefined;
135+expect(handleArgs?.event?.message?.content).toBe('{"text":"/menu custom-key"}');
138136expect(sendCardFeishuMock).not.toHaveBeenCalled();
139137});
140138@@ -145,16 +143,12 @@ describe("Feishu bot menu handler", () => {
145143await onBotMenu(createBotMenuEvent({ eventKey: "quick-actions", timestamp: "1700000000003" }));
146144147145await vi.waitFor(() => {
148-expect(handleFeishuMessageMock).toHaveBeenCalledWith(
149-expect.objectContaining({
150-event: expect.objectContaining({
151-message: expect.objectContaining({
152-content: '{"text":"/menu quick-actions"}',
153-}),
154-}),
155-}),
156-);
146+expect(handleFeishuMessageMock).toHaveBeenCalledTimes(1);
157147});
148+const handleArgs = handleFeishuMessageMock.mock.calls[0]?.[0] as
149+| { event?: { message?: { content?: string } } }
150+| undefined;
151+expect(handleArgs?.event?.message?.content).toBe('{"text":"/menu quick-actions"}');
158152expectFirstSentCardUsesFillWidthOnly(sendCardFeishuMock);
159153});
160154此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。