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

TL-18466: add GVLid, update multiimp validation, add unit tests #9

Merged
merged 3 commits into from
Oct 28, 2020
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
7 changes: 2 additions & 5 deletions modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@ import { registerBidder } from '../src/adapters/bidderFactory.js';
import * as utils from '../src/utils.js';
import { config } from '../src/config.js';

const GVLID = 28;
const BIDDER_CODE = 'triplelift';
const STR_ENDPOINT = 'https://tlx.3lift.com/header/auction?';
let gdprApplies = true;
let consentString = null;

export const tripleliftAdapterSpec = {

gvlid: GVLID,
code: BIDDER_CODE,
supportedMediaTypes: [BANNER, VIDEO],
isBidRequestValid: function (bid) {
if (bid.mediaTypes.video) {
let video = _getORTBVideo(bid);
if (!video.w || !video.h) return false;
}
return typeof bid.params.inventoryCode !== 'undefined';
},

Expand Down
167 changes: 162 additions & 5 deletions test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,21 @@ describe('triplelift adapter', function () {
expect(tripleliftAdapterSpec.isBidRequestValid(instreamBid)).to.equal(true);
});

it('should return true when required params found - instream - 2', function () {
colbertk marked this conversation as resolved.
Show resolved Hide resolved
delete instreamBid.mediaTypes.playerSize;
delete instreamBid.params.video.w;
delete instreamBid.params.video.h;
// the only required param is inventoryCode
expect(tripleliftAdapterSpec.isBidRequestValid(instreamBid)).to.equal(true);
});

it('should return false when required params are not passed', function () {
delete bid.params.inventoryCode;
expect(tripleliftAdapterSpec.isBidRequestValid(bid)).to.equal(false);
});

it('should return false when required params are not passed - instream', function () {
delete instreamBid.mediaTypes.playerSize;
delete instreamBid.params.video.w;
delete instreamBid.params.video.h;
delete instreamBid.params.inventoryCode;
expect(tripleliftAdapterSpec.isBidRequestValid(instreamBid)).to.equal(false);
});
});
Expand Down Expand Up @@ -165,6 +171,7 @@ describe('triplelift adapter', function () {
userId: {},
schain,
},
// banner and outstream video
{
bidder: 'triplelift',
params: {
Expand Down Expand Up @@ -197,6 +204,140 @@ describe('triplelift adapter', function () {
auctionId: '1d1a030790a475',
userId: {},
schain,
},
// banner and incomplete video
{
bidder: 'triplelift',
params: {
inventoryCode: 'outstream_test',
floor: 1.0,
video: {
mimes: ['video/mp4'],
maxduration: 30,
minduration: 6,
w: 640,
h: 480
}
},
mediaTypes: {
video: {

},
banner: {
sizes: [
[970, 250],
[1, 1]
]
}
},
adUnitCode: 'adunit-code-instream',
sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']],
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
userId: {},
schain,
},
// incomplete banner and incomplete video
{
bidder: 'triplelift',
params: {
inventoryCode: 'outstream_test',
floor: 1.0,
video: {
mimes: ['video/mp4'],
maxduration: 30,
minduration: 6,
w: 640,
h: 480
}
},
mediaTypes: {
video: {

},
banner: {

}
},
adUnitCode: 'adunit-code-instream',
sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']],
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
userId: {},
schain,
},
// banner and instream video
{
bidder: 'triplelift',
params: {
inventoryCode: 'outstream_test',
floor: 1.0,
video: {
mimes: ['video/mp4'],
maxduration: 30,
minduration: 6,
w: 640,
h: 480
}
},
mediaTypes: {
video: {
context: 'instream',
playerSize: [640, 480]
},
banner: {
sizes: [
[970, 250],
[1, 1]
]
}
},
adUnitCode: 'adunit-code-instream',
sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']],
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
userId: {},
schain,
},
// banner and outream video and native
{
bidder: 'triplelift',
params: {
inventoryCode: 'outstream_test',
floor: 1.0,
video: {
mimes: ['video/mp4'],
maxduration: 30,
minduration: 6,
w: 640,
h: 480
}
},
mediaTypes: {
video: {
context: 'outstream',
playerSize: [640, 480]
},
banner: {
sizes: [
[970, 250],
[1, 1]
]
},
native: {

}
},
adUnitCode: 'adunit-code-instream',
sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']],
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
userId: {},
schain,
}
];

Expand Down Expand Up @@ -261,10 +402,26 @@ describe('triplelift adapter', function () {
expect(payload.imp[1].tagid).to.equal('insteam_test');
expect(payload.imp[1].floor).to.equal(1.0);
expect(payload.imp[1].video).to.exist.and.to.be.a('object');

// banner and outstream video
expect(payload.imp[2]).to.not.have.property('video');
expect(payload.imp[2]).to.have.property('banner');
expect(payload.imp[2].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]);
// banner and incomplete video
expect(payload.imp[3]).to.not.have.property('video');
expect(payload.imp[3]).to.have.property('banner');
expect(payload.imp[3].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]);
// incomplete mediatypes.banner and incomplete video
expect(payload.imp[4]).to.not.have.property('video');
expect(payload.imp[4]).to.have.property('banner');
expect(payload.imp[4].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]);
// banner and instream video
expect(payload.imp[5]).to.not.have.property('banner');
expect(payload.imp[5]).to.have.property('video');
expect(payload.imp[5].video).to.exist.and.to.be.a('object');
// banner and outream video and native
expect(payload.imp[6]).to.not.have.property('video');
expect(payload.imp[6]).to.have.property('banner');
expect(payload.imp[6].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]);
});

it('should add tdid to the payload if included', function () {
Expand Down Expand Up @@ -587,7 +744,7 @@ describe('triplelift adapter', function () {

it('should include the advertiser name in the meta field if available', function () {
let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest});
expect(result[0].meta.advertiserName).to.equal('fake advertiser name')
expect(result[0].meta.advertiserName).to.equal('fake advertiser name');
expect(result[1].meta).to.not.have.key('advertiserName');
});
});
Expand Down