From a9b267821924cb2df0fe69e5bd5718b794c91141 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Mon, 8 May 2023 10:25:51 -0400 Subject: [PATCH] Revert "Prebid 8: Delete adgeneration (#9904)" This reverts commit ce984b34fbacd753264bc87c4c6b9fabf4871344. --- modules/adgenerationBidAdapter.js | 315 ++++++ modules/adgenerationBidAdapter.md | 75 ++ .../modules/adgenerationBidAdapter_spec.js | 984 ++++++++++++++++++ 3 files changed, 1374 insertions(+) create mode 100644 modules/adgenerationBidAdapter.js create mode 100644 modules/adgenerationBidAdapter.md create mode 100644 test/spec/modules/adgenerationBidAdapter_spec.js diff --git a/modules/adgenerationBidAdapter.js b/modules/adgenerationBidAdapter.js new file mode 100644 index 00000000000..0e4e9ef6805 --- /dev/null +++ b/modules/adgenerationBidAdapter.js @@ -0,0 +1,315 @@ +import {tryAppendQueryString, getBidIdParameter, escapeUnsafeChars} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, NATIVE} from '../src/mediaTypes.js'; +import {config} from '../src/config.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; + +const ADG_BIDDER_CODE = 'adgeneration'; + +export const spec = { + code: ADG_BIDDER_CODE, + aliases: ['adg'], // short code + supportedMediaTypes: [BANNER, NATIVE], + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function (bid) { + return !!(bid.params.id); + }, + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} - an array of bids + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function (validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const ADGENE_PREBID_VERSION = '1.4.0'; + let serverRequests = []; + for (let i = 0, len = validBidRequests.length; i < len; i++) { + const validReq = validBidRequests[i]; + const DEBUG_URL = 'https://api-test.scaleout.jp/adsv/v1'; + const URL = 'https://d.socdm.com/adsv/v1'; + const url = validReq.params.debug ? DEBUG_URL : URL; + const criteoId = getCriteoId(validReq); + const id5id = getId5Id(validReq); + const id5LinkType = getId5LinkType(validReq); + let data = ``; + data = tryAppendQueryString(data, 'posall', 'SSPLOC'); + const id = getBidIdParameter('id', validReq.params); + data = tryAppendQueryString(data, 'id', id); + data = tryAppendQueryString(data, 'sdktype', '0'); + data = tryAppendQueryString(data, 'hb', 'true'); + data = tryAppendQueryString(data, 't', 'json3'); + data = tryAppendQueryString(data, 'transactionid', validReq.transactionId); + data = tryAppendQueryString(data, 'sizes', getSizes(validReq)); + data = tryAppendQueryString(data, 'currency', getCurrencyType()); + data = tryAppendQueryString(data, 'pbver', '$prebid.version$'); + data = tryAppendQueryString(data, 'sdkname', 'prebidjs'); + data = tryAppendQueryString(data, 'adapterver', ADGENE_PREBID_VERSION); + data = tryAppendQueryString(data, 'adgext_criteo_id', criteoId); + data = tryAppendQueryString(data, 'adgext_id5_id', id5id); + data = tryAppendQueryString(data, 'adgext_id5_id_link_type', id5LinkType); + // native以外にvideo等の対応が入った場合は要修正 + if (!validReq.mediaTypes || !validReq.mediaTypes.native) { + data = tryAppendQueryString(data, 'imark', '1'); + } + + // TODO: is 'page' the right value here? + data = tryAppendQueryString(data, 'tp', bidderRequest.refererInfo.page); + if (isIos()) { + const hyperId = getHyperId(validReq); + if (hyperId != null) { + data = tryAppendQueryString(data, 'hyper_id', hyperId); + } + } + // remove the trailing "&" + if (data.lastIndexOf('&') === data.length - 1) { + data = data.substring(0, data.length - 1); + } + serverRequests.push({ + method: 'GET', + url: url, + data: data, + bidRequest: validBidRequests[i] + }); + } + return serverRequests; + }, + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @param {BidRequest} bidRequests + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function (serverResponse, bidRequests) { + const body = serverResponse.body; + if (!body.results || body.results.length < 1) { + return []; + } + const bidRequest = bidRequests.bidRequest; + const bidResponse = { + requestId: bidRequest.bidId, + cpm: body.cpm || 0, + width: body.w ? body.w : 1, + height: body.h ? body.h : 1, + creativeId: body.creativeid || '', + dealId: body.dealid || '', + currency: getCurrencyType(), + netRevenue: true, + ttl: body.ttl || 10, + }; + if (body.adomain && Array.isArray(body.adomain) && body.adomain.length) { + bidResponse.meta = { + advertiserDomains: body.adomain + } + } + if (isNative(body)) { + bidResponse.native = createNativeAd(body); + bidResponse.mediaType = NATIVE; + } else { + // banner + bidResponse.ad = createAd(body, bidRequest); + } + return [bidResponse]; + }, + + /** + * Register the user sync pixels which should be dropped after the auction. + * + * @param {SyncOptions} syncOptions Which user syncs are allowed? + * @param {ServerResponse[]} serverResponses List of server's responses. + * @return {UserSync[]} The user syncs which should be dropped. + */ + getUserSyncs: function (syncOptions, serverResponses) { + const syncs = []; + return syncs; + } +}; + +function createAd(body, bidRequest) { + let ad = body.ad; + if (body.vastxml && body.vastxml.length > 0) { + if (isUpperBillboard(body)) { + const marginTop = bidRequest.params.marginTop ? bidRequest.params.marginTop : '0'; + ad = `${createADGBrowserMTag()}${insertVASTMethodForADGBrowserM(body.vastxml, marginTop)}`; + } else { + ad = `
${createAPVTag()}${insertVASTMethodForAPV(bidRequest.bidId, body.vastxml)}`; + } + } + ad = appendChildToBody(ad, body.beacon); + if (removeWrapper(ad)) return removeWrapper(ad); + return ad; +} + +function isUpperBillboard(body) { + if (body.location_params && body.location_params.option && body.location_params.option.ad_type) { + return body.location_params.option.ad_type === 'upper_billboard'; + } + return false; +} + +function isNative(body) { + if (!body) return false; + return body.native_ad && body.native_ad.assets.length > 0; +} + +function createNativeAd(body) { + let native = {}; + if (body.native_ad && body.native_ad.assets.length > 0) { + const assets = body.native_ad.assets; + for (let i = 0, len = assets.length; i < len; i++) { + switch (assets[i].id) { + case 1: + native.title = assets[i].title.text; + break; + case 2: + native.image = { + url: assets[i].img.url, + height: assets[i].img.h, + width: assets[i].img.w, + }; + break; + case 3: + native.icon = { + url: assets[i].img.url, + height: assets[i].img.h, + width: assets[i].img.w, + }; + break; + case 4: + native.sponsoredBy = assets[i].data.value; + break; + case 5: + native.body = assets[i].data.value; + break; + case 6: + native.cta = assets[i].data.value; + break; + case 502: + native.privacyLink = encodeURIComponent(assets[i].data.value); + break; + } + } + native.clickUrl = body.native_ad.link.url; + native.clickTrackers = body.native_ad.link.clicktrackers || []; + native.impressionTrackers = body.native_ad.imptrackers || []; + if (body.beaconurl && body.beaconurl != '') { + native.impressionTrackers.push(body.beaconurl); + } + } + return native; +} + +function appendChildToBody(ad, data) { + return ad.replace(/<\/\s?body>/, `${data}`); +} + +function createAPVTag() { + const APVURL = 'https://cdn.apvdr.com/js/VideoAd.min.js'; + let apvScript = document.createElement('script'); + apvScript.type = 'text/javascript'; + apvScript.id = 'apv'; + apvScript.src = APVURL; + return apvScript.outerHTML; +} + +function createADGBrowserMTag() { + const ADGBrowserMURL = 'https://i.socdm.com/sdk/js/adg-browser-m.js'; + return ``; +} + +function insertVASTMethodForAPV(targetId, vastXml) { + let apvVideoAdParam = { + s: targetId + }; + let script = document.createElement(`script`); + script.type = 'text/javascript'; + script.innerHTML = `(function(){ new APV.VideoAd(${escapeUnsafeChars(JSON.stringify(apvVideoAdParam))}).load('${vastXml.replace(/\r?\n/g, '')}'); })();`; + return script.outerHTML; +} + +function insertVASTMethodForADGBrowserM(vastXml, marginTop) { + const script = document.createElement(`script`); + script.type = 'text/javascript'; + script.innerHTML = `window.ADGBrowserM.init({vastXml: '${vastXml.replace(/\r?\n/g, '')}', marginTop: '${marginTop}'});`; + return script.outerHTML; +} + +/** + * + * @param ad + */ +function removeWrapper(ad) { + const bodyIndex = ad.indexOf(''); + const lastBodyIndex = ad.lastIndexOf(''); + if (bodyIndex === -1 || lastBodyIndex === -1) return false; + return ad.substr(bodyIndex, lastBodyIndex).replace('', '').replace('', ''); +} + +/** + * request + * @param validReq request + * @returns {?string} 300x250,320x50... + */ +function getSizes(validReq) { + const sizes = validReq.sizes; + if (!sizes || sizes.length < 1) return null; + let sizesStr = ''; + for (const i in sizes) { + const size = sizes[i]; + if (size.length !== 2) return null; + sizesStr += `${size[0]}x${size[1]},`; + } + if (sizesStr || sizesStr.lastIndexOf(',') === sizesStr.length - 1) { + sizesStr = sizesStr.substring(0, sizesStr.length - 1); + } + return sizesStr; +} + +/** + * @return {?string} USD or JPY + */ +function getCurrencyType() { + if (config.getConfig('currency.adServerCurrency') && config.getConfig('currency.adServerCurrency').toUpperCase() === 'USD') return 'USD'; + return 'JPY'; +} + +/** + * + * @param validReq request + * @return {null|string} + */ +function getCriteoId(validReq) { + return (validReq.userId && validReq.userId.criteoId) ? validReq.userId.criteoId : null +} + +function getId5Id(validReq) { + return validId5(validReq) ? validReq.userId.id5id.uid : null +} + +function getId5LinkType(validReq) { + return validId5(validReq) ? validReq.userId.id5id.ext.linkType : null +} + +function validId5(validReq) { + return validReq.userId && validReq.userId.id5id && validReq.userId.id5id.uid && validReq.userId.id5id.ext.linkType +} + +function getHyperId(validReq) { + if (validReq.userId && validReq.userId.novatiq && validReq.userId.novatiq.snowflake.syncResponse === 1) { + return validReq.userId.novatiq.snowflake.id; + } + return null; +} + +function isIos() { + return (/(ios|ipod|ipad|iphone)/i).test(window.navigator.userAgent); +} + +registerBidder(spec); diff --git a/modules/adgenerationBidAdapter.md b/modules/adgenerationBidAdapter.md new file mode 100644 index 00000000000..7f66732ff38 --- /dev/null +++ b/modules/adgenerationBidAdapter.md @@ -0,0 +1,75 @@ +# Overview + +``` +Module Name: AdGeneration Bid Adapter +Module Type: Bidder Adapter +Maintainer: ssp-ope@supership.jp +``` + +# Description + +Connects to AdGeneration exchange for bids. + +AdGeneration bid adapter supports Banner and Native. + +# Test Parameters +``` +var adUnits = [ + // Banner adUnit + { + code: 'banner-div', // banner + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: 'adg', + params: { + id: '58278', // banner + } + }, + ] + }, + // Native adUnit + { + code: 'native-div', + sizes: [[1,1]], + mediaTypes: { + native: { + image: { + required: true + }, + title: { + required: true, + len: 80 + }, + sponsoredBy: { + required: true + }, + clickUrl: { + required: true + }, + body: { + required: true + }, + icon: { + required: true + }, + privacyLink: { + required: true + }, + }, + }, + bids: [ + { + bidder: 'adg', + params: { + id: '58279', //native + } + }, + ] + }, +]; +``` diff --git a/test/spec/modules/adgenerationBidAdapter_spec.js b/test/spec/modules/adgenerationBidAdapter_spec.js new file mode 100644 index 00000000000..8583c226e50 --- /dev/null +++ b/test/spec/modules/adgenerationBidAdapter_spec.js @@ -0,0 +1,984 @@ +import {expect} from 'chai'; +import {spec} from 'modules/adgenerationBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import {NATIVE} from 'src/mediaTypes.js'; +import {config} from 'src/config.js'; +import prebid from '../../../package.json'; + +describe('AdgenerationAdapter', function () { + const adapter = newBidder(spec); + const ENDPOINT = ['https://api-test.scaleout.jp/adsv/v1', 'https://d.socdm.com/adsv/v1']; + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + const bid = { + 'bidder': 'adg', + 'params': { + id: '58278', // banner + } + }; + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = {}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + const bidRequests = [ + { // banner + bidder: 'adg', + params: { + id: '58278', + currency: 'JPY', + }, + adUnitCode: 'adunit-code', + sizes: [[300, 250], [320, 100]], + bidId: '2f6ac468a9c15e', + bidderRequestId: '14a9f773e30243', + auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', + transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a' + }, + { // native + bidder: 'adg', + params: { + id: '58278', + currency: 'JPY', + }, + mediaTypes: { + native: { + image: { + required: true + }, + title: { + required: true, + len: 80 + }, + sponsoredBy: { + required: true + }, + clickUrl: { + required: true + }, + body: { + required: true + }, + icon: { + required: true + } + }, + }, + adUnitCode: 'adunit-code', + sizes: [[1, 1]], + bidId: '2f6ac468a9c15e', + bidderRequestId: '14a9f773e30243', + auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', + transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a' + }, + { // bannerWithHyperId + bidder: 'adg', + params: { + id: '58278', // banner + }, + adUnitCode: 'adunit-code', + sizes: [[320, 100]], + bidId: '2f6ac468a9c15e', + bidderRequestId: '14a9f773e30243', + auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', + transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a', + userId: { + novatiq: { + snowflake: {'id': 'novatiqId', syncResponse: 1} + } + } + }, + { // bannerWithAdgextCriteoId + bidder: 'adg', + params: { + id: '58278', // banner + }, + adUnitCode: 'adunit-code', + sizes: [[320, 100]], + bidId: '2f6ac468a9c15e', + bidderRequestId: '14a9f773e30243', + auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', + transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a', + userId: { + criteoId: 'criteo-id-test-1234567890' + } + }, + { // bannerWithAdgextId5Id + bidder: 'adg', + params: { + id: '58278', // banner + }, + adUnitCode: 'adunit-code', + sizes: [[320, 100]], + bidId: '2f6ac468a9c15e', + bidderRequestId: '14a9f773e30243', + auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', + transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a', + userId: { + id5id: { + ext: { + linkType: 2 + }, + uid: 'id5-id-test-1234567890' + } + } + } + ]; + const bidderRequest = { + refererInfo: { + page: 'https://example.com' + } + }; + const data = { + banner: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.4.0&imark=1&tp=https%3A%2F%2Fexample.com`, + bannerUSD: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100¤cy=USD&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.4.0&imark=1&tp=https%3A%2F%2Fexample.com`, + native: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=1x1¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.4.0&tp=https%3A%2F%2Fexample.com`, + bannerWithHyperId: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=320x100¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.4.0&imark=1&tp=https%3A%2F%2Fexample.com&hyper_id=novatiqId`, + bannerWithAdgextCriteoId: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=320x100¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.4.0&adgext_criteo_id=criteo-id-test-1234567890&imark=1&tp=https%3A%2F%2Fexample.com`, + bannerWithAdgextId5Id: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=320x100¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.4.0&adgext_id5_id=id5-id-test-1234567890&adgext_id5_id_link_type=2&imark=1&tp=https%3A%2F%2Fexample.com`, + }; + it('sends bid request to ENDPOINT via GET', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.url).to.equal(ENDPOINT[1]); + expect(request.method).to.equal('GET'); + }); + + it('sends bid request to debug ENDPOINT via GET', function () { + bidRequests[0].params.debug = true; + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.url).to.equal(ENDPOINT[0]); + expect(request.method).to.equal('GET'); + }); + + it('should attache params to the banner request', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.data).to.equal(data.banner); + }); + + it('should attache params to the native request', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[1]; + expect(request.data).to.equal(data.native); + }); + + it('should attache params to the bannerWithHyperId request', function () { + const defaultUA = window.navigator.userAgent; + window.navigator.__defineGetter__('userAgent', function() { + return 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1'; + }); + const request = spec.buildRequests(bidRequests, bidderRequest)[2]; + + window.navigator.__defineGetter__('userAgent', function() { + return defaultUA; + }); + expect(request.data).to.equal(data.bannerWithHyperId); + }); + + it('should attache params to the bannerWithAdgextCriteoId request', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[3]; + expect(request.data).to.equal(data.bannerWithAdgextCriteoId); + }); + + it('should attache params to the bannerWithAdgextId5Id request', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[4]; + expect(request.data).to.equal(data.bannerWithAdgextId5Id); + }); + + it('allows setConfig to set bidder currency for JPY', function () { + config.setConfig({ + currency: { + adServerCurrency: 'JPY' + } + }); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.data).to.equal(data.banner); + config.resetConfig(); + }); + it('allows setConfig to set bidder currency for USD', function () { + config.setConfig({ + currency: { + adServerCurrency: 'USD' + } + }); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.data).to.equal(data.bannerUSD); + config.resetConfig(); + }); + }); + describe('interpretResponse', function () { + const bidRequests = { + banner: { + bidRequest: { + bidder: 'adg', + params: { + id: '58278', // banner + }, + adUnitCode: 'adunit-code', + sizes: [[320, 100]], + bidId: '2f6ac468a9c15e', + bidderRequestId: '14a9f773e30243', + auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', + transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a' + }, + }, + native: { + bidRequest: { + bidder: 'adg', + params: { + id: '58278', // banner + }, + mediaTypes: { + native: { + image: { + required: true + }, + title: { + required: true, + len: 80 + }, + sponsoredBy: { + required: true + }, + clickUrl: { + required: true + }, + body: { + required: true + }, + icon: { + required: true + } + } + }, + adUnitCode: 'adunit-code', + sizes: [[1, 1]], + bidId: '2f6ac468a9c15e', + bidderRequestId: '14a9f773e30243', + auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', + transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a' + }, + }, + upperBillboard: { + bidRequest: { + bidder: 'adg', + params: { + id: '143038', // banner + marginTop: '50', + }, + adUnitCode: 'adunit-code', + sizes: [[320, 180]], + bidId: '2f6ac468a9c15e', + bidderRequestId: '14a9f773e30243', + auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', + transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a' + }, + }, + }; + + const serverResponse = { + noAd: { + results: [], + }, + normal: { + banner: { + ad: '
', + beacon: '', + cpm: 36.0008, + displaytype: '1', + ids: {}, + w: 320, + h: 100, + location_params: null, + locationid: '58279', + rotation: '0', + scheduleid: '512603', + sdktype: '0', + creativeid: '1k2kv35vsa5r', + dealid: 'fd5sa5fa7f', + ttl: 1000, + results: [ + {ad: '<\!DOCTYPE html>
'}, + ], + adomain: ['advertiserdomain.com'] + }, + native: { + ad: '<\!DOCTYPE html>↵ ↵ ↵ ↵ ↵
↵ ', + beacon: '', + cpm: 36.0008, + displaytype: '1', + ids: {}, + location_params: null, + locationid: '58279', + adomain: ['advertiserdomain.com'], + native_ad: { + assets: [ + { + data: { + label: 'accompanying_text', + value: 'AD' + }, + id: 501 + }, + { + data: { + label: 'optout_url', + value: 'https://supership.jp/optout/#' + }, + id: 502 + }, + { + data: { + ext: { + black_back: 'https://i.socdm.com/sdk/img/icon_adg_optout_26x26_white.png', + }, + label: 'information_icon_url', + value: 'https://i.socdm.com/sdk/img/icon_adg_optout_26x26_gray.png', + id: 503 + } + }, + { + id: 1, + required: 1, + title: {text: 'Title'} + }, + { + id: 2, + img: { + h: 250, + url: 'https://sdk-temp.s3-ap-northeast-1.amazonaws.com/adg-sample-ad/img/300x250.png', + w: 300 + }, + required: 1 + }, + { + id: 3, + img: { + h: 300, + url: 'https://placehold.jp/300x300.png', + w: 300 + }, + required: 1 + }, + { + data: {value: 'Description'}, + id: 5, + required: 0 + }, + { + data: {value: 'CTA'}, + id: 6, + required: 0 + }, + { + data: {value: 'Sponsored'}, + id: 4, + required: 0 + } + ], + imptrackers: ['https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1.gif'], + link: { + clicktrackers: [ + 'https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1_clicktracker_access.gif' + ], + url: 'https://supership.jp' + }, + }, + results: [ + {ad: 'Creative<\/body>'} + ], + rotation: '0', + scheduleid: '512603', + sdktype: '0', + creativeid: '1k2kv35vsa5r', + dealid: 'fd5sa5fa7f', + ttl: 1000 + }, + upperBillboard: { + 'ad': '<\!DOCTYPE html>\n \n \n \n \n \n \n \n
\n \n
\n \n', + 'beacon': '', + 'beaconurl': 'https://tg.socdm.com/bc/v3?b=Y2hzbT0yOTQsNGZiM2NkNWVpZD0xNDMwMzgmcG9zPVNTUExPQyZhZD0xMjMzMzIzLzI2MTA2MS4yNjU3OTkuMTIzMzMyMy8yMTY2NDY2LzE1NDQxMC8xNDMwMzg6U1NQTE9DOiovaWR4PTA7ZHNwaWQ9MTtkaTI9MjEzNC0xMzI4NjRfbmV3Zm9ybWF0X3Rlc3Q7ZnR5cGU9Mztwcj15TXB3O3ByYj15UTtwcm89eVE7cHJvYz1KUFk7Y3JkMnk9MTExLjkyO2NyeTJkPTAuMDA4OTM0OTUzNTM4MjQxNjAxMztwcnY9aWp6QVZtWW9wbmJUV1B0cWhtZEN1ZWRXNDd0MjU1MEtmYjFWYmI3SzsmZXg9MTYzMzMyNzU4MyZjdD0xNjMzMzI3NTgzODAzJnNyPWh0dHA-&xuid=Xm8Q8cCo5r8AAHCCMg0AAAAA&ctsv=m-ad240&seqid=be38bdb4-74a7-14a7-3439-b7f1ea8b4f33&seqtime=1633327583803&seqctx=gat3by5hZy5mdHlwZaEz&t=.gif', + 'cpm': 80, + 'creative_params': {}, + 'creativeid': 'ScaleOut_2146187', + 'dealid': '2134-132864_newformat_test', + 'displaytype': '1', + 'h': 180, + 'ids': { + 'anid': '', + 'diid': '', + 'idfa': '', + 'soc': 'Xm8Q8cCo5r8AAHCCMg0AAAAA' + }, + 'location_params': { + 'option': { + 'ad_type': 'upper_billboard' + } + }, + 'locationid': '143038', + 'results': [ + { + 'ad': '<\!DOCTYPE html>\n \n \n \n \n \n \n \n
\n \n
\n \n', + 'beacon': '', + 'beaconurl': 'https://tg.socdm.com/bc/v3?b=Y2hzbT0yOTQsNGZiM2NkNWVpZD0xNDMwMzgmcG9zPVNTUExPQyZhZD0xMjMzMzIzLzI2MTA2MS4yNjU3OTkuMTIzMzMyMy8yMTY2NDY2LzE1NDQxMC8xNDMwMzg6U1NQTE9DOiovaWR4PTA7ZHNwaWQ9MTtkaTI9MjEzNC0xMzI4NjRfbmV3Zm9ybWF0X3Rlc3Q7ZnR5cGU9Mztwcj15TXB3O3ByYj15UTtwcm89eVE7cHJvYz1KUFk7Y3JkMnk9MTExLjkyO2NyeTJkPTAuMDA4OTM0OTUzNTM4MjQxNjAxMztwcnY9aWp6QVZtWW9wbmJUV1B0cWhtZEN1ZWRXNDd0MjU1MEtmYjFWYmI3SzsmZXg9MTYzMzMyNzU4MyZjdD0xNjMzMzI3NTgzODAzJnNyPWh0dHA-&xuid=Xm8Q8cCo5r8AAHCCMg0AAAAA&ctsv=m-ad240&seqid=be38bdb4-74a7-14a7-3439-b7f1ea8b4f33&seqtime=1633327583803&seqctx=gat3by5hZy5mdHlwZaEz&t=.gif', + 'cpm': 80, + 'creative_params': {}, + 'creativeid': 'ScaleOut_2146187', + 'dealid': '2134-132864_newformat_test', + 'h': 180, + 'landing_url': 'https://supership.jp/', + 'rparams': {}, + 'scheduleid': '1233323', + 'trackers': { + 'imp': [ + 'https://tg.socdm.com/bc/v3?b=Y2hzbT0yOTQsNGZiM2NkNWVpZD0xNDMwMzgmcG9zPVNTUExPQyZhZD0xMjMzMzIzLzI2MTA2MS4yNjU3OTkuMTIzMzMyMy8yMTY2NDY2LzE1NDQxMC8xNDMwMzg6U1NQTE9DOiovaWR4PTA7ZHNwaWQ9MTtkaTI9MjEzNC0xMzI4NjRfbmV3Zm9ybWF0X3Rlc3Q7ZnR5cGU9Mztwcj15TXB3O3ByYj15UTtwcm89eVE7cHJvYz1KUFk7Y3JkMnk9MTExLjkyO2NyeTJkPTAuMDA4OTM0OTUzNTM4MjQxNjAxMztwcnY9aWp6QVZtWW9wbmJUV1B0cWhtZEN1ZWRXNDd0MjU1MEtmYjFWYmI3SzsmZXg9MTYzMzMyNzU4MyZjdD0xNjMzMzI3NTgzODAzJnNyPWh0dHA-&xuid=Xm8Q8cCo5r8AAHCCMg0AAAAA&ctsv=m-ad240&seqid=be38bdb4-74a7-14a7-3439-b7f1ea8b4f33&seqtime=1633327583803&seqctx=gat3by5hZy5mdHlwZaEz&t=.gif' + ], + 'viewable_imp': [ + 'https://tg.socdm.com/aux/inview?creative_id=2166466&ctsv=m-ad240&extra_field=idx%3D0%3Bdspid%3D1%3Bdi2%3D2134-132864_newformat_test%3Bftype%3D3%3Bprb%3D0%3Bpro%3D0%3Bproc%3DJPY%3Bcrd2y%3D111.92%3Bcry2d%3D0.0089349535382416013%3Bsspm%3D0%3Bsom%3D0.2%3Borgm%3D0%3Btechm%3D0%3Bssp_margin%3D0%3Bso_margin%3D0.2%3Borg_margin%3D0%3Btech_margin%3D0%3Bbs%3Dclassic%3B&family_id=1233323&id=143038&loglocation_id=154410&lookupname=143038%3ASSPLOC%3A*&pos=SSPLOC&schedule_id=261061.265799.1233323&seqid=be38bdb4-74a7-14a7-3439-b7f1ea8b4f33&seqtime=1633327583803&xuid=Xm8Q8cCo5r8AAHCCMg0AAAAA' + ], + 'viewable_measured': [ + 'https://tg.socdm.com/aux/measured?creative_id=2166466&ctsv=m-ad240&extra_field=idx%3D0%3Bdspid%3D1%3Bdi2%3D2134-132864_newformat_test%3Bftype%3D3%3Bprb%3D0%3Bpro%3D0%3Bproc%3DJPY%3Bcrd2y%3D111.92%3Bcry2d%3D0.0089349535382416013%3Bsspm%3D0%3Bsom%3D0.2%3Borgm%3D0%3Btechm%3D0%3Bssp_margin%3D0%3Bso_margin%3D0.2%3Borg_margin%3D0%3Btech_margin%3D0%3Bbs%3Dclassic%3B&family_id=1233323&id=143038&loglocation_id=154410&lookupname=143038%3ASSPLOC%3A*&pos=SSPLOC&schedule_id=261061.265799.1233323&seqid=be38bdb4-74a7-14a7-3439-b7f1ea8b4f33&seqtime=1633327583803&xuid=Xm8Q8cCo5r8AAHCCMg0AAAAA' + ] + }, + 'ttl': 1000, + 'vastxml': '\n \n \n SOADS\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n 00:00:15\n \n \n \n \n \n \n \n \n \n \n \n \n https://i.socdm.com/a/2/2095/2091787/20210810043037-de3e74aec30f36.mp4\n https://i.socdm.com/a/2/2095/2091788/20210810043037-6dd368dc91d507.mp4\n https://i.socdm.com/a/2/2095/2091789/20210810043037-c8eb814ddd85c4.webm\n https://i.socdm.com/a/2/2095/2091790/20210810043037-0a7f74c40268ab.webm\n \n \n \n \n \n \n', + 'vcpm': 0, + 'w': 320, + 'weight': 1 + } + ], + 'rotation': '0', + 'scheduleid': '1233323', + 'sdktype': '0', + 'trackers': { + 'imp': [ + 'https://tg.socdm.com/bc/v3?b=Y2hzbT0yOTQsNGZiM2NkNWVpZD0xNDMwMzgmcG9zPVNTUExPQyZhZD0xMjMzMzIzLzI2MTA2MS4yNjU3OTkuMTIzMzMyMy8yMTY2NDY2LzE1NDQxMC8xNDMwMzg6U1NQTE9DOiovaWR4PTA7ZHNwaWQ9MTtkaTI9MjEzNC0xMzI4NjRfbmV3Zm9ybWF0X3Rlc3Q7ZnR5cGU9Mztwcj15TXB3O3ByYj15UTtwcm89eVE7cHJvYz1KUFk7Y3JkMnk9MTExLjkyO2NyeTJkPTAuMDA4OTM0OTUzNTM4MjQxNjAxMztwcnY9aWp6QVZtWW9wbmJUV1B0cWhtZEN1ZWRXNDd0MjU1MEtmYjFWYmI3SzsmZXg9MTYzMzMyNzU4MyZjdD0xNjMzMzI3NTgzODAzJnNyPWh0dHA-&xuid=Xm8Q8cCo5r8AAHCCMg0AAAAA&ctsv=m-ad240&seqid=be38bdb4-74a7-14a7-3439-b7f1ea8b4f33&seqtime=1633327583803&seqctx=gat3by5hZy5mdHlwZaEz&t=.gif' + ], + 'viewable_imp': [ + 'https://tg.socdm.com/aux/inview?creative_id=2166466&ctsv=m-ad240&extra_field=idx%3D0%3Bdspid%3D1%3Bdi2%3D2134-132864_newformat_test%3Bftype%3D3%3Bprb%3D0%3Bpro%3D0%3Bproc%3DJPY%3Bcrd2y%3D111.92%3Bcry2d%3D0.0089349535382416013%3Bsspm%3D0%3Bsom%3D0.2%3Borgm%3D0%3Btechm%3D0%3Bssp_margin%3D0%3Bso_margin%3D0.2%3Borg_margin%3D0%3Btech_margin%3D0%3Bbs%3Dclassic%3B&family_id=1233323&id=143038&loglocation_id=154410&lookupname=143038%3ASSPLOC%3A*&pos=SSPLOC&schedule_id=261061.265799.1233323&seqid=be38bdb4-74a7-14a7-3439-b7f1ea8b4f33&seqtime=1633327583803&xuid=Xm8Q8cCo5r8AAHCCMg0AAAAA' + ], + 'viewable_measured': [ + 'https://tg.socdm.com/aux/measured?creative_id=2166466&ctsv=m-ad240&extra_field=idx%3D0%3Bdspid%3D1%3Bdi2%3D2134-132864_newformat_test%3Bftype%3D3%3Bprb%3D0%3Bpro%3D0%3Bproc%3DJPY%3Bcrd2y%3D111.92%3Bcry2d%3D0.0089349535382416013%3Bsspm%3D0%3Bsom%3D0.2%3Borgm%3D0%3Btechm%3D0%3Bssp_margin%3D0%3Bso_margin%3D0.2%3Borg_margin%3D0%3Btech_margin%3D0%3Bbs%3Dclassic%3B&family_id=1233323&id=143038&loglocation_id=154410&lookupname=143038%3ASSPLOC%3A*&pos=SSPLOC&schedule_id=261061.265799.1233323&seqid=be38bdb4-74a7-14a7-3439-b7f1ea8b4f33&seqtime=1633327583803&xuid=Xm8Q8cCo5r8AAHCCMg0AAAAA' + ] + }, + 'ttl': 1000, + 'vastxml': '\n \n \n SOADS\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n 00:00:15\n \n \n \n \n \n \n \n \n \n \n \n \n https://i.socdm.com/a/2/2095/2091787/20210810043037-de3e74aec30f36.mp4\n https://i.socdm.com/a/2/2095/2091788/20210810043037-6dd368dc91d507.mp4\n https://i.socdm.com/a/2/2095/2091789/20210810043037-c8eb814ddd85c4.webm\n https://i.socdm.com/a/2/2095/2091790/20210810043037-0a7f74c40268ab.webm\n \n \n \n \n \n \n', + 'vcpm': 0, + 'w': 320, + } + }, + emptyAdomain: { + banner: { + ad: '
', + beacon: '', + cpm: 36.0008, + displaytype: '1', + ids: {}, + w: 320, + h: 100, + location_params: null, + locationid: '58279', + rotation: '0', + scheduleid: '512603', + sdktype: '0', + creativeid: '1k2kv35vsa5r', + dealid: 'fd5sa5fa7f', + ttl: 1000, + results: [ + {ad: '<\!DOCTYPE html>
'}, + ], + adomain: [] + }, + native: { + ad: '<\!DOCTYPE html>↵ ↵ ↵ ↵ ↵
↵ ', + beacon: '', + cpm: 36.0008, + displaytype: '1', + ids: {}, + location_params: null, + locationid: '58279', + adomain: [], + native_ad: { + assets: [ + { + data: { + label: 'accompanying_text', + value: 'AD' + }, + id: 501 + }, + { + data: { + label: 'optout_url', + value: 'https://supership.jp/optout/#' + }, + id: 502 + }, + { + data: { + ext: { + black_back: 'https://i.socdm.com/sdk/img/icon_adg_optout_26x26_white.png', + }, + label: 'information_icon_url', + value: 'https://i.socdm.com/sdk/img/icon_adg_optout_26x26_gray.png', + id: 503 + } + }, + { + id: 1, + required: 1, + title: {text: 'Title'} + }, + { + id: 2, + img: { + h: 250, + url: 'https://sdk-temp.s3-ap-northeast-1.amazonaws.com/adg-sample-ad/img/300x250.png', + w: 300 + }, + required: 1 + }, + { + id: 3, + img: { + h: 300, + url: 'https://placehold.jp/300x300.png', + w: 300 + }, + required: 1 + }, + { + data: {value: 'Description'}, + id: 5, + required: 0 + }, + { + data: {value: 'CTA'}, + id: 6, + required: 0 + }, + { + data: {value: 'Sponsored'}, + id: 4, + required: 0 + } + ], + imptrackers: ['https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1.gif'], + link: { + clicktrackers: [ + 'https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1_clicktracker_access.gif' + ], + url: 'https://supership.jp' + }, + }, + results: [ + {ad: 'Creative<\/body>'} + ], + rotation: '0', + scheduleid: '512603', + sdktype: '0', + creativeid: '1k2kv35vsa5r', + dealid: 'fd5sa5fa7f', + ttl: 1000 + } + }, + noAdomain: { + banner: { + ad: '
', + beacon: '', + cpm: 36.0008, + displaytype: '1', + ids: {}, + w: 320, + h: 100, + location_params: null, + locationid: '58279', + rotation: '0', + scheduleid: '512603', + sdktype: '0', + creativeid: '1k2kv35vsa5r', + dealid: 'fd5sa5fa7f', + ttl: 1000, + results: [ + {ad: '<\!DOCTYPE html>
'}, + ], + }, + native: { + ad: '<\!DOCTYPE html>↵ ↵ ↵ ↵ ↵
↵ ', + beacon: '', + cpm: 36.0008, + displaytype: '1', + ids: {}, + location_params: null, + locationid: '58279', + native_ad: { + assets: [ + { + data: { + label: 'accompanying_text', + value: 'AD' + }, + id: 501 + }, + { + data: { + label: 'optout_url', + value: 'https://supership.jp/optout/#' + }, + id: 502 + }, + { + data: { + ext: { + black_back: 'https://i.socdm.com/sdk/img/icon_adg_optout_26x26_white.png', + }, + label: 'information_icon_url', + value: 'https://i.socdm.com/sdk/img/icon_adg_optout_26x26_gray.png', + id: 503 + } + }, + { + id: 1, + required: 1, + title: {text: 'Title'} + }, + { + id: 2, + img: { + h: 250, + url: 'https://sdk-temp.s3-ap-northeast-1.amazonaws.com/adg-sample-ad/img/300x250.png', + w: 300 + }, + required: 1 + }, + { + id: 3, + img: { + h: 300, + url: 'https://placehold.jp/300x300.png', + w: 300 + }, + required: 1 + }, + { + data: {value: 'Description'}, + id: 5, + required: 0 + }, + { + data: {value: 'CTA'}, + id: 6, + required: 0 + }, + { + data: {value: 'Sponsored'}, + id: 4, + required: 0 + } + ], + imptrackers: ['https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1.gif'], + link: { + clicktrackers: [ + 'https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1_clicktracker_access.gif' + ], + url: 'https://supership.jp' + }, + }, + results: [ + {ad: 'Creative<\/body>'} + ], + rotation: '0', + scheduleid: '512603', + sdktype: '0', + creativeid: '1k2kv35vsa5r', + dealid: 'fd5sa5fa7f', + ttl: 1000 + } + } + }; + + const bidResponses = { + normal: { + banner: { + requestId: '2f6ac468a9c15e', + cpm: 36.0008, + width: 320, + height: 100, + creativeId: '1k2kv35vsa5r', + dealId: 'fd5sa5fa7f', + currency: 'JPY', + netRevenue: true, + ttl: 1000, + ad: '
', + adomain: ['advertiserdomain.com'] + }, + native: { + requestId: '2f6ac468a9c15e', + cpm: 36.0008, + width: 1, + height: 1, + creativeId: '1k2kv35vsa5r', + dealId: 'fd5sa5fa7f', + currency: 'JPY', + netRevenue: true, + ttl: 1000, + adomain: ['advertiserdomain.com'], + ad: '↵
', + native: { + title: 'Title', + image: { + url: 'https://sdk-temp.s3-ap-northeast-1.amazonaws.com/adg-sample-ad/img/300x250.png', + height: 250, + width: 300 + }, + icon: { + url: 'https://placehold.jp/300x300.png', + height: 300, + width: 300 + }, + sponsoredBy: 'Sponsored', + body: 'Description', + cta: 'CTA', + privacyLink: 'https://supership.jp/optout/#', + clickUrl: 'https://supership.jp', + clickTrackers: ['https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1_clicktracker_access.gif'], + impressionTrackers: ['https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1.gif'] + }, + mediaType: NATIVE + }, + upperBillboard: { + requestId: '2f6ac468a9c15e', + cpm: 80, + width: 320, + height: 180, + creativeId: 'ScaleOut_2146187', + dealId: '2134-132864_newformat_test', + currency: 'JPY', + netRevenue: true, + ttl: 1000, + ad: ``, + adomain: ['advertiserdomain.com'] + }, + }, + emptyAdomain: { + banner: { + requestId: '2f6ac468a9c15e', + cpm: 36.0008, + width: 320, + height: 100, + creativeId: '1k2kv35vsa5r', + dealId: 'fd5sa5fa7f', + currency: 'JPY', + netRevenue: true, + ttl: 1000, + ad: '
', + adomain: [] + }, + native: { + requestId: '2f6ac468a9c15e', + cpm: 36.0008, + width: 1, + height: 1, + creativeId: '1k2kv35vsa5r', + dealId: 'fd5sa5fa7f', + currency: 'JPY', + netRevenue: true, + ttl: 1000, + adomain: [], + ad: '↵
', + native: { + title: 'Title', + image: { + url: 'https://sdk-temp.s3-ap-northeast-1.amazonaws.com/adg-sample-ad/img/300x250.png', + height: 250, + width: 300 + }, + icon: { + url: 'https://placehold.jp/300x300.png', + height: 300, + width: 300 + }, + sponsoredBy: 'Sponsored', + body: 'Description', + cta: 'CTA', + privacyLink: 'https://supership.jp/optout/#', + clickUrl: 'https://supership.jp', + clickTrackers: ['https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1_clicktracker_access.gif'], + impressionTrackers: ['https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1.gif'] + }, + mediaType: NATIVE + }, + }, + noAdomain: { + banner: { + requestId: '2f6ac468a9c15e', + cpm: 36.0008, + width: 320, + height: 100, + creativeId: '1k2kv35vsa5r', + dealId: 'fd5sa5fa7f', + currency: 'JPY', + netRevenue: true, + ttl: 1000, + ad: '
', + }, + native: { + requestId: '2f6ac468a9c15e', + cpm: 36.0008, + width: 1, + height: 1, + creativeId: '1k2kv35vsa5r', + dealId: 'fd5sa5fa7f', + currency: 'JPY', + netRevenue: true, + ttl: 1000, + ad: '↵
', + native: { + title: 'Title', + image: { + url: 'https://sdk-temp.s3-ap-northeast-1.amazonaws.com/adg-sample-ad/img/300x250.png', + height: 250, + width: 300 + }, + icon: { + url: 'https://placehold.jp/300x300.png', + height: 300, + width: 300 + }, + sponsoredBy: 'Sponsored', + body: 'Description', + cta: 'CTA', + privacyLink: 'https://supership.jp/optout/#', + clickUrl: 'https://supership.jp', + clickTrackers: ['https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1_clicktracker_access.gif'], + impressionTrackers: ['https://adg-dummy-dsp.s3-ap-northeast-1.amazonaws.com/1x1.gif'] + }, + mediaType: NATIVE + } + }, + }; + + it('no bid responses', function () { + const result = spec.interpretResponse({body: serverResponse.noAd}, bidRequests.banner); + expect(result.length).to.equal(0); + }); + + it('handles ADGBrowserM responses', function () { + config.setConfig({ + currency: { + adServerCurrency: 'JPY' + } + }); + const result = spec.interpretResponse({body: serverResponse.normal.upperBillboard}, bidRequests.upperBillboard)[0]; + expect(result.requestId).to.equal(bidResponses.normal.upperBillboard.requestId); + expect(result.width).to.equal(bidResponses.normal.upperBillboard.width); + expect(result.height).to.equal(bidResponses.normal.upperBillboard.height); + expect(result.creativeId).to.equal(bidResponses.normal.upperBillboard.creativeId); + expect(result.dealId).to.equal(bidResponses.normal.upperBillboard.dealId); + expect(result.currency).to.equal(bidResponses.normal.upperBillboard.currency); + expect(result.netRevenue).to.equal(bidResponses.normal.upperBillboard.netRevenue); + expect(result.ttl).to.equal(bidResponses.normal.upperBillboard.ttl); + expect(result.ad).to.equal(bidResponses.normal.upperBillboard.ad); + }); + + it('handles banner responses for empty adomain', function () { + const result = spec.interpretResponse({body: serverResponse.emptyAdomain.banner}, bidRequests.banner)[0]; + expect(result.requestId).to.equal(bidResponses.emptyAdomain.banner.requestId); + expect(result.width).to.equal(bidResponses.emptyAdomain.banner.width); + expect(result.height).to.equal(bidResponses.emptyAdomain.banner.height); + expect(result.creativeId).to.equal(bidResponses.emptyAdomain.banner.creativeId); + expect(result.dealId).to.equal(bidResponses.emptyAdomain.banner.dealId); + expect(result.currency).to.equal(bidResponses.emptyAdomain.banner.currency); + expect(result.netRevenue).to.equal(bidResponses.emptyAdomain.banner.netRevenue); + expect(result.ttl).to.equal(bidResponses.emptyAdomain.banner.ttl); + expect(result.ad).to.equal(bidResponses.emptyAdomain.banner.ad); + expect(result).to.not.have.any.keys('meta'); + expect(result).to.not.have.any.keys('advertiserDomains'); + }); + + it('handles native responses for empty adomain', function () { + const result = spec.interpretResponse({body: serverResponse.emptyAdomain.native}, bidRequests.native)[0]; + expect(result.requestId).to.equal(bidResponses.emptyAdomain.native.requestId); + expect(result.width).to.equal(bidResponses.emptyAdomain.native.width); + expect(result.height).to.equal(bidResponses.emptyAdomain.native.height); + expect(result.creativeId).to.equal(bidResponses.emptyAdomain.native.creativeId); + expect(result.dealId).to.equal(bidResponses.emptyAdomain.native.dealId); + expect(result.currency).to.equal(bidResponses.emptyAdomain.native.currency); + expect(result.netRevenue).to.equal(bidResponses.emptyAdomain.native.netRevenue); + expect(result.ttl).to.equal(bidResponses.emptyAdomain.native.ttl); + expect(result.native.title).to.equal(bidResponses.emptyAdomain.native.native.title); + expect(result.native.image.url).to.equal(bidResponses.emptyAdomain.native.native.image.url); + expect(result.native.image.height).to.equal(bidResponses.emptyAdomain.native.native.image.height); + expect(result.native.image.width).to.equal(bidResponses.emptyAdomain.native.native.image.width); + expect(result.native.icon.url).to.equal(bidResponses.emptyAdomain.native.native.icon.url); + expect(result.native.icon.width).to.equal(bidResponses.emptyAdomain.native.native.icon.width); + expect(result.native.icon.height).to.equal(bidResponses.emptyAdomain.native.native.icon.height); + expect(result.native.sponsoredBy).to.equal(bidResponses.emptyAdomain.native.native.sponsoredBy); + expect(result.native.body).to.equal(bidResponses.emptyAdomain.native.native.body); + expect(result.native.cta).to.equal(bidResponses.emptyAdomain.native.native.cta); + expect(decodeURIComponent(result.native.privacyLink)).to.equal(bidResponses.emptyAdomain.native.native.privacyLink); + expect(result.native.clickUrl).to.equal(bidResponses.emptyAdomain.native.native.clickUrl); + expect(result.native.impressionTrackers[0]).to.equal(bidResponses.emptyAdomain.native.native.impressionTrackers[0]); + expect(result.native.clickTrackers[0]).to.equal(bidResponses.emptyAdomain.native.native.clickTrackers[0]); + expect(result.mediaType).to.equal(bidResponses.emptyAdomain.native.mediaType); + expect(result).to.not.have.any.keys('meta'); + expect(result).to.not.have.any.keys('advertiserDomains'); + }); + + it('handles banner responses for no adomain', function () { + const result = spec.interpretResponse({body: serverResponse.noAdomain.banner}, bidRequests.banner)[0]; + expect(result.requestId).to.equal(bidResponses.noAdomain.banner.requestId); + expect(result.width).to.equal(bidResponses.noAdomain.banner.width); + expect(result.height).to.equal(bidResponses.noAdomain.banner.height); + expect(result.creativeId).to.equal(bidResponses.noAdomain.banner.creativeId); + expect(result.dealId).to.equal(bidResponses.noAdomain.banner.dealId); + expect(result.currency).to.equal(bidResponses.noAdomain.banner.currency); + expect(result.netRevenue).to.equal(bidResponses.noAdomain.banner.netRevenue); + expect(result.ttl).to.equal(bidResponses.noAdomain.banner.ttl); + expect(result.ad).to.equal(bidResponses.noAdomain.banner.ad); + expect(result).to.not.have.any.keys('meta'); + expect(result).to.not.have.any.keys('advertiserDomains'); + }); + + it('handles native responses for no adomain', function () { + const result = spec.interpretResponse({body: serverResponse.noAdomain.native}, bidRequests.native)[0]; + expect(result.requestId).to.equal(bidResponses.noAdomain.native.requestId); + expect(result.width).to.equal(bidResponses.noAdomain.native.width); + expect(result.height).to.equal(bidResponses.noAdomain.native.height); + expect(result.creativeId).to.equal(bidResponses.noAdomain.native.creativeId); + expect(result.dealId).to.equal(bidResponses.noAdomain.native.dealId); + expect(result.currency).to.equal(bidResponses.noAdomain.native.currency); + expect(result.netRevenue).to.equal(bidResponses.noAdomain.native.netRevenue); + expect(result.ttl).to.equal(bidResponses.noAdomain.native.ttl); + expect(result.native.title).to.equal(bidResponses.noAdomain.native.native.title); + expect(result.native.image.url).to.equal(bidResponses.noAdomain.native.native.image.url); + expect(result.native.image.height).to.equal(bidResponses.noAdomain.native.native.image.height); + expect(result.native.image.width).to.equal(bidResponses.noAdomain.native.native.image.width); + expect(result.native.icon.url).to.equal(bidResponses.noAdomain.native.native.icon.url); + expect(result.native.icon.width).to.equal(bidResponses.noAdomain.native.native.icon.width); + expect(result.native.icon.height).to.equal(bidResponses.noAdomain.native.native.icon.height); + expect(result.native.sponsoredBy).to.equal(bidResponses.noAdomain.native.native.sponsoredBy); + expect(result.native.body).to.equal(bidResponses.noAdomain.native.native.body); + expect(result.native.cta).to.equal(bidResponses.noAdomain.native.native.cta); + expect(decodeURIComponent(result.native.privacyLink)).to.equal(bidResponses.noAdomain.native.native.privacyLink); + expect(result.native.clickUrl).to.equal(bidResponses.noAdomain.native.native.clickUrl); + expect(result.native.impressionTrackers[0]).to.equal(bidResponses.noAdomain.native.native.impressionTrackers[0]); + expect(result.native.clickTrackers[0]).to.equal(bidResponses.noAdomain.native.native.clickTrackers[0]); + expect(result.mediaType).to.equal(bidResponses.noAdomain.native.mediaType); + expect(result).to.not.have.any.keys('meta'); + expect(result).to.not.have.any.keys('advertiserDomains'); + }); + }); +});