Skip to content

Commit

Permalink
fix: mock uuid in af user deletion test-cases & change place of mocking
Browse files Browse the repository at this point in the history
Signed-off-by: Sai Sankeerth <[email protected]>
  • Loading branch information
Sai Sankeerth committed Sep 25, 2023
1 parent 95b26fb commit 1b1a008
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
27 changes: 13 additions & 14 deletions test/integrations/component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions test/integrations/destinations/af/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
}),
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit 1b1a008

Please sign in to comment.