From 59880d1e40fcfc77d140cfb32794af4c4de8d4e4 Mon Sep 17 00:00:00 2001 From: "dev adxcg.com" <31470944+adxcgcom@users.noreply.github.com> Date: Wed, 4 Jul 2018 22:47:44 +0000 Subject: [PATCH 1/4] additional parameters sent on auction, impression and video level --- modules/adxcgBidAdapter.js | 280 +++++++++++++++------- test/spec/modules/adxcgBidAdapter_spec.js | 275 ++++++++++++--------- 2 files changed, 348 insertions(+), 207 deletions(-) diff --git a/modules/adxcgBidAdapter.js b/modules/adxcgBidAdapter.js index c6f35445a46..6b95fb1d38a 100644 --- a/modules/adxcgBidAdapter.js +++ b/modules/adxcgBidAdapter.js @@ -1,17 +1,25 @@ -import * as utils from 'src/utils'; -import * as url from 'src/url'; -import {registerBidder} from 'src/adapters/bidderFactory'; -import {BANNER, NATIVE, VIDEO} from 'src/mediaTypes'; +import { config } from 'src/config' +import * as utils from 'src/utils' +import * as url from 'src/url' +import { registerBidder } from 'src/adapters/bidderFactory' +import { BANNER, NATIVE, VIDEO } from 'src/mediaTypes' +import includes from 'core-js/library/fn/array/includes' /** * Adapter for requesting bids from adxcg.net * updated to latest prebid repo on 2017.10.20 * updated for gdpr compliance on 2018.05.22 -requires gdpr compliance module + * updated to pass aditional auction and impression level parameters. added pass for video targeting parameters */ -const BIDDER_CODE = 'adxcg'; -const SUPPORTED_AD_TYPES = [BANNER, VIDEO, NATIVE]; -const SOURCE = 'pbjs10'; +const BIDDER_CODE = 'adxcg' +const SUPPORTED_AD_TYPES = [BANNER, VIDEO, NATIVE] +const SOURCE = 'pbjs10' +const VIDEO_TARGETING = ['id', 'mimes', 'minduration', 'maxduration', 'startdelay', 'skippable', 'playback_method', 'frameworks'] +const USER_PARAMS_AUCTION = ['forcedDspIds', 'forcedCampaignIds', 'forcedCreativeIds', 'gender', 'dnt', 'language'] +const USER_PARAMS_BID = ['lineparam1', 'lineparam2', 'lineparam3'] +const BIDADAPTERVERSION = 'r20180703PB10' + export const spec = { code: BIDDER_CODE, supportedMediaTypes: SUPPORTED_AD_TYPES, @@ -23,7 +31,33 @@ export const spec = { * @return boolean True if this is a valid bid, and false otherwise. */ isBidRequestValid: function (bid) { - return !!(bid.params.adzoneid); + if (!bid || !bid.params) { + utils.logWarn(BIDDER_CODE + ': Missing bid parameters') + return false + } + + if (!utils.isStr(bid.params.adzoneid)) { + utils.logWarn(BIDDER_CODE + ': adzoneid must be specified as a string') + return false + } + + if (isVideoRequest(bid)) { + if (!bid.params.video.mimes) { + // Give a warning but let it pass + utils.logWarn(BIDDER_CODE + ': mimes should be specified for videos') + } else if (!utils.isArray(bid.params.video.mimes) || !bid.params.video.mimes.every(s => utils.isStr(s))) { + utils.logWarn(BIDDER_CODE + ': mimes must be an array of strings') + return false + } + + const context = utils.deepAccess(bid, 'mediaTypes.video.context') + if (context !== 'instream') { + utils.logWarn(BIDDER_CODE + ': video context must be valid - instream') + return false + } + } + + return true }, /** @@ -33,53 +67,110 @@ export const spec = { * Info describing the request to the server. */ buildRequests: function (validBidRequests, bidderRequest) { - utils.logMessage(`buildRequests: ${JSON.stringify(validBidRequests)}`); - - let adZoneIds = []; - let prebidBidIds = []; - let sizes = []; + utils.logMessage(`buildRequests: ${JSON.stringify(validBidRequests)}`) - validBidRequests.forEach(bid => { - adZoneIds.push(utils.getBidIdParameter('adzoneid', bid.params)); - prebidBidIds.push(bid.bidId); - sizes.push(utils.parseSizesInput(bid.sizes).join('|')); - }); + let location = utils.getTopWindowLocation() + let secure = location.protocol === 'https:' + let dt = new Date() + let ratio = window.devicePixelRatio || 1 + let iobavailable = window && window.IntersectionObserver && window.IntersectionObserverEntry && window.IntersectionObserverEntry.prototype && 'intersectionRatio' in window.IntersectionObserverEntry.prototype - let location = utils.getTopWindowLocation(); - let secure = location.protocol === 'https:'; + let bt = config.getConfig('bidderTimeout') + if (window.PREBID_TIMEOUT) { + bt = Math.min(window.PREBID_TIMEOUT, bt) + } - let requestUrl = url.parse(location.href); - requestUrl.search = null; - requestUrl.hash = null; + let requestUrl = url.parse(location.href) + requestUrl.search = null + requestUrl.hash = null + // add common parameters let beaconParams = { renderformat: 'javascript', - ver: 'r20180522PB10', - adzoneid: adZoneIds.join(','), - format: sizes.join(','), - prebidBidIds: prebidBidIds.join(','), - url: encodeURIComponent(url.format(requestUrl)), + ver: BIDADAPTERVERSION, + url: encodeURIComponent(utils.getTopWindowUrl()), secure: secure ? '1' : '0', source: SOURCE, - pbjs: '$prebid.version$' - }; + uw: window.screen.width, + uh: window.screen.height, + dpr: ratio, + bt: bt, + isinframe: utils.inIframe(), + cookies: utils.checkCookieSupport() ? '1' : '0', + tz: dt.getTimezoneOffset(), + dt: utils.timestamp(), + iob: iobavailable ? '1' : '0', + pbjs: '$prebid.version$', + rndid: Math.floor(Math.random() * (999999 - 100000 + 1)) + 100000 + } + + if (utils.getTopWindowReferrer()) { + beaconParams.ref = encodeURIComponent(utils.getTopWindowReferrer()) + } if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) { - beaconParams.gdpr = bidderRequest.gdprConsent.gdprApplies ? '1' : '0'; - beaconParams.gdpr_consent = bidderRequest.gdprConsent.consentString; + beaconParams.gdpr = bidderRequest.gdprConsent.gdprApplies ? '1' : '0' + beaconParams.gdpr_consent = bidderRequest.gdprConsent.consentString } + let biddercustom = config.getConfig(BIDDER_CODE) + if (biddercustom) { + Object.keys(biddercustom) + .filter(param => includes(USER_PARAMS_AUCTION, param)) + .forEach(param => beaconParams[param] = encodeURIComponent(biddercustom[param])) + } + + // per impression parameters + let adZoneIds = [] + let prebidBidIds = [] + let sizes = [] + let bidfloors = [] + + validBidRequests.forEach((bid, index) => { + adZoneIds.push(utils.getBidIdParameter('adzoneid', bid.params)) + prebidBidIds.push(bid.bidId) + sizes.push(utils.parseSizesInput(bid.sizes).join('|')) + + let bidfloor = utils.getBidIdParameter('bidfloor', bid.params) || 0 + bidfloors.push(bidfloor) + // copy video params + if (isVideoRequest(bid)) { + if (bid.params.video) { + Object.keys(bid.params.video) + .filter(param => includes(VIDEO_TARGETING, param)) + .forEach(param => beaconParams['video.' + param + '.' + index] = encodeURIComponent(bid.params.video[param])) + } + // copy video context params + beaconParams['video.context' + '.' + index] = utils.deepAccess(bid, 'mediaTypes.video.context') + } + + // copy all custom parameters impression level parameters not supported above + let customBidParams = utils.getBidIdParameter('custom', bid.params) || {} + if (customBidParams) { + Object.keys(customBidParams) + .filter(param => includes(USER_PARAMS_BID, param)) + .forEach(param => beaconParams[param + '.' + index] = encodeURIComponent(customBidParams[param])) + } + }) + + beaconParams.adzoneid = adZoneIds.join(',') + beaconParams.format = sizes.join(',') + beaconParams.prebidBidIds = prebidBidIds.join(',') + beaconParams.bidfloors = bidfloors.join(',') + let adxcgRequestUrl = url.format({ protocol: secure ? 'https' : 'http', hostname: secure ? 'hbps.adxcg.net' : 'hbp.adxcg.net', pathname: '/get/adi', search: beaconParams - }); + }) return { + contentType: 'text/plain', method: 'GET', url: adxcgRequestUrl, - }; + withCredentials: true + } }, /** * Unpack the response from the server into a list of bids. @@ -87,77 +178,84 @@ export const spec = { * @param {*} serverResponse A successful response from the server. * @return {bidRequests[]} An array of bids which were nested inside the server. */ - interpretResponse: function (serverResponse, bidRequests) { - let bids = []; - - serverResponse = serverResponse.body; - if (serverResponse) { - serverResponse.forEach(serverResponseOneItem => { - let bid = {}; - - bid.requestId = serverResponseOneItem.bidId; - bid.cpm = serverResponseOneItem.cpm; - bid.creativeId = parseInt(serverResponseOneItem.creativeId); - bid.currency = serverResponseOneItem.currency ? serverResponseOneItem.currency : 'USD'; - bid.netRevenue = serverResponseOneItem.netRevenue ? serverResponseOneItem.netRevenue : true; - bid.ttl = serverResponseOneItem.ttl ? serverResponseOneItem.ttl : 300; - - if (serverResponseOneItem.deal_id != null && serverResponseOneItem.deal_id.trim().length > 0) { - bid.dealId = serverResponseOneItem.deal_id; - } + interpretResponse: - if (serverResponseOneItem.ad) { - bid.ad = serverResponseOneItem.ad; - } else if (serverResponseOneItem.vastUrl) { - bid.vastUrl = serverResponseOneItem.vastUrl; - bid.mediaType = 'video'; - } else if (serverResponseOneItem.nativeResponse) { - bid.mediaType = 'native'; + function (serverResponse, bidRequests) { + let bids = [] - let nativeResponse = serverResponseOneItem.nativeResponse; + serverResponse = serverResponse.body + if (serverResponse) { + serverResponse.forEach(serverResponseOneItem => { + let bid = {} - bid['native'] = { - clickUrl: encodeURIComponent(nativeResponse.link.url), - impressionTrackers: nativeResponse.imptrackers - }; + bid.requestId = serverResponseOneItem.bidId + bid.cpm = serverResponseOneItem.cpm + bid.creativeId = parseInt(serverResponseOneItem.creativeId) + bid.currency = serverResponseOneItem.currency ? serverResponseOneItem.currency : 'USD' + bid.netRevenue = serverResponseOneItem.netRevenue ? serverResponseOneItem.netRevenue : true + bid.ttl = serverResponseOneItem.ttl ? serverResponseOneItem.ttl : 300 - nativeResponse.assets.forEach(asset => { - if (asset.title && asset.title.text) { - bid['native'].title = asset.title.text; - } + if (serverResponseOneItem.deal_id != null && serverResponseOneItem.deal_id.trim().length > 0) { + bid.dealId = serverResponseOneItem.deal_id + } - if (asset.img && asset.img.url) { - bid['native'].image = asset.img.url; - } + if (serverResponseOneItem.ad) { + bid.ad = serverResponseOneItem.ad + } else if (serverResponseOneItem.vastUrl) { + bid.vastUrl = serverResponseOneItem.vastUrl + bid.mediaType = 'video' + } else if (serverResponseOneItem.nativeResponse) { + bid.mediaType = 'native' - if (asset.data && asset.data.label === 'DESC' && asset.data.value) { - bid['native'].body = asset.data.value; - } + let nativeResponse = serverResponseOneItem.nativeResponse - if (asset.data && asset.data.label === 'SPONSORED' && asset.data.value) { - bid['native'].sponsoredBy = asset.data.value; + bid['native'] = { + clickUrl: encodeURIComponent(nativeResponse.link.url), + impressionTrackers: nativeResponse.imptrackers } - }); - } - bid.width = serverResponseOneItem.width; - bid.height = serverResponseOneItem.height; - utils.logMessage(`submitting bid[${serverResponseOneItem.bidId}]: ${JSON.stringify(bid)}`); - bids.push(bid); - }); - } else { - utils.logMessage(`empty bid response`); - } - return bids; - }, + nativeResponse.assets.forEach(asset => { + if (asset.title && asset.title.text) { + bid['native'].title = asset.title.text + } + + if (asset.img && asset.img.url) { + bid['native'].image = asset.img.url + } + + if (asset.data && asset.data.label === 'DESC' && asset.data.value) { + bid['native'].body = asset.data.value + } + + if (asset.data && asset.data.label === 'SPONSORED' && asset.data.value) { + bid['native'].sponsoredBy = asset.data.value + } + }) + } + + bid.width = serverResponseOneItem.width + bid.height = serverResponseOneItem.height + utils.logMessage(`submitting bid[${serverResponseOneItem.bidId}]: ${JSON.stringify(bid)}`) + bids.push(bid) + }) + } else { + utils.logMessage(`empty bid response`) + } + return bids + }, + getUserSyncs: function (syncOptions) { if (syncOptions.iframeEnabled) { return [{ type: 'iframe', url: '//cdn.adxcg.net/pb-sync.html' - }]; + }] } } -}; +} + +function isVideoRequest (bid) { + return bid.mediaType === 'video' || !!utils.deepAccess(bid, 'mediaTypes.video') +} -registerBidder(spec); +registerBidder(spec) diff --git a/test/spec/modules/adxcgBidAdapter_spec.js b/test/spec/modules/adxcgBidAdapter_spec.js index 64b4805ca9f..8b57c8a7c10 100644 --- a/test/spec/modules/adxcgBidAdapter_spec.js +++ b/test/spec/modules/adxcgBidAdapter_spec.js @@ -1,10 +1,10 @@ -import {expect} from 'chai'; -import * as url from 'src/url'; -import {spec} from 'modules/adxcgBidAdapter'; +import { expect } from 'chai' +import * as url from 'src/url' +import { spec } from 'modules/adxcgBidAdapter' describe('AdxcgAdapter', () => { describe('isBidRequestValid', () => { - let bid = { + let bidBanner = { 'bidder': 'adxcg', 'params': { 'adzoneid': '1' @@ -14,19 +14,57 @@ describe('AdxcgAdapter', () => { 'bidId': '84ab500420319d', 'bidderRequestId': '7101db09af0db2', 'auctionId': '1d1a030790a475', - }; + } + + let bidVideo = { + 'bidder': 'adxcg', + 'params': { + 'adzoneid': '1', + 'api': [2], + 'protocols': [1, 2], + 'mimes': ['video/mp4', 'video/x-flv'], + 'maxduration': 30 + }, + 'mediaTypes': { + 'video': { + 'context': 'instream' + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [640, 360], [1, 1]], + 'bidId': '84ab500420319d', + 'bidderRequestId': '7101db09af0db2', + 'auctionId': '1d1a030790a475', + } it('should return true when required params found', () => { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); + expect(spec.isBidRequestValid(bidBanner)).to.equal(true) + }) + + it('should return true when required params not found', () => { + expect(spec.isBidRequestValid({})).to.be.false + }) it('should return false when required params are not passed', () => { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); + let bid = Object.assign({}, bidBanner) + delete bid.params + bid.params = {} + expect(spec.isBidRequestValid(bid)).to.equal(false) + }) + + it('should return true when required video params not found', () => { + const simpleVideo = JSON.parse(JSON.stringify(bidVideo)) + simpleVideo.params.adzoneid = 123 + expect(spec.isBidRequestValid(simpleVideo)).to.be.false + // simpleVideo.params.site_id = siteId; + simpleVideo.params.mimes = [1, 2, 3] + expect(spec.isBidRequestValid(simpleVideo)).to.be.false + simpleVideo.params.mimes = 'bad type' + expect(spec.isBidRequestValid(simpleVideo)).to.be.false + // delete simpleVideo.params.mimes + // expect(spec.isBidRequestValid(simpleVideo)).to.be.true + }) + }) describe('request function http', () => { let bid = { @@ -39,30 +77,30 @@ describe('AdxcgAdapter', () => { 'bidId': '84ab500420319d', 'bidderRequestId': '7101db09af0db2', 'auctionId': '1d1a030790a475', - }; + } it('creates a valid adxcg request url', () => { - let request = spec.buildRequests([bid]); - expect(request).to.exist; + let request = spec.buildRequests([bid]) + expect(request).to.exist // console.log('IS:' + JSON.stringify(request)); - expect(request.method).to.equal('GET'); - let parsedRequestUrl = url.parse(request.url); + expect(request.method).to.equal('GET') + let parsedRequestUrl = url.parse(request.url) - expect(parsedRequestUrl.hostname).to.equal('hbp.adxcg.net'); - expect(parsedRequestUrl.pathname).to.equal('/get/adi'); + expect(parsedRequestUrl.hostname).to.equal('hbp.adxcg.net') + expect(parsedRequestUrl.pathname).to.equal('/get/adi') - let query = parsedRequestUrl.search; - expect(query.renderformat).to.equal('javascript'); - expect(query.ver).to.equal('r20180522PB10'); - expect(query.source).to.equal('pbjs10'); - expect(query.pbjs).to.equal('$prebid.version$'); - expect(query.adzoneid).to.equal('1'); - expect(query.format).to.equal('300x250|640x360|1x1'); - expect(query.jsonp).to.be.empty; - expect(query.prebidBidIds).to.equal('84ab500420319d'); - }); - }); + let query = parsedRequestUrl.search + expect(query.renderformat).to.equal('javascript') + expect(query.ver).to.equal('r20180703PB10') + expect(query.source).to.equal('pbjs10') + expect(query.pbjs).to.equal('$prebid.version$') + expect(query.adzoneid).to.equal('1') + expect(query.format).to.equal('300x250|640x360|1x1') + expect(query.jsonp).to.be.empty + expect(query.prebidBidIds).to.equal('84ab500420319d') + }) + }) describe('gdpr compliance', () => { let bid = { @@ -75,26 +113,31 @@ describe('AdxcgAdapter', () => { 'bidId': '84ab500420319d', 'bidderRequestId': '7101db09af0db2', 'auctionId': '1d1a030790a475', - }; + } it('should send GDPR Consent data if gdprApplies', () => { - let request = spec.buildRequests([bid], {gdprConsent: {gdprApplies: true, consentString: 'consentDataString'}}); - let parsedRequestUrl = url.parse(request.url); - let query = parsedRequestUrl.search; + let request = spec.buildRequests([bid], {gdprConsent: {gdprApplies: true, consentString: 'consentDataString'}}) + let parsedRequestUrl = url.parse(request.url) + let query = parsedRequestUrl.search - expect(query.gdpr).to.equal('1'); - expect(query.gdpr_consent).to.equal('consentDataString'); - }); + expect(query.gdpr).to.equal('1') + expect(query.gdpr_consent).to.equal('consentDataString') + }) it('should not send GDPR Consent data if gdprApplies is false or undefined', () => { - let request = spec.buildRequests([bid], {gdprConsent: {gdprApplies: false, consentString: 'consentDataString'}}); - let parsedRequestUrl = url.parse(request.url); - let query = parsedRequestUrl.search; - - expect(query.gdpr).to.be.empty; - expect(query.gdpr_consent).to.be.empty; - }); - }); + let request = spec.buildRequests([bid], { + gdprConsent: { + gdprApplies: false, + consentString: 'consentDataString' + } + }) + let parsedRequestUrl = url.parse(request.url) + let query = parsedRequestUrl.search + + expect(query.gdpr).to.be.empty + expect(query.gdpr_consent).to.be.empty + }) + }) describe('response handler', () => { let BIDDER_REQUEST = { @@ -107,7 +150,7 @@ describe('AdxcgAdapter', () => { 'bidId': '84ab500420319d', 'bidderRequestId': '7101db09af0db2', 'auctionId': '1d1a030790a475', - }; + } let BANNER_RESPONSE = { @@ -209,89 +252,89 @@ describe('AdxcgAdapter', () => { } it('handles regular responses', () => { - let result = spec.interpretResponse(BANNER_RESPONSE, BIDDER_REQUEST); - - expect(result).to.have.lengthOf(1); - - expect(result[0]).to.exist; - expect(result[0].width).to.equal(300); - expect(result[0].height).to.equal(250); - expect(result[0].creativeId).to.equal(42); - expect(result[0].cpm).to.equal(0.45); - expect(result[0].ad).to.equal(''); - expect(result[0].currency).to.equal('USD'); - expect(result[0].netRevenue).to.equal(true); - expect(result[0].ttl).to.equal(300); - expect(result[0].dealId).to.not.exist; - }); + let result = spec.interpretResponse(BANNER_RESPONSE, BIDDER_REQUEST) + + expect(result).to.have.lengthOf(1) + + expect(result[0]).to.exist + expect(result[0].width).to.equal(300) + expect(result[0].height).to.equal(250) + expect(result[0].creativeId).to.equal(42) + expect(result[0].cpm).to.equal(0.45) + expect(result[0].ad).to.equal('') + expect(result[0].currency).to.equal('USD') + expect(result[0].netRevenue).to.equal(true) + expect(result[0].ttl).to.equal(300) + expect(result[0].dealId).to.not.exist + }) it('handles regular responses with dealid', () => { - let result = spec.interpretResponse(BANNER_RESPONSE_WITHDEALID, BIDDER_REQUEST); + let result = spec.interpretResponse(BANNER_RESPONSE_WITHDEALID, BIDDER_REQUEST) - expect(result).to.have.lengthOf(1); + expect(result).to.have.lengthOf(1) - expect(result[0].width).to.equal(300); - expect(result[0].height).to.equal(250); - expect(result[0].creativeId).to.equal(42); - expect(result[0].cpm).to.equal(0.45); - expect(result[0].ad).to.equal(''); - expect(result[0].currency).to.equal('USD'); - expect(result[0].netRevenue).to.equal(true); - expect(result[0].ttl).to.equal(300); - }); + expect(result[0].width).to.equal(300) + expect(result[0].height).to.equal(250) + expect(result[0].creativeId).to.equal(42) + expect(result[0].cpm).to.equal(0.45) + expect(result[0].ad).to.equal('') + expect(result[0].currency).to.equal('USD') + expect(result[0].netRevenue).to.equal(true) + expect(result[0].ttl).to.equal(300) + }) it('handles video responses', () => { - let result = spec.interpretResponse(VIDEO_RESPONSE, BIDDER_REQUEST); - expect(result).to.have.lengthOf(1); - - expect(result[0].width).to.equal(640); - expect(result[0].height).to.equal(360); - expect(result[0].mediaType).to.equal('video'); - expect(result[0].creativeId).to.equal(42); - expect(result[0].cpm).to.equal(0.45); - expect(result[0].vastUrl).to.equal('vastContentUrl'); - expect(result[0].currency).to.equal('USD'); - expect(result[0].netRevenue).to.equal(true); - expect(result[0].ttl).to.equal(300); - }); + let result = spec.interpretResponse(VIDEO_RESPONSE, BIDDER_REQUEST) + expect(result).to.have.lengthOf(1) + + expect(result[0].width).to.equal(640) + expect(result[0].height).to.equal(360) + expect(result[0].mediaType).to.equal('video') + expect(result[0].creativeId).to.equal(42) + expect(result[0].cpm).to.equal(0.45) + expect(result[0].vastUrl).to.equal('vastContentUrl') + expect(result[0].currency).to.equal('USD') + expect(result[0].netRevenue).to.equal(true) + expect(result[0].ttl).to.equal(300) + }) it('handles native responses', () => { - let result = spec.interpretResponse(NATIVE_RESPONSE, BIDDER_REQUEST); - - expect(result[0].width).to.equal(0); - expect(result[0].height).to.equal(0); - expect(result[0].mediaType).to.equal('native'); - expect(result[0].creativeId).to.equal(42); - expect(result[0].cpm).to.equal(0.45); - expect(result[0].currency).to.equal('USD'); - expect(result[0].netRevenue).to.equal(true); - expect(result[0].ttl).to.equal(300); - - expect(result[0].native.clickUrl).to.equal('linkContent'); - expect(result[0].native.impressionTrackers).to.deep.equal(['impressionTracker1', 'impressionTracker2']); - expect(result[0].native.title).to.equal('titleContent'); - expect(result[0].native.image).to.equal('imageContent'); - expect(result[0].native.body).to.equal('descriptionContent'); - expect(result[0].native.sponsoredBy).to.equal('sponsoredByContent'); - }); + let result = spec.interpretResponse(NATIVE_RESPONSE, BIDDER_REQUEST) + + expect(result[0].width).to.equal(0) + expect(result[0].height).to.equal(0) + expect(result[0].mediaType).to.equal('native') + expect(result[0].creativeId).to.equal(42) + expect(result[0].cpm).to.equal(0.45) + expect(result[0].currency).to.equal('USD') + expect(result[0].netRevenue).to.equal(true) + expect(result[0].ttl).to.equal(300) + + expect(result[0].native.clickUrl).to.equal('linkContent') + expect(result[0].native.impressionTrackers).to.deep.equal(['impressionTracker1', 'impressionTracker2']) + expect(result[0].native.title).to.equal('titleContent') + expect(result[0].native.image).to.equal('imageContent') + expect(result[0].native.body).to.equal('descriptionContent') + expect(result[0].native.sponsoredBy).to.equal('sponsoredByContent') + }) it('handles nobid responses', () => { - let response = []; - let bidderRequest = BIDDER_REQUEST; + let response = [] + let bidderRequest = BIDDER_REQUEST - let result = spec.interpretResponse(response, bidderRequest); - expect(result.length).to.equal(0); - }); - }); + let result = spec.interpretResponse(response, bidderRequest) + expect(result.length).to.equal(0) + }) + }) describe('getUserSyncs', () => { let syncoptionsIframe = { 'iframeEnabled': 'true' - }; + } it('should return iframe sync option', () => { - expect(spec.getUserSyncs(syncoptionsIframe)[0].type).to.equal('iframe'); - expect(spec.getUserSyncs(syncoptionsIframe)[0].url).to.equal('//cdn.adxcg.net/pb-sync.html'); - }); - }); -}); + expect(spec.getUserSyncs(syncoptionsIframe)[0].type).to.equal('iframe') + expect(spec.getUserSyncs(syncoptionsIframe)[0].url).to.equal('//cdn.adxcg.net/pb-sync.html') + }) + }) +}) From 96453eb981982b3c254881f4dfd9d60dfe4f74bc Mon Sep 17 00:00:00 2001 From: adxcgcom <31470944+adxcgcom@users.noreply.github.com> Date: Fri, 13 Jul 2018 16:13:22 +0200 Subject: [PATCH 2/4] Removed commented code here, line 64 and line 85 --- test/spec/modules/adxcgBidAdapter_spec.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/spec/modules/adxcgBidAdapter_spec.js b/test/spec/modules/adxcgBidAdapter_spec.js index 8b57c8a7c10..716aa18c2e7 100644 --- a/test/spec/modules/adxcgBidAdapter_spec.js +++ b/test/spec/modules/adxcgBidAdapter_spec.js @@ -61,8 +61,6 @@ describe('AdxcgAdapter', () => { expect(spec.isBidRequestValid(simpleVideo)).to.be.false simpleVideo.params.mimes = 'bad type' expect(spec.isBidRequestValid(simpleVideo)).to.be.false - // delete simpleVideo.params.mimes - // expect(spec.isBidRequestValid(simpleVideo)).to.be.true }) }) @@ -82,11 +80,9 @@ describe('AdxcgAdapter', () => { it('creates a valid adxcg request url', () => { let request = spec.buildRequests([bid]) expect(request).to.exist - // console.log('IS:' + JSON.stringify(request)); - + expect(request.method).to.equal('GET') let parsedRequestUrl = url.parse(request.url) - expect(parsedRequestUrl.hostname).to.equal('hbp.adxcg.net') expect(parsedRequestUrl.pathname).to.equal('/get/adi') From 616ee7b9f3facf9075bf6af7a5c6e0a3643a2564 Mon Sep 17 00:00:00 2001 From: adxcgcom <31470944+adxcgcom@users.noreply.github.com> Date: Fri, 13 Jul 2018 16:24:59 +0200 Subject: [PATCH 3/4] removing trailing spaces --- test/spec/modules/adxcgBidAdapter_spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/spec/modules/adxcgBidAdapter_spec.js b/test/spec/modules/adxcgBidAdapter_spec.js index 716aa18c2e7..81fee906455 100644 --- a/test/spec/modules/adxcgBidAdapter_spec.js +++ b/test/spec/modules/adxcgBidAdapter_spec.js @@ -80,7 +80,6 @@ describe('AdxcgAdapter', () => { it('creates a valid adxcg request url', () => { let request = spec.buildRequests([bid]) expect(request).to.exist - expect(request.method).to.equal('GET') let parsedRequestUrl = url.parse(request.url) expect(parsedRequestUrl.hostname).to.equal('hbp.adxcg.net') From ab78dfd9b2b168ee4c7d4c6fcc8dc9e0594a2aa5 Mon Sep 17 00:00:00 2001 From: adxcgcom <31470944+adxcgcom@users.noreply.github.com> Date: Sat, 14 Jul 2018 08:40:00 +0200 Subject: [PATCH 4/4] comments cleanup --- test/spec/modules/adxcgBidAdapter_spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/spec/modules/adxcgBidAdapter_spec.js b/test/spec/modules/adxcgBidAdapter_spec.js index 81fee906455..60aadaec21f 100644 --- a/test/spec/modules/adxcgBidAdapter_spec.js +++ b/test/spec/modules/adxcgBidAdapter_spec.js @@ -56,7 +56,6 @@ describe('AdxcgAdapter', () => { const simpleVideo = JSON.parse(JSON.stringify(bidVideo)) simpleVideo.params.adzoneid = 123 expect(spec.isBidRequestValid(simpleVideo)).to.be.false - // simpleVideo.params.site_id = siteId; simpleVideo.params.mimes = [1, 2, 3] expect(spec.isBidRequestValid(simpleVideo)).to.be.false simpleVideo.params.mimes = 'bad type'