Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
test(contact): drive the profile picture deadline with fake timers
Yudhi Armyndharis6e745bb9440b
diff --git a/src/modules/contact/contact.service.spec.ts b/src/modules/contact/contact.service.spec.tsindex 49ba94a87..61a565fee 100644--- a/src/modules/contact/contact.service.spec.ts+++ b/src/modules/contact/contact.service.spec.ts@@ -130,11 +130,15 @@ describe('ContactService', () => {.fn().mockResolvedValueOnce('https://pps/1.jpg').mockImplementationOnce(() => new Promise(() => undefined)); // never settles- const started = Date.now();- const out = await makeService({ getProfilePicture }).getProfilePictures('s1', ['[email protected]', '[email protected]']);- expect(out).toEqual({ '[email protected]': 'https://pps/1.jpg', '[email protected]': null });- expect(Date.now() - started).toBeLessThan(12_000);- }, 15_000);+ jest.useFakeTimers();+ try {+ const out = makeService({ getProfilePicture }).getProfilePictures('s1', ['[email protected]', '[email protected]']);+ await jest.advanceTimersByTimeAsync(8000);+ await expect(out).resolves.toEqual({ '[email protected]': 'https://pps/1.jpg', '[email protected]': null });+ } finally {+ jest.useRealTimers();+ }+ });describe('block/unblock reject ids that do not name a person', () => {// whatsapp-web.js's Contact.block()/unblock() return false for a group id (nothing blocked,