@@ -15,6 +15,7 @@ function createWebhookContext(rawBody: string): WebhookContext {
|
15 | 15 | describe("MockProvider", () => { |
16 | 16 | it("preserves explicit falsy event values", () => { |
17 | 17 | const provider = new MockProvider(); |
| 18 | +const beforeParse = Date.now(); |
18 | 19 | const result = provider.parseWebhookEvent( |
19 | 20 | createWebhookContext( |
20 | 21 | JSON.stringify({ |
@@ -44,6 +45,9 @@ describe("MockProvider", () => {
|
44 | 45 | }), |
45 | 46 | ), |
46 | 47 | ); |
| 48 | +const afterParse = Date.now(); |
| 49 | +const endedTimestamp = result.events[1]?.timestamp; |
| 50 | +const speechTimestamp = result.events[2]?.timestamp; |
47 | 51 | |
48 | 52 | expect(result.events).toEqual([ |
49 | 53 | { |
@@ -60,19 +64,23 @@ describe("MockProvider", () => {
|
60 | 64 | type: "call.ended", |
61 | 65 | callId: "call-2", |
62 | 66 | providerCallId: undefined, |
63 | | -timestamp: expect.any(Number), |
| 67 | +timestamp: endedTimestamp, |
64 | 68 | reason: "", |
65 | 69 | }, |
66 | 70 | { |
67 | 71 | id: "evt-speech", |
68 | 72 | type: "call.speech", |
69 | 73 | callId: "call-3", |
70 | 74 | providerCallId: undefined, |
71 | | -timestamp: expect.any(Number), |
| 75 | +timestamp: speechTimestamp, |
72 | 76 | transcript: "", |
73 | 77 | isFinal: false, |
74 | 78 | confidence: undefined, |
75 | 79 | }, |
76 | 80 | ]); |
| 81 | +expect(endedTimestamp).toBeGreaterThanOrEqual(beforeParse); |
| 82 | +expect(endedTimestamp).toBeLessThanOrEqual(afterParse); |
| 83 | +expect(speechTimestamp).toBeGreaterThanOrEqual(beforeParse); |
| 84 | +expect(speechTimestamp).toBeLessThanOrEqual(afterParse); |
77 | 85 | }); |
78 | 86 | }); |