






















@@ -18,6 +18,21 @@ vi.mock("./client.js", () => ({
18181919describe("createCommentTypingReactionLifecycle", () => {
2020const request = vi.fn();
21+const commentReactionUrl =
22+"/open-apis/drive/v2/files/doc_token_1/comments/reaction?file_type=docx";
23+24+function expectedTypingReactionRequest(action: "add" | "delete") {
25+return {
26+method: "POST",
27+url: commentReactionUrl,
28+data: {
29+ action,
30+reply_id: "reply_1",
31+reaction_type: "Typing",
32+},
33+timeout: 30_000,
34+};
35+}
21362237afterAll(() => {
2338vi.doUnmock("./accounts.js");
@@ -71,30 +86,8 @@ describe("createCommentTypingReactionLifecycle", () => {
7186await lifecycle.start();
7287await lifecycle.cleanup();
738874-expect(request).toHaveBeenNthCalledWith(
75-1,
76-expect.objectContaining({
77-method: "POST",
78-url: "/open-apis/drive/v2/files/doc_token_1/comments/reaction?file_type=docx",
79-data: {
80-action: "add",
81-reply_id: "reply_1",
82-reaction_type: "Typing",
83-},
84-}),
85-);
86-expect(request).toHaveBeenNthCalledWith(
87-2,
88-expect.objectContaining({
89-method: "POST",
90-url: "/open-apis/drive/v2/files/doc_token_1/comments/reaction?file_type=docx",
91-data: {
92-action: "delete",
93-reply_id: "reply_1",
94-reaction_type: "Typing",
95-},
96-}),
97-);
89+expect(request).toHaveBeenNthCalledWith(1, expectedTypingReactionRequest("add"));
90+expect(request).toHaveBeenNthCalledWith(2, expectedTypingReactionRequest("delete"));
9891});
999210093it("skips requests when reply_id is missing", async () => {
@@ -114,16 +107,7 @@ describe("createCommentTypingReactionLifecycle", () => {
114107await lifecycle.cleanup();
115108116109expect(request).toHaveBeenCalledTimes(2);
117-expect(request).toHaveBeenNthCalledWith(
118-2,
119-expect.objectContaining({
120-data: {
121-action: "delete",
122-reply_id: "reply_1",
123-reaction_type: "Typing",
124-},
125-}),
126-);
110+expect(request).toHaveBeenNthCalledWith(2, expectedTypingReactionRequest("delete"));
127111});
128112129113it("retries delete during later cleanup after an ambient delete failure", async () => {
@@ -148,25 +132,7 @@ describe("createCommentTypingReactionLifecycle", () => {
148132await lifecycle.cleanup();
149133150134expect(request).toHaveBeenCalledTimes(3);
151-expect(request).toHaveBeenNthCalledWith(
152-2,
153-expect.objectContaining({
154-data: {
155-action: "delete",
156-reply_id: "reply_1",
157-reaction_type: "Typing",
158-},
159-}),
160-);
161-expect(request).toHaveBeenNthCalledWith(
162-3,
163-expect.objectContaining({
164-data: {
165-action: "delete",
166-reply_id: "reply_1",
167-reaction_type: "Typing",
168-},
169-}),
170-);
135+expect(request).toHaveBeenNthCalledWith(2, expectedTypingReactionRequest("delete"));
136+expect(request).toHaveBeenNthCalledWith(3, expectedTypingReactionRequest("delete"));
171137});
172138});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。