From bea6ab011b7a1f503f1a5d20336052c2887890ba Mon Sep 17 00:00:00 2001 From: LeoWu Date: Thu, 3 May 2018 20:33:19 +0800 Subject: [PATCH] add feature to bridgewellBidAdapter (#2480) * [FEAT] support mediaTypes.banner.sizes * [FEAT] init native * [FEAT] init bw version * [FEAT] hoist bidder version --- modules/bridgewellBidAdapter.js | 125 ++- modules/bridgewellBidAdapter.md | 37 + .../spec/modules/bridgewellBidAdapter_spec.js | 738 +++++++++++++++++- 3 files changed, 895 insertions(+), 5 deletions(-) diff --git a/modules/bridgewellBidAdapter.js b/modules/bridgewellBidAdapter.js index 712b00ec51a..c57ac85bc09 100644 --- a/modules/bridgewellBidAdapter.js +++ b/modules/bridgewellBidAdapter.js @@ -1,12 +1,15 @@ import * as utils from 'src/utils'; import {registerBidder} from 'src/adapters/bidderFactory'; +import {BANNER, NATIVE} from 'src/mediaTypes'; import find from 'core-js/library/fn/array/find'; const BIDDER_CODE = 'bridgewell'; const REQUEST_ENDPOINT = '//rec.scupio.com/recweb/prebid.aspx?cb=' + Math.random(); +const BIDDER_VERSION = '0.0.1'; export const spec = { code: BIDDER_CODE, + supportedMediaTypes: [BANNER, NATIVE], /** * Determines whether or not the given bid request is valid. @@ -59,6 +62,10 @@ export const spec = { method: 'POST', url: REQUEST_ENDPOINT, data: { + version: { + prebid: '$prebid.version$', + bridgewell: BIDDER_VERSION + }, adUnits: adUnits }, validBidRequests: validBidRequests @@ -104,7 +111,7 @@ export const spec = { }); } - if (sizeValid) { // dont care native sizes + if (sizeValid || (mediaTypes && mediaTypes.native)) { // dont care native sizes valid = true; } } @@ -120,23 +127,133 @@ export const spec = { // check required parameters if (typeof matchedResponse.cpm !== 'number') { return; - } else if (typeof matchedResponse.ad !== 'string') { - return; } else if (typeof matchedResponse.netRevenue !== 'boolean') { return; } else if (typeof matchedResponse.currency !== 'string') { return; + } else if (typeof matchedResponse.mediaType !== 'string') { + return; } bidResponse.requestId = req.bidId; bidResponse.cpm = matchedResponse.cpm * req.params.cpmWeight; bidResponse.width = matchedResponse.width; bidResponse.height = matchedResponse.height; - bidResponse.ad = matchedResponse.ad; bidResponse.ttl = matchedResponse.ttl; bidResponse.creativeId = matchedResponse.id; bidResponse.netRevenue = matchedResponse.netRevenue; bidResponse.currency = matchedResponse.currency; + bidResponse.mediaType = matchedResponse.mediaType; + + // check required parameters by matchedResponse.mediaType + switch (matchedResponse.mediaType) { + case BANNER: + // check banner required parameters + if (typeof matchedResponse.ad !== 'string') { + return; + } + + bidResponse.ad = matchedResponse.ad; + break; + case NATIVE: + // check native required parameters + if (!matchedResponse.native) { + return; + } + + let req_nativeLayout = req.mediaTypes.native; + let res_native = matchedResponse.native; + + // check title + let title = req_nativeLayout.title; + if (title && title.required) { + if (typeof res_native.title !== 'string') { + return; + } else if (title.len && title.len < res_native.title.length) { + return; + } + } + + // check body + let body = req_nativeLayout.body; + if (body && body.required) { + if (typeof res_native.body !== 'string') { + return; + } + } + + // check image + let image = req_nativeLayout.image; + if (image && image.required) { + if (res_native.image) { + if (typeof res_native.image.url !== 'string') { // check image url + return; + } else { + if (res_native.image.width !== image.sizes[0] || res_native.image.height !== image.sizes[1]) { // check image sizes + return; + } + } + } else { + return; + } + } + + // check sponsoredBy + let sponsoredBy = req_nativeLayout.sponsoredBy; + if (sponsoredBy && sponsoredBy.required) { + if (typeof res_native.sponsoredBy !== 'string') { + return; + } + } + + // check icon + let icon = req_nativeLayout.icon; + if (icon && icon.required) { + if (res_native.icon) { + if (typeof res_native.icon.url !== 'string') { // check icon url + return; + } else { + if (res_native.icon.width !== icon.sizes[0] || res_native.icon.height !== icon.sizes[0]) { // check image sizes + return; + } + } + } else { + return; + } + } + + // check clickUrl + if (typeof res_native.clickUrl !== 'string') { + return; + } + + // check clickTracker + let clickTrackers = res_native.clickTrackers; + if (clickTrackers) { + if (clickTrackers.length === 0) { + return; + } + } else { + return; + } + + // check impressionTrackers + let impressionTrackers = res_native.impressionTrackers; + if (impressionTrackers) { + if (impressionTrackers.length === 0) { + return; + } + } else { + return; + } + + bidResponse.native = matchedResponse.native; + + break; + + default: // response mediaType is not supported + return; + } bidResponses.push(bidResponse); } diff --git a/modules/bridgewellBidAdapter.md b/modules/bridgewellBidAdapter.md index 6e542af18a7..014be62ccef 100644 --- a/modules/bridgewellBidAdapter.md +++ b/modules/bridgewellBidAdapter.md @@ -55,5 +55,42 @@ Module that connects to Bridgewell demand source to fetch bids. ChannelID: 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ' } }] + }, { + code: 'test-div', + sizes: [1, 1], + mediaTypes: { + native: { + title: { + required: true, + len: 80 + }, + body: { + required: true + }, + image: { + required: true, + sizes: [150, 50] + }, + icon: { + required: false, + sizes: [50, 50] + }, + clickUrl: { + required: true + }, + cta: { + required: false + }, + sponsoredBy: { + required: false + } + } + }, + bids: [{ + bidder: 'bridgewell', + params: { + ChannelID: 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ' + } + }] }]; ``` diff --git a/test/spec/modules/bridgewellBidAdapter_spec.js b/test/spec/modules/bridgewellBidAdapter_spec.js index 8615531f88f..5dae3c474ac 100644 --- a/test/spec/modules/bridgewellBidAdapter_spec.js +++ b/test/spec/modules/bridgewellBidAdapter_spec.js @@ -87,6 +87,84 @@ describe('bridgewellBidAdapter', function () { 'bidId': '3150ccb55da321', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', + }, + { + 'bidder': 'bridgewell', + 'params': { + 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [1, 1], + 'mediaTypes': { + 'native': { + 'title': { + 'required': true, + 'len': 15 + }, + 'body': { + 'required': true + }, + 'image': { + 'required': true, + 'sizes': [150, 150] + }, + 'icon': { + 'required': true, + 'sizes': [50, 50] + }, + 'clickUrl': { + 'required': true + }, + 'cta': { + 'required': true + }, + 'sponsoredBy': { + 'required': true + } + } + }, + 'bidId': '3150ccb55da321', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }, + { + 'bidder': 'bridgewell', + 'params': { + 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [1, 1], + 'mediaTypes': { + 'native': { + 'title': { + 'required': false, + 'len': 15 + }, + 'body': { + 'required': false + }, + 'image': { + 'required': false, + 'sizes': [150, 150] + }, + 'icon': { + 'required': false, + 'sizes': [50, 50] + }, + 'clickUrl': { + 'required': false + }, + 'cta': { + 'required': false + }, + 'sponsoredBy': { + 'required': false + } + } + }, + 'bidId': '3150ccb55da321', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', } ]; const adapter = newBidder(spec); @@ -224,6 +302,7 @@ describe('bridgewellBidAdapter', function () { 'cpm': 5.0, 'width': 300, 'height': 250, + 'mediaType': 'banner', 'ad': '
test 300x250
', 'ttl': 360, 'netRevenue': true, @@ -235,6 +314,7 @@ describe('bridgewellBidAdapter', function () { 'cpm': 5.0, 'width': 728, 'height': 90, + 'mediaType': 'banner', 'ad': '
test 728x90
', 'ttl': 360, 'netRevenue': true, @@ -246,6 +326,7 @@ describe('bridgewellBidAdapter', function () { 'cpm': 5.0, 'width': 300, 'height': 250, + 'mediaType': 'banner', 'ad': '
test 300x250
', 'ttl': 360, 'netRevenue': true, @@ -257,6 +338,7 @@ describe('bridgewellBidAdapter', function () { 'cpm': 5.0, 'width': 300, 'height': 250, + 'mediaType': 'banner', 'ad': '
test 300x250
', 'ttl': 360, 'netRevenue': true, @@ -268,6 +350,7 @@ describe('bridgewellBidAdapter', function () { 'cpm': 5.0, 'width': 728, 'height': 90, + 'mediaType': 'banner', 'ad': '
test 728x90
', 'ttl': 360, 'netRevenue': true, @@ -279,6 +362,7 @@ describe('bridgewellBidAdapter', function () { 'cpm': 5.0, 'width': 728, 'height': 90, + 'mediaType': 'banner', 'ad': '
test 728x90
', 'ttl': 360, 'netRevenue': true, @@ -290,10 +374,69 @@ describe('bridgewellBidAdapter', function () { 'cpm': 5.0, 'width': 728, 'height': 90, + 'mediaType': 'banner', 'ad': '
test 728x90
', 'ttl': 360, 'netRevenue': true, 'currency': 'NTD' + }, + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }, + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' } ]; @@ -305,7 +448,13 @@ describe('bridgewellBidAdapter', function () { result.every(res => expect(res.ttl).to.be.a('number')); result.every(res => expect(res.netRevenue).to.be.a('boolean')); result.every(res => expect(res.currency).to.be.a('string')); - result.every(res => expect(res.ad).to.be.a('string')); + result.every(res => { + if (res.ad) { + expect(res.ad).to.be.an('string'); + } else if (res.native) { + expect(res.native).to.be.an('object'); + } + }); }); it('should give up bid if server response is undefiend', () => { @@ -384,6 +533,7 @@ describe('bridgewellBidAdapter', function () { 'cpm': 5.0, 'width': 300, 'height': 250, + 'mediaType': 'banner', 'ttl': 360, 'netRevenue': true, 'currency': 'NTD' @@ -424,5 +574,591 @@ describe('bridgewellBidAdapter', function () { const result = spec.interpretResponse({'body': [target]}, request); expect(result).to.deep.equal([]); }); + + it('should give up bid if mediaType is missing', () => { + let target = { + 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 300, + 'height': 250, + 'ad': '
test 300x250
', + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if property native of mediaType native is missing', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native title is missing', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native title is too long', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-titletest-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native body is missing', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + + it('should give up bid if native image url is missing', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + }); + + it('should give up bid if native image is missing', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native image url is missing', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native image sizes is unmatch', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg' + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native sponsoredBy is missing', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native icon is missing', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native icon url is missing', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native icon sizes is unmatch', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg' + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native clickUrl is missing', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native clickTrackers is missing', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native clickTrackers is empty', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': [], + 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native impressionTrackers is missing', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native impressionTrackers is empty', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'native': { + 'image': { + 'url': 'https://img.scupio.com/test/test-image.jpg', + 'width': 150, + 'height': 150 + }, + 'title': 'test-title', + 'sponsoredBy': 'test-sponsoredBy', + 'body': 'test-body', + 'icon': { + 'url': 'https://img.scupio.com/test/test-icon.jpg', + 'width': 50, + 'height': 50 + }, + 'clickUrl': 'https://img.scupio.com/test-clickUrl', + 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], + 'impressionTrackers': [] + }, + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if mediaType is not support', () => { + let target = { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 1, + 'height': 1, + 'mediaType': 'superNiceAd', + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }; + + const result = spec.interpretResponse({'body': [target]}, request); + expect(result).to.deep.equal([]); + }); }); });