Skip to content

Commit

Permalink
Gumgum Bid Adapter: use nearest matching h/w dimensions from bid requ…
Browse files Browse the repository at this point in the history
…est (#7505)

* Gumgum: ADTS-157 use nearest matching h/w dimensions from bid request

* updated method calls from utils
  • Loading branch information
lbenmore authored Sep 30, 2021
1 parent 6d4daa4 commit 34c189d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
10 changes: 8 additions & 2 deletions modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { logError, logWarn, parseSizesInput, _each, deepAccess } from '../src/utils.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { _each, deepAccess, logError, logWarn, parseSizesInput } from '../src/utils.js';

import { config } from '../src/config.js'
import { getStorageManager } from '../src/storageManager.js';
import includes from 'core-js-pure/features/array/includes';
Expand Down Expand Up @@ -488,7 +489,12 @@ function interpretResponse(serverResponse, bidRequest) {
} else if (product === 5 && includes(sizes, '1x1')) {
sizes = ['1x1'];
} else if (product === 2 && includes(sizes, '1x1')) {
sizes = responseWidth && responseHeight ? [`${responseWidth}x${responseHeight}`] : parseSizesInput(bidRequest.sizes)
const requestSizesThatMatchResponse = (bidRequest.sizes && bidRequest.sizes.reduce((result, current) => {
const [ width, height ] = current;
if (responseWidth === width || responseHeight === height) result.push(current.join('x'));
return result
}, [])) || [];
sizes = requestSizesThatMatchResponse.length ? requestSizesThatMatchResponse : parseSizesInput(bidRequest.sizes)
}

let [width, height] = sizes[0].split('x');
Expand Down
23 changes: 18 additions & 5 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,11 +683,24 @@ describe('gumgumAdapter', function () {
expect(result[0].height).to.equal('1');
});

it('uses response width and height for inscreen product', function () {
const result = spec.interpretResponse({ body: serverResponse }, bidRequest)[0];
expect(result.width).to.equal(serverResponse.ad.width.toString());
expect(result.height).to.equal(serverResponse.ad.height.toString());
});
it('uses request size that nearest matches response size for in-screen', function () {
const request = { ...bidRequest };
const body = { ...serverResponse };
const expectedSize = [ 300, 50 ];
let result;

request.pi = 2;
request.sizes.unshift(expectedSize);

// typical ad server response values for in-screen
body.ad.width = 300;
body.ad.height = 100;

result = spec.interpretResponse({ body }, request)[0];

expect(result.width = expectedSize[0]);
expect(result.height = expectedSize[1]);
})

it('defaults to use bidRequest sizes', function () {
const { ad, jcsi, pag, thms, meta } = serverResponse
Expand Down

0 comments on commit 34c189d

Please sign in to comment.