From 279fff714aed1a4b41960d04300ff75feae9fd30 Mon Sep 17 00:00:00 2001 From: Meisam Seyed Aliroteh Date: Thu, 30 May 2024 10:53:13 -0700 Subject: [PATCH] chore: address nit --- test/unit/common/CommonUtils.test.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/unit/common/CommonUtils.test.ts b/test/unit/common/CommonUtils.test.ts index 072a017..5a5b9cc 100644 --- a/test/unit/common/CommonUtils.test.ts +++ b/test/unit/common/CommonUtils.test.ts @@ -363,16 +363,15 @@ describe('CommonUtils', () => { } async function verifyDownloadFails(url: string, mockResponse: any) { + const fake = (options: any, callback: (res: http.IncomingMessage) => void) => { + setTimeout(() => callback(mockResponse), 100); + return { on: () => {}, end: () => {} }; + }; + if (url.startsWith('https:')) { - httpsGetStub.callsFake((_, callback) => { - setTimeout(() => callback(mockResponse), 100); - return { on: () => {}, end: () => {} }; - }); + httpsGetStub.callsFake(fake); } else { - httpGetStub.callsFake((_, callback) => { - setTimeout(() => callback(mockResponse), 100); - return { on: () => {}, end: () => {} }; - }); + httpGetStub.callsFake(fake); } try {