Skip to content

Commit

Permalink
PAAPI: emit addComponentAuction event
Browse files Browse the repository at this point in the history
Component Auction Configs appear to be entirely contained within the
PAAPI + fledgeForGPT modules. This event provides a way to access
those configs from outside of those 2 modules.
  • Loading branch information
ETNOL committed Apr 15, 2024
1 parent 2fd1b74 commit 00c69c2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/adapters/bidderFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ export const registerSyncInner = hook('async', function(spec, responses, gdprCon
}, 'registerSyncs')

export const addComponentAuction = hook('sync', (request, fledgeAuctionConfig) => {
events.emit(CONSTANTS.EVENTS.ADD_COMPONENT_AUCTION, request, fledgeAuctionConfig);
}, 'addComponentAuction');

// check that the bid has a width and height set
Expand Down
3 changes: 2 additions & 1 deletion src/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"BID_VIEWABLE": "bidViewable",
"STALE_RENDER": "staleRender",
"BILLABLE_EVENT": "billableEvent",
"BID_ACCEPTED": "bidAccepted"
"BID_ACCEPTED": "bidAccepted",
"ADD_COMPONENT_AUCTION": "addComponentAuction"
},
"AD_RENDER_FAILED_REASON": {
"PREVENT_WRITING_ON_MAIN_DOCUMENT": "preventWritingOnMainDocument",
Expand Down
25 changes: 25 additions & 0 deletions test/spec/unit/core/bidderFactory_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1588,4 +1588,29 @@ describe('bidderFactory', () => {
});
})
});

describe('addComponentAuction', () => {
let requestStub
let fledgeAuctionConfigStub
let eventEmitterSpy

beforeEach(() => {
eventEmitterSpy = sinon.spy(events, 'emit');
requestStub = sinon.stub();
fledgeAuctionConfigStub = sinon.stub();
})

afterEach(() => {
eventEmitterSpy.restore();
})

it(`should emit an addComponentAuction event`, () => {
addComponentAuction(requestStub, fledgeAuctionConfigStub);
const eventCall = eventEmitterSpy.withArgs(CONSTANTS.EVENTS.ADD_COMPONENT_AUCTION).getCalls()[0];
const [event, request, fledgeAuctionConfig] = eventCall.args;
assert.equal(event, CONSTANTS.EVENTS.ADD_COMPONENT_AUCTION)
assert.equal(request, requestStub);
assert.equal(fledgeAuctionConfig, fledgeAuctionConfigStub);
})
});
})

0 comments on commit 00c69c2

Please sign in to comment.