diff --git a/modules/seedtagBidAdapter.js b/modules/seedtagBidAdapter.js index e1832e50020..24cc6489ef0 100644 --- a/modules/seedtagBidAdapter.js +++ b/modules/seedtagBidAdapter.js @@ -6,7 +6,13 @@ const BIDDER_CODE = 'seedtag'; const SEEDTAG_ALIAS = 'st'; const SEEDTAG_SSP_ENDPOINT = 'https://s.seedtag.com/c/hb/bid'; const SEEDTAG_SSP_ONTIMEOUT_ENDPOINT = 'https://s.seedtag.com/se/hb/timeout'; - +const ALLOWED_PLACEMENTS = { + inImage: true, + inScreen: true, + inArticle: true, + banner: true, + video: true +} const mediaTypesMap = { [BANNER]: 'display', [VIDEO]: 'video' @@ -27,10 +33,7 @@ function hasMandatoryParams(params) { !!params.publisherId && !!params.adUnitId && !!params.placement && - (params.placement === 'inImage' || - params.placement === 'inScreen' || - params.placement === 'banner' || - params.placement === 'video') + !!ALLOWED_PLACEMENTS[params.placement] ); } @@ -88,8 +91,10 @@ function buildBid(seedtagBid) { currency: seedtagBid.currency, netRevenue: true, mediaType: mediaType, - ttl: seedtagBid.ttl + ttl: seedtagBid.ttl, + nurl: seedtagBid.nurl }; + if (mediaType === VIDEO) { bid.vastXml = seedtagBid.content; } else { @@ -200,6 +205,16 @@ export const spec = { onTimeout(data) { getTimeoutUrl(data); utils.triggerPixel(SEEDTAG_SSP_ONTIMEOUT_ENDPOINT); + }, + + /** + * Function to call when the adapter wins the auction + * @param {bid} Bid information received from the server + */ + onBidWon: function (bid) { + if (bid && bid.nurl) { + utils.triggerPixel(bid.nurl); + } } } registerBidder(spec); diff --git a/test/spec/modules/seedtagBidAdapter_spec.js b/test/spec/modules/seedtagBidAdapter_spec.js index 8957bde6bd9..b43d2fa8a5f 100644 --- a/test/spec/modules/seedtagBidAdapter_spec.js +++ b/test/spec/modules/seedtagBidAdapter_spec.js @@ -1,5 +1,6 @@ import { expect } from 'chai' import { spec, getTimeoutUrl } from 'modules/seedtagBidAdapter.js' +import * as utils from 'src/utils.js' const PUBLISHER_ID = '0000-0000-01' const ADUNIT_ID = '000000' @@ -42,7 +43,7 @@ describe('Seedtag Adapter', function() { } ) } - const placements = ['banner', 'video', 'inImage', 'inScreen'] + const placements = ['banner', 'video', 'inImage', 'inScreen', 'inArticle'] placements.forEach(placement => { it('should be ' + placement, function() { const isBidRequestValid = spec.isBidRequestValid( @@ -53,7 +54,7 @@ describe('Seedtag Adapter', function() { }) }) }) - describe('when video slot has all mandatory params.', function() { + describe('when video slot has all mandatory params', function() { it('should return true, when video mediatype object are correct.', function() { const slotConfig = getSlotConfigs( { @@ -116,7 +117,7 @@ describe('Seedtag Adapter', function() { expect(isBidRequestValid).to.equal(false) }) }) - describe('when video mediaType object is not correct.', function() { + describe('when video mediaType object is not correct', function() { function createVideoSlotconfig(mediaType) { return getSlotConfigs(mediaType, { publisherId: PUBLISHER_ID, @@ -301,7 +302,7 @@ describe('Seedtag Adapter', function() { expect(typeof bids).to.equal('object') expect(bids.length).to.equal(0) }) - it('should return a void array, when the server response have not got bids.', function() { + it('should return a void array, when the server response have no bids.', function() { const request = { data: JSON.stringify({}) } const serverResponse = { body: { bids: [] } } const bids = spec.interpretResponse(serverResponse, request) @@ -323,7 +324,8 @@ describe('Seedtag Adapter', function() { width: 728, height: 90, mediaType: 'display', - ttl: 360 + ttl: 360, + nurl: 'testurl.com/nurl' } ], cookieSync: { url: '' } @@ -338,6 +340,7 @@ describe('Seedtag Adapter', function() { expect(bids[0].currency).to.equal('USD') expect(bids[0].netRevenue).to.equal(true) expect(bids[0].ad).to.equal('content') + expect(bids[0].nurl).to.equal('testurl.com/nurl') }) }) describe('the bid is a video', function() { @@ -354,7 +357,8 @@ describe('Seedtag Adapter', function() { width: 728, height: 90, mediaType: 'video', - ttl: 360 + ttl: 360, + nurl: undefined } ], cookieSync: { url: '' } @@ -416,4 +420,33 @@ describe('Seedtag Adapter', function() { ) }) }) + + describe('onBidWon', function () { + beforeEach(function() { + sinon.stub(utils, 'triggerPixel') + }) + + afterEach(function() { + utils.triggerPixel.restore() + }) + + describe('without nurl', function() { + const bid = {} + + it('does not create pixel ', function() { + spec.onBidWon(bid) + expect(utils.triggerPixel.called).to.equal(false); + }) + }) + + describe('with nurl', function () { + const nurl = 'http://seedtag_domain/won' + const bid = { nurl } + + it('creates nurl pixel if bid nurl', function() { + spec.onBidWon({ nurl }) + expect(utils.triggerPixel.calledWith(nurl)).to.equal(true); + }) + }) + }) })