Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

test(call): cover CallService.createCallLink forwarding

Yudhi Armyndharise14dee3e21ac
diff --git a/src/modules/call/call.service.spec.ts b/src/modules/call/call.service.spec.ts
index 7974b941e..13cc56561 100644
--- a/src/modules/call/call.service.spec.ts
+++ b/src/modules/call/call.service.spec.ts
@@ -26,6 +26,19 @@ describe('CallService', () => {
expect(rejectCall).toHaveBeenCalledWith('CALL1');
});
+ it('delegates createCallLink to the engine with the type and epoch-ms startTime', async () => {
+ const createCallLink = jest.fn().mockResolvedValue('https://call.whatsapp.com/voice/L');
+ const svc = makeService({ createCallLink });
+ await expect(svc.createCallLink('s1', 'audio', 1_800_000_000_000)).resolves.toBe(
+ 'https://call.whatsapp.com/voice/L',
+ );
+ expect(createCallLink).toHaveBeenCalledWith('audio', 1_800_000_000_000);
+ });
+
+ it('guards createCallLink with the same 400 when the engine is missing', () => {
+ expect(() => makeService(undefined).createCallLink('s1', 'video', 1)).toThrow('Session is not started');
+ });
+
it('propagates the engine not-found error (unknown/expired call id -> 404)', async () => {
const rejectCall = jest.fn().mockRejectedValue(new CallNotFoundError('CALL1'));
const svc = makeService({ rejectCall });