Skip to content
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
14 changes: 7 additions & 7 deletions modules/showheroes-bsBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { Renderer } from '../src/Renderer.js';
import { ortbConverter } from '../libraries/ortbConverter/converter.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { VIDEO } from '../src/mediaTypes.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';

const ENDPOINT = 'https://ads.viralize.tv/openrtb2/auction/';
const BIDDER_CODE = 'showheroes-bs';
Expand All @@ -19,12 +19,13 @@ const converter = ortbConverter({
netRevenue: true,
ttl: TTL,
currency: 'EUR',
mediaType: VIDEO,
},
imp(buildImp, bidRequest, context) {
const imp = buildImp(bidRequest, context);
const videoContext = deepAccess(bidRequest, 'mediaTypes.video.context');
deepSetValue(imp, 'video.ext.context', videoContext);
if (videoContext) {
deepSetValue(imp, 'video.ext.context', videoContext);
}
imp.ext = imp.ext || {};
imp.ext.params = bidRequest.params;
imp.ext.adUnitCode = bidRequest.adUnitCode;
Expand Down Expand Up @@ -75,14 +76,14 @@ export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
aliases: ['showheroesBs'],
supportedMediaTypes: [VIDEO],
supportedMediaTypes: [VIDEO, BANNER],
isBidRequestValid: (bid) => {
return !!bid.params.unitId;
},
buildRequests: (bidRequests, bidderRequest) => {
const QA = bidRequests[0].params.qa;

const ortbData = converter.toORTB({ bidRequests, bidderRequest })
const ortbData = converter.toORTB({ bidRequests, bidderRequest });

return {
url: QA?.endpoint || ENDPOINT,
Expand All @@ -95,8 +96,7 @@ export const spec = {
return [];
}

const bids = converter.fromORTB({response: response.body, request: request.data}).bids;
return bids;
return converter.fromORTB({response: response.body, request: request.data}).bids;
},
getUserSyncs: (syncOptions, serverResponses) => {
const syncs = [];
Expand Down
72 changes: 72 additions & 0 deletions test/spec/modules/showheroes-bsBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect } from 'chai'
import { spec } from 'modules/showheroes-bsBidAdapter.js'
import { addFPDToBidderRequest } from '../../helpers/fpd.js';
import { getGlobal } from '../../../src/prebidGlobal.js';
import 'modules/priceFloors.js';
import 'modules/consentManagementTcf.js';
import 'modules/consentManagementUsp.js';
Expand Down Expand Up @@ -78,7 +79,25 @@ const bidRequestOutstreamV2 = {
}
}

const bidRequestBannerV2 = {
...bidRequestCommonParamsV2,
...{
mediaTypes: {
banner: {
sizes: [[300, 250]],
}
}
}
}

describe('shBidAdapter', () => {
before(() => {
// without this change in the Renderer.js file exception is thrown
// because 'adUnits' is undefined, and there is a call that does
// 'pbjs.adUnits.find' in the Renderer.js file
getGlobal().adUnits = [];
});

it('validates request', () => {
const bid = {
params: {
Expand Down Expand Up @@ -139,6 +158,7 @@ describe('shBidAdapter', () => {
adm: vastXml,
impid: '38b373e1e31c18',
crid: 'c_38b373e1e31c18',
mtype: 2, // 2 = video
adomain: adomain,
ext: {
callbacks: {
Expand Down Expand Up @@ -249,6 +269,58 @@ describe('shBidAdapter', () => {
expect(bid.vastUrl).to.eql(vastUrl);
})
}

it('should get correct bid response when type is banner', function () {
const request = spec.buildRequests([bidRequestBannerV2], bidderRequest);
const bannerResponse = {
cur: 'EUR',
seatbid: [{
bid: [{
price: 1,
w: 300,
h: 250,
adm: '<div>test banner</div>',
impid: '38b373e1e31c18',
crid: 'c_38b373e1e31c18',
mtype: 1, // 1 = banner
adomain: adomain,
ext: {
callbacks: {
won: [callback_won],
},
extra: 'test',
},
}],
seat: 'showheroes',
}]
};

const expectedResponse = [
{
cpm: 1,
creativeId: 'c_38b373e1e31c18',
creative_id: 'c_38b373e1e31c18',
currency: 'EUR',
width: 300,
height: 250,
mediaType: 'banner',
netRevenue: true,
requestId: '38b373e1e31c18',
ttl: 300,
meta: {
advertiserDomains: adomain,
},
ad: '<div>test banner</div>',
callbacks: {
won: [callback_won],
},
extra: 'test',
}
];

const result = spec.interpretResponse({ 'body': bannerResponse }, request);
expect(result).to.deep.equal(expectedResponse);
})
});

describe('getUserSyncs', function () {
Expand Down