Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nextMillenniumBidAdapter: Added support imp.video.pos and imp.banner.pos #12606

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions modules/nextMillenniumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {config} from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {getRefererInfo} from '../src/refererDetection.js';

const NM_VERSION = '4.2.1';
const NM_VERSION = '4.3.0';
const PBJS_VERSION = 'v$prebid.version$';
const GVLID = 1060;
const BIDDER_CODE = 'nextMillennium';
Expand Down Expand Up @@ -308,13 +308,15 @@ export function getImpBanner(imp, banner) {
if (banner.bidfloorcur) imp.bidfloorcur = banner.bidfloorcur;
if (banner.bidfloor) imp.bidfloor = banner.bidfloor;

const format = (banner.data?.sizes || []).map(s => { return {w: s[0], h: s[1]} })
const format = (banner.data?.sizes || []).map(s => { return {w: s[0], h: s[1]} });
const {w, h} = (format[0] || {})
imp.banner = {
w,
h,
format,
};

setImpPos(imp.banner, banner?.pos);
};

export function getImpVideo(imp, video) {
Expand All @@ -336,6 +338,12 @@ export function getImpVideo(imp, video) {
imp.video.w = video.data.w;
imp.video.h = video.data.h;
};

setImpPos(imp.video, video?.pos);
};

export function setImpPos(obj, pos) {
if (typeof pos === 'number' && pos >= 0 && pos <= 7) obj.pos = pos;
};

export function setConsentStrings(postBody = {}, bidderRequest) {
Expand Down
40 changes: 39 additions & 1 deletion test/spec/modules/nextMillenniumBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect } from 'chai';
import {
getImp,
setImpPos,
getSourceObj,
replaceUsersyncMacros,
setConsentStrings,
Expand Down Expand Up @@ -28,6 +29,7 @@ describe('nextMillenniumBidAdapterTests', () => {
data: {sizes: [[300, 250], [320, 250]]},
bidfloorcur: 'EUR',
bidfloor: 1.11,
pos: 3,
},
},
},
Expand All @@ -37,7 +39,12 @@ describe('nextMillenniumBidAdapterTests', () => {
bidfloorcur: 'EUR',
bidfloor: 1.11,
ext: {prebid: {storedrequest: {id: '123'}}},
banner: {w: 300, h: 250, format: [{w: 300, h: 250}, {w: 320, h: 250}]},
banner: {
pos: 3,
w: 300,
h: 250,
format: [{w: 300, h: 250}, {w: 320, h: 250}],
},
},
},

Expand All @@ -56,6 +63,7 @@ describe('nextMillenniumBidAdapterTests', () => {
video: {
data: {playerSize: [400, 300], api: [2], placement: 1, plcmt: 1},
bidfloorcur: 'USD',
pos: 0,
},
},
},
Expand All @@ -71,6 +79,7 @@ describe('nextMillenniumBidAdapterTests', () => {
plcmt: 1,
w: 400,
h: 300,
pos: 0,
},
},
},
Expand Down Expand Up @@ -177,6 +186,35 @@ describe('nextMillenniumBidAdapterTests', () => {
}
});

describe('function setImpPos', () => {
const tests = [
{
title: 'position is - 1',
pos: 0,
expected: {pos: 0},
},

{
title: 'position is - 2',
pos: 7,
expected: {pos: 7},
},

{
title: 'position is empty',
expected: {},
},
];

for (const {title, pos, expected} of tests) {
it(title, () => {
const obj = {};
setImpPos(obj, pos);
expect(obj).to.deep.equal(expected);
});
};
});

describe('function getSourceObj', () => {
const dataTests = [
{
Expand Down
Loading