Skip to content

Commit

Permalink
add meta key to interpreted bid response (#5358)
Browse files Browse the repository at this point in the history
* add meta key to interpreted bid response

* add more unit tests

Co-authored-by: sumit sharma <sumit.sharma1@SYNPUNLT9114TFL.appnexus.com>
Co-authored-by: sumit sharma <sumit.sharma1@SYNPUNLT9114TFL.SYNAPPNXS.local>
  • Loading branch information
3 people authored Jun 16, 2020
1 parent 2f1793d commit d69d9db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/adapters/bidderFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ export function newBidder(spec) {
// creating a copy of original values as cpm and currency are modified later
bid.originalCpm = bid.cpm;
bid.originalCurrency = bid.currency;
bid.meta = bid.meta || Object.assign({}, bid[bidRequest.bidder]);
const prebidBid = Object.assign(createBid(CONSTANTS.STATUS.GOOD, bidRequest), bid);
addBidWithCode(bidRequest.adUnitCode, prebidBid);
} else {
Expand Down
10 changes: 8 additions & 2 deletions test/spec/unit/core/bidderFactory_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,12 @@ describe('bidders created by newBidder', function () {
adUnitCode: 'mock/placement',
currency: 'USD',
netRevenue: true,
ttl: 300
ttl: 300,
bidderCode: 'sampleBidder',
sampleBidder: {advertiserId: '12345', networkId: '111222'}
};
const bidderRequest = Object.assign({}, MOCK_BIDS_REQUEST);
bidderRequest.bids[0].bidder = 'sampleBidder';
spec.isBidRequestValid.returns(true);
spec.buildRequests.returns({
method: 'POST',
Expand All @@ -413,7 +417,7 @@ describe('bidders created by newBidder', function () {

spec.interpretResponse.returns(bid);

bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);
bidder.callBids(bidderRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);

expect(addBidResponseStub.calledOnce).to.equal(true);
expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement');
Expand All @@ -423,6 +427,8 @@ describe('bidders created by newBidder', function () {
expect(bidObject.originalCurrency).to.equal(bid.currency);
expect(doneStub.calledOnce).to.equal(true);
expect(logErrorSpy.callCount).to.equal(0);
expect(bidObject.meta).to.exist;
expect(bidObject.meta).to.deep.equal({advertiserId: '12345', networkId: '111222'});
});

it('should call spec.getUserSyncs() with the response', function () {
Expand Down

0 comments on commit d69d9db

Please sign in to comment.