Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tej656 committed Jul 30, 2024
1 parent 208b501 commit 4c0b581
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
7 changes: 3 additions & 4 deletions modules/pubxaiAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ const analyticsType = 'endpoint';
const adapterCode = 'pubxai';
const pubxaiAnalyticsVersion = 'v2.0.0';
const defaultHost = 'api.pbxai.com';
const auctionPath = '/analytics/auction';
const winningBidPath = '/analytics/bidwon';
const storage = getStorageManager({ moduleType: MODULE_TYPE_ANALYTICS, moduleName: adapterCode })

/**
Expand Down Expand Up @@ -236,9 +234,10 @@ const prepareSend = (auctionId) => {
if (!shouldFireEventRequest(auctionId, initOptions.samplingRate)) {
return;
}
const pubxID = initOptions.pubxId;
[
{
path: winningBidPath,
path: `/analytics/${pubxID}/bidwon`,
requiredKeys: [
'winningBid',
'pageDetail',
Expand All @@ -253,7 +252,7 @@ const prepareSend = (auctionId) => {
eventType: 'win',
},
{
path: auctionPath,
path: `/analytics/${pubxID}/auction`,
requiredKeys: [
'bids',
'pageDetail',
Expand Down
17 changes: 9 additions & 8 deletions test/spec/modules/pubxaiAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ describe('pubxai analytics adapter', () => {
});

describe('track', () => {
const pubxId = '6c415fc0-8b0e-4cf5-be73-01526a4db625'
let initOptions = {
samplingRate: '1',
pubxId: '6c415fc0-8b0e-4cf5-be73-01526a4db625',
pubxId: pubxId,
};

let originalVS;
Expand Down Expand Up @@ -148,7 +149,7 @@ describe('pubxai analytics adapter', () => {
timeout: 1000,
config: {
samplingRate: '1',
pubxId: '6c415fc0-8b0e-4cf5-be73-01526a4db625',
pubxId: pubxId,
},
},
bidRequested: {
Expand Down Expand Up @@ -529,7 +530,7 @@ describe('pubxai analytics adapter', () => {
null,
auctionId: 'bc3806e4-873e-453c-8ae5-204f35e923b4',
sizes: '300x250',
renderStatus: 2,
bidType: 2,
requestTimestamp: 1616654312804,
creativeId: 96846035,
currency: 'USD',
Expand Down Expand Up @@ -651,7 +652,7 @@ describe('pubxai analytics adapter', () => {
placementId: 13144370,
renderedSize: '300x250',
sizes: '300x250',
renderStatus: 4,
bidType: 4,
responseTimestamp: 1616654313071,
requestTimestamp: 1616654312804,
status: 'rendered',
Expand Down Expand Up @@ -758,7 +759,7 @@ describe('pubxai analytics adapter', () => {
const [expectedUrl, expectedData] = arg;
const parsedUrl = new URL(expectedUrl);
expect(parsedUrl.pathname).to.equal(
['/analytics/bidwon', '/analytics/auction'][index]
[`/analytics/${pubxId}/bidwon`, `/analytics/${pubxId}/auction`][index]
);
expect(Object.fromEntries(parsedUrl.searchParams)).to.deep.equal({
auctionTimestamp: '1616654312804',
Expand Down Expand Up @@ -800,7 +801,7 @@ describe('pubxai analytics adapter', () => {
// Step 7: check the pathname of the calls is correct (sent only to the auction endpoint)
const [expectedUrl, expectedData] = navigator.sendBeacon.args[0];
const parsedUrl = new URL(expectedUrl);
expect(parsedUrl.pathname).to.equal('/analytics/auction');
expect(parsedUrl.pathname).to.equal(`/analytics/${pubxId}/auction`);

// Step 8: check that the meta information in the call is correct
expect(Object.fromEntries(parsedUrl.searchParams)).to.deep.equal({
Expand Down Expand Up @@ -926,7 +927,7 @@ describe('pubxai analytics adapter', () => {
const parsedUrl = new URL(expectedUrl);
const auctionIdMapFn = index < 2 ? (i, _) => i : replaceProperty;
expect(parsedUrl.pathname).to.equal(
['/analytics/bidwon', '/analytics/auction'][index % 2]
[`/analytics/${pubxId}/bidwon`, `/analytics/${pubxId}/auction`][index % 2]
);
expect(Object.fromEntries(parsedUrl.searchParams)).to.deep.equal({
auctionTimestamp: '1616654312804',
Expand Down Expand Up @@ -1042,7 +1043,7 @@ describe('pubxai analytics adapter', () => {
const [expectedUrl, expectedData] = arg;
const parsedUrl = new URL(expectedUrl);
expect(parsedUrl.pathname).to.equal(
['/analytics/bidwon', '/analytics/auction'][index]
[`/analytics/${pubxId}/bidwon`, `/analytics/${pubxId}/auction`][index]
);
expect(Object.fromEntries(parsedUrl.searchParams)).to.deep.equal({
auctionTimestamp: '1616654312804',
Expand Down

0 comments on commit 4c0b581

Please sign in to comment.