diff --git a/modules/iasBidAdapter.js b/modules/iasBidAdapter.js index 61ba909527a..7e5be05c856 100644 --- a/modules/iasBidAdapter.js +++ b/modules/iasBidAdapter.js @@ -3,6 +3,8 @@ import { registerBidder } from 'src/adapters/bidderFactory'; const BIDDER_CODE = 'ias'; +const otherBidIds = []; + function isBidRequestValid(bid) { const { pubId, adUnitPath } = bid.params; return !!(pubId && adUnitPath); @@ -37,11 +39,11 @@ function stringifySlot(bidRequest) { } function stringifyWindowSize() { - return [window.innerWidth || -1, window.innerHeight || -1].join('.'); + return [ window.innerWidth || -1, window.innerHeight || -1 ].join('.'); } function stringifyScreenSize() { - return [(window.screen && window.screen.width) || -1, (window.screen && window.screen.height) || -1].join('.'); + return [ (window.screen && window.screen.width) || -1, (window.screen && window.screen.height) || -1 ].join('.'); } function buildRequests(bidRequests) { @@ -60,12 +62,18 @@ function buildRequests(bidRequests) { const queryString = encodeURI(queries.map(qs => qs.join('=')).join('&')); + bidRequests.forEach(function (request) { + if (bidRequests[0].bidId != request.bidId) { + otherBidIds.push(request.bidId); + } + }); + return { method: 'GET', url: IAS_HOST, data: queryString, bidRequest: bidRequests[0] - } + }; } function getPageLevelKeywords(response) { @@ -103,6 +111,13 @@ function interpretResponse(serverResponse, request) { shallowMerge(commonBidResponse, getPageLevelKeywords(iasResponse)); commonBidResponse.slots = iasResponse.slots; bidResponses.push(commonBidResponse); + + otherBidIds.forEach(function (bidId) { + var otherResponse = Object.assign({}, commonBidResponse); + otherResponse.requestId = bidId; + bidResponses.push(otherResponse); + }); + return bidResponses; } diff --git a/test/spec/modules/iasBidAdapter_spec.js b/test/spec/modules/iasBidAdapter_spec.js index 4f335ab22ba..1ee38999f7f 100644 --- a/test/spec/modules/iasBidAdapter_spec.js +++ b/test/spec/modules/iasBidAdapter_spec.js @@ -89,6 +89,9 @@ describe('iasBidAdapter is an adapter that', () => { url: IAS_HOST }); }); + it('only includes the first `bidRequest` as the bidRequest variable on a multiple slot request', () => { + expect(spec.buildRequests(bidRequests).bidRequest.adUnitCode).to.equal(bidRequests[0].adUnitCode); + }); describe('has property `data` that is an encode query string containing information such as', () => { let val; const ANID_PARAM = 'anId'; @@ -124,8 +127,41 @@ describe('iasBidAdapter is an adapter that', () => { expect(spec.interpretResponse).to.be.a('function'); }); describe('returns a list of bid response that', () => { - let bidResponse, slots; + let bidRequests, bidResponse, slots, serverResponse; beforeEach(() => { + bidRequests = [ + { + adUnitCode: 'one-div-id', + auctionId: 'someAuctionId', + bidId: 'someBidId1', + bidder: 'ias', + bidderRequestId: 'someBidderRequestId', + params: { + pubId: '1234', + adUnitPath: '/a/b/c' + }, + sizes: [ + [10, 20], + [300, 400] + ], + transactionId: 'someTransactionId' + }, + { + adUnitCode: 'two-div-id', + auctionId: 'someAuctionId', + bidId: 'someBidId2', + bidder: 'ias', + bidderRequestId: 'someBidderRequestId', + params: { + pubId: '1234', + adUnitPath: '/d/e/f' + }, + sizes: [ + [50, 60] + ], + transactionId: 'someTransactionId' + } + ]; const request = { bidRequest: { bidId: '102938' @@ -140,7 +176,7 @@ describe('iasBidAdapter is an adapter that', () => { id: '5678', vw: ['80', '90'] }; - const serverResponse = { + serverResponse = { body: { brandSafety: { adt: 'adtVal', @@ -185,6 +221,11 @@ describe('iasBidAdapter is an adapter that', () => { it('has property `slots`', () => { expect(bidResponse[0]).to.deep.include({ slots: slots }); }); + it('response is the same for multiple slots', () => { + var adapter = spec; + var requests = adapter.buildRequests(bidRequests); + expect(adapter.interpretResponse(serverResponse, requests)).to.length(2); + }); }); }); });