From d5cf40c9b915231991c7e7e10bd3636c97761227 Mon Sep 17 00:00:00 2001 From: Dejan Strbac Date: Tue, 8 May 2018 18:03:35 +0200 Subject: [PATCH 1/6] Aardvark v1.0 + Add GDPR support --- modules/aardvarkBidAdapter.js | 154 ++++++++++++ modules/aardvarkBidAdapter.md | 30 +++ test/spec/modules/aardvarkBidAdapter_spec.js | 239 +++++++++++++++++++ 3 files changed, 423 insertions(+) create mode 100644 modules/aardvarkBidAdapter.js create mode 100644 modules/aardvarkBidAdapter.md create mode 100644 test/spec/modules/aardvarkBidAdapter_spec.js diff --git a/modules/aardvarkBidAdapter.js b/modules/aardvarkBidAdapter.js new file mode 100644 index 00000000000..47946fcf00b --- /dev/null +++ b/modules/aardvarkBidAdapter.js @@ -0,0 +1,154 @@ +import * as utils from 'src/utils'; +import {registerBidder} from 'src/adapters/bidderFactory'; + +const BIDDER_CODE = 'aardvark'; +const DEFAULT_ENDPOINT = 'bidder.rtk.io'; +const SYNC_ENDPOINT = 'sync.rtk.io'; +const AARDVARK_TTL = 300; +const AARDVARK_CURRENCY = 'USD'; + +var hasSynced = false; + +export function resetUserSync() { + hasSynced = false; +} + +export const spec = { + code: BIDDER_CODE, + + isBidRequestValid: function(bid) { + return ((typeof bid.params.ai === 'string') && !!bid.params.ai.length && + (typeof bid.params.sc === 'string') && !!bid.params.sc.length); + }, + + buildRequests: function(validBidRequests, bidderRequest) { + var auctionCodes = []; + var requests = []; + var requestsMap = {}; + var referer = utils.getTopWindowUrl(); + var pageCategories = []; + + if (window.rtkcategories && Array.isArray(window.rtkcategories)) { + pageCategories = window.rtkcategories; + } + + utils._each(validBidRequests, function(b) { + var rMap = requestsMap[b.params.ai]; + if (!rMap) { + rMap = { + shortCodes: [], + payload: { + version: 1, + jsonp: false, + rtkreferer: referer + }, + endpoint: DEFAULT_ENDPOINT + }; + + if (pageCategories && pageCategories.length) { + rMap.payload.categories = pageCategories.slice(0); + } + + if (b.params.categories && b.params.categories.length) { + rMap.payload.categories = rMap.payload.categories || [] + utils._each(b.params.categories, function(cat) { + rMap.payload.categories.push(cat); + }); + } + + if (bidderRequest && bidderRequest.gdprConsent) { + rMap.payload.gdpr = bidderRequest.gdprConsent.gdprApplies; + rMap.payload.consent = bidderRequest.gdprConsent.consentString; + } + + requestsMap[b.params.ai] = rMap; + auctionCodes.push(b.params.ai); + } + + rMap.shortCodes.push(b.params.sc); + rMap.payload[b.params.sc] = b.bidId; + + if ((typeof b.params.host === 'string') && b.params.host.length && + (b.params.host !== rMap.endpoint)) { + rMap.endpoint = b.params.host; + } + }); + + utils._each(auctionCodes, function(auctionId) { + var req = requestsMap[auctionId]; + requests.push({ + method: 'GET', + url: `//${req.endpoint}/${auctionId}/${req.shortCodes.join('_')}/aardvark`, + data: req.payload, + bidderRequest + }); + }); + + return requests; + }, + + interpretResponse: function(serverResponse, bidRequest) { + var bidResponses = []; + utils._each(serverResponse.body, function(rawBid) { + if (!rawBid.cpm) { + return; + } + + var bidResponse = { + requestId: rawBid.cid, + cpm: rawBid.cpm, + width: rawBid.width || 0, + height: rawBid.height || 0, + currency: rawBid.currency ? rawBid.currency : AARDVARK_CURRENCY, + netRevenue: rawBid.netRevenue ? rawBid.netRevenue : true, + ttl: rawBid.ttl ? rawBid.ttl : AARDVARK_TTL, + exchange: rawBid.ex, + creativeId: rawBid.creativeId || 0 + }; + + if (rawBid.hasOwnProperty('dealId')) { + bidResponse.dealId = rawBid.dealId + } + + switch (rawBid.media) { + case 'banner': + bidResponse.ad = rawBid.adm + utils.createTrackPixelHtml(decodeURIComponent(rawBid.nurl)); + break; + + default: + return utils.logError('bad Aardvark response (media)', rawBid); + } + + bidResponses.push(bidResponse); + }); + + return bidResponses; + }, + + getUserSyncs: function(syncOptions, serverResponses, gdprConsent) { + const syncs = []; + var url = '//' + SYNC_ENDPOINT + '/cs'; + var gdprApplies = true; + if (typeof gdprConsent.gdprApplies === 'boolean') { + gdprApplies = gdprConsent.gdprApplies; + } + + if (syncOptions.iframeEnabled) { + if (!hasSynced) { + hasSynced = true; + if (gdprApplies) { + url = url + '?g=1&c=' + encodeURIComponent(gdprConsent.consentString); + } + syncs.push({ + type: 'iframe', + url: url + }); + } + } else { + utils.logWarn('Aardvark: Please enable iframe based user sync.'); + } + return syncs; + } +}; + +registerBidder(spec); diff --git a/modules/aardvarkBidAdapter.md b/modules/aardvarkBidAdapter.md new file mode 100644 index 00000000000..79fca52f081 --- /dev/null +++ b/modules/aardvarkBidAdapter.md @@ -0,0 +1,30 @@ +# Overview + +**Module Name**: Aardvark Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: chris@rtk.io + +# Description + +Module that connects to a RTK.io Ad Units to fetch bids. + +# Test Parameters +``` + var adUnits = [{ + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]], + } + }, + code: 'div-gpt-ad-1460505748561-0', + + bids: [{ + bidder: 'aardvark', + params: { + ai: '7Dwb', + sc: 'WygO' + } + }] + + }]; +``` \ No newline at end of file diff --git a/test/spec/modules/aardvarkBidAdapter_spec.js b/test/spec/modules/aardvarkBidAdapter_spec.js new file mode 100644 index 00000000000..eeadfce9519 --- /dev/null +++ b/test/spec/modules/aardvarkBidAdapter_spec.js @@ -0,0 +1,239 @@ +import { expect } from 'chai'; +import { spec } from 'modules/aardvarkBidAdapter'; + +describe('aardvarkAdapterTest', () => { + describe('forming valid bidRequests', () => { + it('should accept valid bidRequests', () => { + expect(spec.isBidRequestValid({ + bidder: 'aardvark', + params: { + ai: 'xiby', + sc: 'TdAx', + }, + sizes: [[300, 250]] + })).to.equal(true); + }); + + it('should reject invalid bidRequests', () => { + expect(spec.isBidRequestValid({ + bidder: 'aardvark', + params: { + ai: 'xiby', + }, + sizes: [[300, 250]] + })).to.equal(false); + }); + }); + + describe('executing network requests', () => { + const bidRequests = [{ + bidder: 'aardvark', + params: { + ai: 'xiby', + sc: 'TdAx', + }, + adUnitCode: 'aaa', + transactionId: '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', + sizes: [300, 250], + bidId: '1abgs362e0x48a8', + bidderRequestId: '70deaff71c281d', + auctionId: '5c66da22-426a-4bac-b153-77360bef5337' + }, + { + bidder: 'aardvark', + params: { + ai: 'xiby', + sc: 'RAZd', + host: 'adzone.pub.com' + }, + adUnitCode: 'bbb', + transactionId: '193995b4-7122-4739-959b-2463282a138b', + sizes: [[800, 600]], + bidId: '22aidtbx5eabd9', + bidderRequestId: '70deaff71c281d', + auctionId: 'e97cafd0-ebfc-4f5c-b7c9-baa0fd335a4a' + }]; + + it('should use HTTP GET method', () => { + const requests = spec.buildRequests(bidRequests); + requests.forEach(function(requestItem) { + expect(requestItem.method).to.equal('GET'); + }); + }); + + it('should call the correct bidRequest url', () => { + const requests = spec.buildRequests(bidRequests); + expect(requests.length).to.equal(1); + expect(requests[0].url).to.match(new RegExp('^\/\/adzone.pub.com/xiby/TdAx_RAZd/aardvark\?')); + }); + + it('should have correct data', () => { + const requests = spec.buildRequests(bidRequests); + expect(requests.length).to.equal(1); + expect(requests[0].data.version).to.equal(1); + expect(requests[0].data.jsonp).to.equal(false); + expect(requests[0].data.TdAx).to.equal('1abgs362e0x48a8'); + expect(requests[0].data.rtkreferer).to.not.be.undefined; + expect(requests[0].data.RAZd).to.equal('22aidtbx5eabd9'); + }); + }); + + describe('splitting multi-auction ad units into own requests', () => { + const bidRequests = [{ + bidder: 'aardvark', + params: { + ai: 'Toby', + sc: 'TdAx', + categories: ['cat1', 'cat2'] + }, + adUnitCode: 'aaa', + transactionId: '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', + sizes: [300, 250], + bidId: '1abgs362e0x48a8', + bidderRequestId: '70deaff71c281d', + auctionId: '5c66da22-426a-4bac-b153-77360bef5337' + }, + { + bidder: 'aardvark', + params: { + ai: 'xiby', + sc: 'RAZd', + host: 'adzone.pub.com' + }, + adUnitCode: 'bbb', + transactionId: '193995b4-7122-4739-959b-2463282a138b', + sizes: [[800, 600]], + bidId: '22aidtbx5eabd9', + bidderRequestId: '70deaff71c281d', + auctionId: 'e97cafd0-ebfc-4f5c-b7c9-baa0fd335a4a' + }]; + + it('should use HTTP GET method', () => { + const requests = spec.buildRequests(bidRequests); + requests.forEach(function(requestItem) { + expect(requestItem.method).to.equal('GET'); + }); + }); + + it('should call the correct bidRequest urls for each auction', () => { + const requests = spec.buildRequests(bidRequests); + expect(requests[0].url).to.match(new RegExp('^\/\/bidder.rtk.io/Toby/TdAx/aardvark\?')); + expect(requests[0].data.categories.length).to.equal(2); + expect(requests[1].url).to.match(new RegExp('^\/\/adzone.pub.com/xiby/RAZd/aardvark\?')); + }); + + it('should have correct data', () => { + const requests = spec.buildRequests(bidRequests); + expect(requests.length).to.equal(2); + expect(requests[0].data.version).to.equal(1); + expect(requests[0].data.jsonp).to.equal(false); + expect(requests[0].data.TdAx).to.equal('1abgs362e0x48a8'); + expect(requests[0].data.rtkreferer).to.not.be.undefined; + expect(requests[0].data.RAZd).to.be.undefined; + expect(requests[1].data.version).to.equal(1); + expect(requests[1].data.jsonp).to.equal(false); + expect(requests[1].data.TdAx).to.be.undefined; + expect(requests[1].data.rtkreferer).to.not.be.undefined; + expect(requests[1].data.RAZd).to.equal('22aidtbx5eabd9'); + }); + }); + + describe('GDPR conformity', () => { + const bidRequests = [{ + bidder: 'aardvark', + params: { + ai: 'xiby', + sc: 'TdAx', + }, + adUnitCode: 'aaa', + transactionId: '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', + sizes: [300, 250], + bidId: '1abgs362e0x48a8', + bidderRequestId: '70deaff71c281d', + auctionId: '5c66da22-426a-4bac-b153-77360bef5337' + }]; + + const bidderRequest = { + gdprConsent: { + consentString: 'awefasdfwefasdfasd', + gdprApplies: true + } + }; + + it('should transmit correct data', () => { + const requests = spec.buildRequests(bidRequests, bidderRequest); + expect(requests.length).to.equal(1); + expect(requests[0].data.gdpr).to.equal(true); + expect(requests[0].data.consent).to.equal('awefasdfwefasdfasd'); + }); + }); + + describe('interpretResponse', () => { + it('should handle bid responses', () => { + const serverResponse = { + body: [ + { + media: 'banner', + nurl: 'http://www.nurl.com/0', + cpm: 0.09, + width: 300, + height: 250, + cid: '22aidtbx5eabd9', + adm: '', + dealId: 'dealing', + ttl: 200, + ex: 'exchange1' + }, + { + media: 'banner', + nurl: 'http://www.nurl.com/1', + cpm: 0.09, + width: 300, + height: 250, + cid: '1abgs362e0x48a8', + adm: '', + ttl: 200, + ex: 'exchange2' + } + ], + headers: {} + }; + + const result = spec.interpretResponse(serverResponse, {}); + expect(result.length).to.equal(2); + + expect(result[0].requestId).to.equal('22aidtbx5eabd9'); + expect(result[0].cpm).to.equal(0.09); + expect(result[0].width).to.equal(300); + expect(result[0].height).to.equal(250); + expect(result[0].currency).to.equal('USD'); + expect(result[0].ttl).to.equal(200); + expect(result[0].dealId).to.equal('dealing'); + expect(result[0].exchange).to.equal('exchange1'); + expect(result[0].ad).to.not.be.undefined; + + expect(result[1].requestId).to.equal('1abgs362e0x48a8'); + expect(result[1].cpm).to.equal(0.09); + expect(result[1].width).to.equal(300); + expect(result[1].height).to.equal(250); + expect(result[1].currency).to.equal('USD'); + expect(result[1].ttl).to.equal(200); + expect(result[1].exchange).to.equal('exchange2'); + expect(result[1].ad).to.not.be.undefined; + }); + + it('should handle nobid responses', () => { + var emptyResponse = { + nurl: '', + cid: '9e5a09319e18f1', + media: 'banner', + error: 'No bids received for 9DgF', + adm: '', + id: '9DgF', + cpm: '0.00' + }; + var result = spec.interpretResponse({ body: emptyResponse }, {}); + expect(result.length).to.equal(0); + }); + }); +}); From e9093f71a2ab498339877d31128aa6065044e25b Mon Sep 17 00:00:00 2001 From: Dejan Strbac Date: Thu, 10 May 2018 16:06:24 +0200 Subject: [PATCH 2/6] required modifications --- modules/aardvarkBidAdapter.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/aardvarkBidAdapter.js b/modules/aardvarkBidAdapter.js index 47946fcf00b..d7a62658fb4 100644 --- a/modules/aardvarkBidAdapter.js +++ b/modules/aardvarkBidAdapter.js @@ -7,7 +7,7 @@ const SYNC_ENDPOINT = 'sync.rtk.io'; const AARDVARK_TTL = 300; const AARDVARK_CURRENCY = 'USD'; -var hasSynced = false; +let hasSynced = false; export function resetUserSync() { hasSynced = false; @@ -28,8 +28,8 @@ export const spec = { var referer = utils.getTopWindowUrl(); var pageCategories = []; - if (window.rtkcategories && Array.isArray(window.rtkcategories)) { - pageCategories = window.rtkcategories; + if (window.top.rtkcategories && Array.isArray(window.top.rtkcategories)) { + pageCategories = window.top.rtkcategories; } utils._each(validBidRequests, function(b) { @@ -57,7 +57,10 @@ export const spec = { } if (bidderRequest && bidderRequest.gdprConsent) { - rMap.payload.gdpr = bidderRequest.gdprConsent.gdprApplies; + rMap.payload.gdpr = false; + if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { + rMap.payload.gdpr = bidderRequest.gdprConsent.gdprApplies; + } rMap.payload.consent = bidderRequest.gdprConsent.consentString; } @@ -102,7 +105,6 @@ export const spec = { currency: rawBid.currency ? rawBid.currency : AARDVARK_CURRENCY, netRevenue: rawBid.netRevenue ? rawBid.netRevenue : true, ttl: rawBid.ttl ? rawBid.ttl : AARDVARK_TTL, - exchange: rawBid.ex, creativeId: rawBid.creativeId || 0 }; @@ -128,8 +130,8 @@ export const spec = { getUserSyncs: function(syncOptions, serverResponses, gdprConsent) { const syncs = []; var url = '//' + SYNC_ENDPOINT + '/cs'; - var gdprApplies = true; - if (typeof gdprConsent.gdprApplies === 'boolean') { + var gdprApplies = false; + if (gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean')) { gdprApplies = gdprConsent.gdprApplies; } From 048f0bdc15a930702220f99a15d748d0388ad8be Mon Sep 17 00:00:00 2001 From: Dejan Strbac Date: Thu, 10 May 2018 16:43:02 +0200 Subject: [PATCH 3/6] cover case where gdprConsent data is not present --- modules/aardvarkBidAdapter.js | 4 ++- test/spec/modules/aardvarkBidAdapter_spec.js | 31 +++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/modules/aardvarkBidAdapter.js b/modules/aardvarkBidAdapter.js index d7a62658fb4..85359f5e1f8 100644 --- a/modules/aardvarkBidAdapter.js +++ b/modules/aardvarkBidAdapter.js @@ -61,7 +61,9 @@ export const spec = { if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { rMap.payload.gdpr = bidderRequest.gdprConsent.gdprApplies; } - rMap.payload.consent = bidderRequest.gdprConsent.consentString; + if (rMap.payload.gdpr) { + rMap.payload.consent = bidderRequest.gdprConsent.consentString; + } } requestsMap[b.params.ai] = rMap; diff --git a/test/spec/modules/aardvarkBidAdapter_spec.js b/test/spec/modules/aardvarkBidAdapter_spec.js index eeadfce9519..402dda6eab0 100644 --- a/test/spec/modules/aardvarkBidAdapter_spec.js +++ b/test/spec/modules/aardvarkBidAdapter_spec.js @@ -168,6 +168,33 @@ describe('aardvarkAdapterTest', () => { }); }); + describe('GDPR absence conformity', () => { + const bidRequests = [{ + bidder: 'aardvark', + params: { + ai: 'xiby', + sc: 'TdAx', + }, + adUnitCode: 'aaa', + transactionId: '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', + sizes: [300, 250], + bidId: '1abgs362e0x48a8', + bidderRequestId: '70deaff71c281d', + auctionId: '5c66da22-426a-4bac-b153-77360bef5337' + }]; + + const bidderRequest = { + gdprConsent: undefined + }; + + it('should transmit correct data', () => { + const requests = spec.buildRequests(bidRequests, bidderRequest); + expect(requests.length).to.equal(1); + expect(requests[0].data.gdpr).to.be.undefined; + expect(requests[0].data.consent).to.be.undefined; + }); + }); + describe('interpretResponse', () => { it('should handle bid responses', () => { const serverResponse = { @@ -182,7 +209,6 @@ describe('aardvarkAdapterTest', () => { adm: '', dealId: 'dealing', ttl: 200, - ex: 'exchange1' }, { media: 'banner', @@ -193,7 +219,6 @@ describe('aardvarkAdapterTest', () => { cid: '1abgs362e0x48a8', adm: '', ttl: 200, - ex: 'exchange2' } ], headers: {} @@ -209,7 +234,6 @@ describe('aardvarkAdapterTest', () => { expect(result[0].currency).to.equal('USD'); expect(result[0].ttl).to.equal(200); expect(result[0].dealId).to.equal('dealing'); - expect(result[0].exchange).to.equal('exchange1'); expect(result[0].ad).to.not.be.undefined; expect(result[1].requestId).to.equal('1abgs362e0x48a8'); @@ -218,7 +242,6 @@ describe('aardvarkAdapterTest', () => { expect(result[1].height).to.equal(250); expect(result[1].currency).to.equal('USD'); expect(result[1].ttl).to.equal(200); - expect(result[1].exchange).to.equal('exchange2'); expect(result[1].ad).to.not.be.undefined; }); From c52e1d7a6ee21a743e36c044cc79f611c0209ae6 Mon Sep 17 00:00:00 2001 From: Dejan Strbac Date: Thu, 10 May 2018 19:11:56 +0200 Subject: [PATCH 4/6] demo auction update --- modules/aardvarkBidAdapter.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/aardvarkBidAdapter.md b/modules/aardvarkBidAdapter.md index 79fca52f081..9f7a128b6f3 100644 --- a/modules/aardvarkBidAdapter.md +++ b/modules/aardvarkBidAdapter.md @@ -13,7 +13,7 @@ Module that connects to a RTK.io Ad Units to fetch bids. var adUnits = [{ mediaTypes: { banner: { - sizes: [[300, 250], [300,600]], + sizes: [[300, 250]], } }, code: 'div-gpt-ad-1460505748561-0', @@ -21,10 +21,10 @@ Module that connects to a RTK.io Ad Units to fetch bids. bids: [{ bidder: 'aardvark', params: { - ai: '7Dwb', - sc: 'WygO' + ai: '0000', + sc: '1234' } }] }]; -``` \ No newline at end of file +``` From 07184460aba43b8525fc398f62132ae512e8027b Mon Sep 17 00:00:00 2001 From: Dejan Strbac Date: Fri, 11 May 2018 14:32:30 +0200 Subject: [PATCH 5/6] ignore empty bids --- modules/aardvarkBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/aardvarkBidAdapter.js b/modules/aardvarkBidAdapter.js index 85359f5e1f8..905a500edc9 100644 --- a/modules/aardvarkBidAdapter.js +++ b/modules/aardvarkBidAdapter.js @@ -95,7 +95,7 @@ export const spec = { interpretResponse: function(serverResponse, bidRequest) { var bidResponses = []; utils._each(serverResponse.body, function(rawBid) { - if (!rawBid.cpm) { + if (!rawBid.cpm || !(+rawBid.cpm)) { return; } From 1fe7e689e0c3a26f893356809e41ac666c1a3ac3 Mon Sep 17 00:00:00 2001 From: Dejan Strbac Date: Mon, 14 May 2018 14:14:53 +0200 Subject: [PATCH 6/6] accept empty bids --- modules/aardvarkBidAdapter.js | 11 ++++++----- test/spec/modules/aardvarkBidAdapter_spec.js | 14 ++++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/modules/aardvarkBidAdapter.js b/modules/aardvarkBidAdapter.js index 905a500edc9..7d358864b35 100644 --- a/modules/aardvarkBidAdapter.js +++ b/modules/aardvarkBidAdapter.js @@ -94,14 +94,15 @@ export const spec = { interpretResponse: function(serverResponse, bidRequest) { var bidResponses = []; - utils._each(serverResponse.body, function(rawBid) { - if (!rawBid.cpm || !(+rawBid.cpm)) { - return; - } + if (!Array.isArray(serverResponse.body)) { + serverResponse.body = [serverResponse.body]; + } + + utils._each(serverResponse.body, function(rawBid) { var bidResponse = { requestId: rawBid.cid, - cpm: rawBid.cpm, + cpm: rawBid.cpm || 0, width: rawBid.width || 0, height: rawBid.height || 0, currency: rawBid.currency ? rawBid.currency : AARDVARK_CURRENCY, diff --git a/test/spec/modules/aardvarkBidAdapter_spec.js b/test/spec/modules/aardvarkBidAdapter_spec.js index 402dda6eab0..d2b9cbc0fa8 100644 --- a/test/spec/modules/aardvarkBidAdapter_spec.js +++ b/test/spec/modules/aardvarkBidAdapter_spec.js @@ -213,7 +213,7 @@ describe('aardvarkAdapterTest', () => { { media: 'banner', nurl: 'http://www.nurl.com/1', - cpm: 0.09, + cpm: 0.19, width: 300, height: 250, cid: '1abgs362e0x48a8', @@ -237,7 +237,7 @@ describe('aardvarkAdapterTest', () => { expect(result[0].ad).to.not.be.undefined; expect(result[1].requestId).to.equal('1abgs362e0x48a8'); - expect(result[1].cpm).to.equal(0.09); + expect(result[1].cpm).to.equal(0.19); expect(result[1].width).to.equal(300); expect(result[1].height).to.equal(250); expect(result[1].currency).to.equal('USD'); @@ -246,17 +246,19 @@ describe('aardvarkAdapterTest', () => { }); it('should handle nobid responses', () => { - var emptyResponse = { + var emptyResponse = [{ nurl: '', cid: '9e5a09319e18f1', media: 'banner', error: 'No bids received for 9DgF', adm: '', id: '9DgF', - cpm: '0.00' - }; + cpm: 0.00 + }]; + var result = spec.interpretResponse({ body: emptyResponse }, {}); - expect(result.length).to.equal(0); + expect(result.length).to.equal(1); + expect(result[0].cpm).to.equal(0.0); }); }); });