Skip to content

Commit

Permalink
GumGum: add default sizes (#5492)
Browse files Browse the repository at this point in the history
* uses encodeURIComponent inline

* adds test for jcsi param

* adds request delay depending on previous response

* adds inVideo param

* fixes video bug

* adds unit test
  • Loading branch information
susyt authored Jul 23, 2020
1 parent 9d85fde commit accd757
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
10 changes: 8 additions & 2 deletions modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,15 @@ function buildRequests (validBidRequests, bidderRequest) {
transactionId,
userId = {}
} = bidRequest;
const bannerSizes = mediaTypes.banner && mediaTypes.banner.sizes;
let sizes = [1, 1];
let data = {};

if (mediaTypes.banner) {
sizes = mediaTypes.banner.sizes;
} else if (mediaTypes.video) {
sizes = mediaTypes.video.playerSize;
}

if (pageViewId) {
data.pv = pageViewId;
}
Expand Down Expand Up @@ -278,7 +284,7 @@ function buildRequests (validBidRequests, bidderRequest) {
tId: transactionId,
pi: data.pi,
selector: params.selector,
sizes: bannerSizes,
sizes,
url: BID_ENDPOINT,
method: 'GET',
data: Object.assign(data, _getBrowserParams(topWindowUrl), _getDigiTrustQueryParams(userId), _getTradeDeskIDParam(userId))
Expand Down
36 changes: 20 additions & 16 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,24 @@ describe('gumgumAdapter', function () {
}
}
];
const vidMediaTypes = {
video: {
playerSize: [640, 480],
context: 'instream',
minduration: 1,
maxduration: 2,
linearity: 1,
startdelay: 1,
placement: 123456,
protocols: [1, 2]
}
};

it('should return a defined sizes field for video', function () {
const request = { ...bidRequests[0], mediaTypes: vidMediaTypes, params: { 'videoPubID': 123 } };
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.sizes).to.equal(vidMediaTypes.video.playerSize);
});

it('sends bid request to ENDPOINT via GET', function () {
const request = spec.buildRequests(bidRequests)[0];
Expand Down Expand Up @@ -145,21 +163,7 @@ describe('gumgumAdapter', function () {
expect(bidRequest.data).to.not.include.any.keys('t');
});
it('should send pubId if videoPubID param is specified', function () {
const mediaTypes = {
video: {
playerSize: [640, 480],
context: 'instream',
minduration: 1,
maxduration: 2,
linearity: 1,
startdelay: 1,
placement: 123456,
protocols: [1, 2]
}
};
const request = Object.assign({}, bidRequests[0]);
request.mediaTypes = mediaTypes
request.params = { 'videoPubID': 123 };
const request = { ...bidRequests[0], mediaTypes: vidMediaTypes, params: { 'videoPubID': 123 } };
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.data).to.include.any.keys('pubId');
expect(bidRequest.data.pubId).to.equal(request.params.videoPubID);
Expand Down Expand Up @@ -423,7 +427,7 @@ describe('gumgumAdapter', function () {
});

it('updates jcsi object when the server response jcsi prop is found', function () {
const response = Object.assign({cw: 'AD_JSON'}, serverResponse);
const response = Object.assign({ cw: 'AD_JSON' }, serverResponse);
const bidResponse = spec.interpretResponse({ body: response }, bidRequest)[0].ad;
const decodedResponse = JSON.parse(atob(bidResponse));
expect(decodedResponse.jcsi).to.eql(JCSI);
Expand Down

0 comments on commit accd757

Please sign in to comment.