


























@@ -106,17 +106,17 @@ describe("TwilioProvider", () => {
106106});
107107108108expect(result).toEqual({ providerCallId: "CA123", status: "queued" });
109-expect(apiRequest).toHaveBeenCalledWith(
110-"/Calls.json",
111-expect.objectContaining({
112-To: "+14155550123",
113-From: "+14155550100",
114-Twiml: "<Response><Say>Hello</Say></Response>",
115-StatusCallback: "https://example.ngrok.app/voice/webhook?callId=call-1&type=status",
116-StatusCallbackEvent: ["initiated", "ringing", "answered", "completed"],
117-}),
109+expect(apiRequest).toHaveBeenCalledTimes(1);
110+const [endpoint, params] = apiRequest.mock.calls[0] ?? [];
111+expect(endpoint).toBe("/Calls.json");
112+expect(params?.To).toBe("+14155550123");
113+expect(params?.From).toBe("+14155550100");
114+expect(params?.Twiml).toBe("<Response><Say>Hello</Say></Response>");
115+expect(params?.StatusCallback).toBe(
116+"https://example.ngrok.app/voice/webhook?callId=call-1&type=status",
118117);
119-expect(apiRequest.mock.calls[0]?.[1]).not.toHaveProperty("Url");
118+expect(params?.StatusCallbackEvent).toEqual(["initiated", "ringing", "answered", "completed"]);
119+expect(params).not.toHaveProperty("Url");
120120});
121121122122it("uses the webhook URL for conversation outbound calls", async () => {
@@ -135,14 +135,14 @@ describe("TwilioProvider", () => {
135135webhookUrl: "https://example.ngrok.app/voice/webhook",
136136});
137137138-expect(apiRequest).toHaveBeenCalledWith(
139- "/Calls.json",
140- expect.objectContaining({
141- Url: "https://example.ngrok.app/voice/webhook?callId=call-1",
142- StatusCallback: "https://example.ngrok.app/voice/webhook?callId=call-1&type=status",
143-}),
138+expect(apiRequest).toHaveBeenCalledTimes(1);
139+const [endpoint, params] = apiRequest.mock.calls[0] ?? [];
140+expect(endpoint).toBe("/Calls.json");
141+expect(params?.Url).toBe("https://example.ngrok.app/voice/webhook?callId=call-1");
142+expect(params?.StatusCallback).toBe(
143+"https://example.ngrok.app/voice/webhook?callId=call-1&type=status",
144144);
145-expect(apiRequest.mock.calls[0]?.[1]).not.toHaveProperty("Twiml");
145+expect(params).not.toHaveProperty("Twiml");
146146});
147147148148it("returns streaming TwiML for outbound conversation calls before in-progress", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。