Skip to content

Commit

Permalink
fix: twitter_ads component test mocks
Browse files Browse the repository at this point in the history
Signed-off-by: Sai Sankeerth <[email protected]>
  • Loading branch information
Sai Sankeerth committed Apr 1, 2024
1 parent 1ad4e21 commit 309032e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/v0/destinations/twitter_ads/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { EventType } = require('../../../constants');
const { ConfigCategories, mappingConfig, BASE_URL } = require('./config');

const { JSON_MIME_TYPE } = require('../../util/constant');
const { getAuthHeaderForRequest } = require('./util');
const util = require('./util');

const getOAuthFields = ({ secret }) => {
if (!secret) {
Expand Down Expand Up @@ -46,7 +46,7 @@ function buildResponse(message, requestJson, metadata, endpointUrl) {
};

const oAuthObject = getOAuthFields(metadata);
const authHeader = getAuthHeaderForRequest(request, oAuthObject).Authorization;
const authHeader = util.getAuthHeaderForRequest(request, oAuthObject).Authorization;
response.headers = {
Authorization: authHeader,
'Content-Type': JSON_MIME_TYPE,
Expand Down
15 changes: 9 additions & 6 deletions test/integrations/destinations/twitter_ads/processor/data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import twUtil from '../../../../../src/v0/destinations/twitter_ads/util';
const authHeaderConstant =
'OAuth oauth_consumer_key="qwe", oauth_nonce="V1kMh028kZLLhfeYozuL0B45Pcx6LvuW", oauth_signature="Di4cuoGv4PnCMMEeqfWTcqhvdwc%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1685603652", oauth_token="dummyAccessToken", oauth_version="1.0"';

export const data = [
{
name: 'twitter_ads',
Expand Down Expand Up @@ -897,10 +897,13 @@ export const data = [
].map((tc) => ({
...tc,
mockFns: (_) => {
jest.mock('../../../../../src/v0/destinations/twitter_ads/util', () => ({
getAuthHeaderForRequest: (_a, _b) => {
return { Authorization: authHeaderConstant };
},
}));
jest
.spyOn(twUtil, 'getAuthHeaderForRequest')
.mockReturnValueOnce({ Authorization: authHeaderConstant });
// jest.mock('../../../../../src/v0/destinations/twitter_ads/util', () => ({
// getAuthHeaderForRequest: (_a, _b) => {
// return { Authorization: authHeaderConstant };
// },
// }));
},
}));

0 comments on commit 309032e

Please sign in to comment.