From 1b1a008101612ae78704c6aad565a7283e1bf5f2 Mon Sep 17 00:00:00 2001 From: Sai Sankeerth Date: Mon, 25 Sep 2023 16:05:41 +0530 Subject: [PATCH] fix: mock uuid in af user deletion test-cases & change place of mocking Signed-off-by: Sai Sankeerth --- test/integrations/component.test.ts | 27 ++++++++++---------- test/integrations/destinations/af/network.ts | 4 +-- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/test/integrations/component.test.ts b/test/integrations/component.test.ts index 4e679589c4..dcfc821fbd 100644 --- a/test/integrations/component.test.ts +++ b/test/integrations/component.test.ts @@ -199,26 +199,25 @@ const sourceTestHandler = async (tcData) => { // Trigger the test suites describe.each(allTestDataFilePaths)('%s Tests', (testDataPath) => { // add special mocks for specific destinations - if (testDataPath.includes('yahoo_dsp')) { - // 21 September 2023 19:39:50 GMT+05:30 - Date.now = jest.fn(() => 1695305390000); - } const testData: TestCaseData[] = getTestData(testDataPath); test.each(testData)('$name - $module - $feature -> $description', async (tcData) => { + if (testDataPath.includes('yahoo_dsp')) { + // 21 September 2023 19:39:50 GMT+05:30 + Date.now = jest.fn(() => 1695305390000); + } if (tcData.feature === FEATURES.USER_DELETION && tcData.name === 'af') { - utils.generateUUID = jest.fn(() => '97fcd7b2-cc24-47d7-b776-057b7b199513'); jest.spyOn(Date.prototype, 'toISOString').mockReturnValue('2023-09-24T11:22:24.018Z'); } - if (tcData.name === 'optimizely_fullstack') { - jest.mock('../../src/v0/util/index', () => { - const originalModule = jest.requireActual('../../src/v0/util/index'); - return { - ...originalModule, - generateUUID: jest.fn(() => 'generated_uuid'), - }; - }); - } + jest.mock('../../src/v0/util/index', () => { + const originalModule = jest.requireActual('../../src/v0/util/index'); + return { + ...originalModule, + generateUUID: jest.fn().mockImplementation(() => { + return 'generated_uuid'; + }), + }; + }); switch (tcData.module) { case tags.MODULES.DESTINATION: diff --git a/test/integrations/destinations/af/network.ts b/test/integrations/destinations/af/network.ts index 00389b3fa6..42a355e72f 100644 --- a/test/integrations/destinations/af/network.ts +++ b/test/integrations/destinations/af/network.ts @@ -21,7 +21,7 @@ export const networkCallsData = [ }, ], property_id: 'AnAID', - subject_request_id: '97fcd7b2-cc24-47d7-b776-057b7b199513', + subject_request_id: 'generated_uuid', submitted_time: '2023-09-24T11:22:24.018Z', }, }), @@ -51,7 +51,7 @@ export const networkCallsData = [ ], status_callback_urls: ['https://examplecontroller.com/opengdpr_callbacks'], property_id: '123456789', - subject_request_id: '97fcd7b2-cc24-47d7-b776-057b7b199513', + subject_request_id: 'generated_uuid', submitted_time: '2023-09-24T11:22:24.018Z', }, headers: {