Skip to content

Commit

Permalink
check if video features are enabled for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipStamenkovic committed Sep 30, 2024
1 parent 489d117 commit 54a8fc1
Showing 1 changed file with 81 additions and 79 deletions.
160 changes: 81 additions & 79 deletions test/spec/modules/showheroes-bsBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,101 +147,103 @@ describe('shBidAdapter', () => {
}
const vastUrl = 'https://test.com/vast/?zid=AACBWAcof-611K4U&u=https://example.org/?foo=bar&gdpr=0&cs=XXXXXXXXXXXXXXXXXXXX&sid=01ecd03ce381505ccdeb88e555b05001&width=300&height=200&prebidmode=1'

it('should get correct bid response when type is video (V2)', function () {
const request = spec.buildRequests([bidRequestVideoV2], bidderRequest)
const expectedResponse = [
{
cpm: 1,
creativeId: 'c_38b373e1e31c18',
creative_id: 'c_38b373e1e31c18',
currency: 'EUR',
width: 640,
height: 480,
playerHeight: 480,
playerWidth: 640,
mediaType: 'video',
netRevenue: true,
requestId: '38b373e1e31c18',
ttl: 300,
meta: {
advertiserDomains: adomain
},
vastXml: vastXml,
callbacks: {
won: [callback_won],
},
extra: 'test',
}
]
if (FEATURES.VIDEO) {
it('should get correct bid response when type is video (V2)', function () {
const request = spec.buildRequests([bidRequestVideoV2], bidderRequest)
const expectedResponse = [
{
cpm: 1,
creativeId: 'c_38b373e1e31c18',
creative_id: 'c_38b373e1e31c18',
currency: 'EUR',
width: 640,
height: 480,
playerHeight: 480,
playerWidth: 640,
mediaType: 'video',
netRevenue: true,
requestId: '38b373e1e31c18',
ttl: 300,
meta: {
advertiserDomains: adomain
},
vastXml: vastXml,
callbacks: {
won: [callback_won],
},
extra: 'test',
}
]

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

it('should get correct bid response when type is outstream (slot V2)', function () {
window.myRenderer = {
renderAd: function() {
return null;
}
}
const bidRequestV2 = JSON.parse(JSON.stringify(bidRequestOutstreamV2));
const bidResponse = JSON.parse(JSON.stringify(basicResponse));
bidResponse.seatbid[0].bid[0].ext.rendererConfig = {
rendererUrl: 'https://test.com/render.js',
renderFunc: 'myRenderer.renderAd',
renderOptions: {
key: 'my renderer custom value',
it('should get correct bid response when type is outstream (slot V2)', function () {
window.myRenderer = {
renderAd: function() {
return null;
}
}
};
const slotId = 'testSlot2'
const bidRequestV2 = JSON.parse(JSON.stringify(bidRequestOutstreamV2));
const bidResponse = JSON.parse(JSON.stringify(basicResponse));
bidResponse.seatbid[0].bid[0].ext.rendererConfig = {
rendererUrl: 'https://test.com/render.js',
renderFunc: 'myRenderer.renderAd',
renderOptions: {
key: 'my renderer custom value',
}
};
const slotId = 'testSlot2'

const container = document.createElement('div')
container.setAttribute('id', slotId)
document.body.appendChild(container)
const container = document.createElement('div')
container.setAttribute('id', slotId)
document.body.appendChild(container)

const request = spec.buildRequests([bidRequestV2], bidderRequest)
const request = spec.buildRequests([bidRequestV2], bidderRequest)

const result = spec.interpretResponse({ 'body': bidResponse }, request)
const bid = result[0]
expect(bid).to.have.property('mediaType', VIDEO);
expect(typeof bid.renderer).to.be.eql('object');
expect(bid.renderer.url).to.eql('https://test.com/render.js');
const result = spec.interpretResponse({ 'body': bidResponse }, request)
const bid = result[0]
expect(bid).to.have.property('mediaType', VIDEO);
expect(typeof bid.renderer).to.be.eql('object');
expect(bid.renderer.url).to.eql('https://test.com/render.js');

sinon.spy(window.myRenderer, 'renderAd');
bid.renderer.render(bid);
sinon.spy(window.myRenderer, 'renderAd');
bid.renderer.render(bid);

const renderCall = window.myRenderer.renderAd.getCall(0);
const renderPayload = renderCall.args[0];
expect(renderPayload.adResponse.content).to.eql(vastXml);
expect(renderPayload.key).to.eql('my renderer custom value');
})
const renderCall = window.myRenderer.renderAd.getCall(0);
const renderPayload = renderCall.args[0];
expect(renderPayload.adResponse.content).to.eql(vastXml);
expect(renderPayload.key).to.eql('my renderer custom value');
})

it('should get correct bid response when type is outstream (customRender)', function () {
const bidRequest = JSON.parse(JSON.stringify(bidRequestOutstreamV2));
it('should get correct bid response when type is outstream (customRender)', function () {
const bidRequest = JSON.parse(JSON.stringify(bidRequestOutstreamV2));

const request = spec.buildRequests([bidRequest], bidderRequest)
const request = spec.buildRequests([bidRequest], bidderRequest)

const result = spec.interpretResponse({ 'body': basicResponse }, request)
const bid = result[0];
expect(bid).to.have.property('mediaType', VIDEO);
const result = spec.interpretResponse({ 'body': basicResponse }, request)
const bid = result[0];
expect(bid).to.have.property('mediaType', VIDEO);

expect(bid.vastXml).to.eql(vastXml);
})
expect(bid.vastXml).to.eql(vastXml);
})

it('should get vast url', function () {
const bidRequest = JSON.parse(JSON.stringify(bidRequestOutstreamV2));
const bidResponse = JSON.parse(JSON.stringify(basicResponse));
bidResponse.seatbid[0].bid[0].nurl = vastUrl
it('should get vast url', function () {
const bidRequest = JSON.parse(JSON.stringify(bidRequestOutstreamV2));
const bidResponse = JSON.parse(JSON.stringify(basicResponse));
bidResponse.seatbid[0].bid[0].nurl = vastUrl

const request = spec.buildRequests([bidRequest], bidderRequest)
const request = spec.buildRequests([bidRequest], bidderRequest)

const result = spec.interpretResponse({ 'body': bidResponse }, request)
const bid = result[0];
expect(bid).to.have.property('mediaType', VIDEO);
const result = spec.interpretResponse({ 'body': bidResponse }, request)
const bid = result[0];
expect(bid).to.have.property('mediaType', VIDEO);

expect(bid.vastXml).to.eql(vastXml);
expect(bid.vastUrl).to.eql(vastUrl);
})
expect(bid.vastXml).to.eql(vastXml);
expect(bid.vastUrl).to.eql(vastUrl);
})
}
});

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

0 comments on commit 54a8fc1

Please sign in to comment.