diff --git a/build/dist/prebid.js b/build/dist/prebid.js index df0508c20d1..282288df4b0 100644 --- a/build/dist/prebid.js +++ b/build/dist/prebid.js @@ -1,10 +1,10 @@ /* prebid.js v1.11.0 Updated : 2018-05-17 */ -!(function(e){var t=window.pbjsChunk;window.pbjsChunk=function(n,o,a){for(var u,d,s,c=0,f=[];c0)if(2===a&&"number"==typeof e[0]&&"number"==typeof e[1])t.push(b(e));else for(var u=0;u0&&void 0!==arguments[0]?arguments[0]:pbjs.adUnits).map((function(e){return e.bids.map((function(e){return e.bidder})).reduce(I,[])})).reduce(I).filter(T)},t.isGptPubadsDefined=function(){if(window.googletag&&t.isFn(window.googletag.pubads)&&t.isFn(window.googletag.pubads().getSlots))return!0},t.getHighestCpm=function(e,t){if(e.cpm===t.cpm)return e.timeToRespond>t.timeToRespond?t:e;return e.cpm0;){var n=Math.floor(Math.random()*t),r=e[--t];e[t]=e[n],e[n]=r}return e},t.adUnitsFilter=function(e,t){return(0,d.default)(e,t&&t.adUnitCode)},t.isSrcdocSupported=function(e){return e.defaultView&&e.defaultView.frameElement&&"srcdoc"in e.defaultView.frameElement&&!/firefox/i.test(navigator.userAgent)},t.deepClone=function(e){return(0,a.default)(e)},t.inIframe=function(){try{return t.getWindowSelf()!==t.getWindowTop()}catch(e){return!0}},t.isSafariBrowser=function(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)},t.replaceAuctionPrice=function(e,t){if(!e)return;return e.replace(/\$\{AUCTION_PRICE\}/g,t)},t.timestamp=function(){return(new Date).getTime()},t.checkCookieSupport=function(){if(window.navigator.cookieEnabled||document.cookie.length)return!0},t.cookiesAreEnabled=function(){if(t.checkCookieSupport())return!0;return window.document.cookie="prebid.cookieTest",-1!=window.document.cookie.indexOf("prebid.cookieTest")},t.delayExecution=function(e,t){if(t<1)throw new Error("numRequiredCalls must be a positive number. Got "+t);var n=0;return function(){++n===t&&e.apply(null,arguments)}},t.groupBy=function(e,t){return e.reduce((function(e,n){return(e[n[t]]=e[n[t]]||[]).push(n),e}),{})},t.deepAccess=function(e,t){if(!e)return;t=String(t).split(".");for(var n=0;n"}], "seat": "1"}], "cur": "USD", "id": "234566709"});' - } - }); - - describe('isBidRequestValid', () => { - it('should accept valid bid', () => { - const validBid = bidRequests[0]; - expect(spec.isBidRequestValid(validBid)).to.equal(true); - }); - it('should reject bid without ID', () => { - let invalidBid = { - bidder: 'indexExchange', - params: { - siteID: '208209' - } - }; - expect(spec.isBidRequestValid(invalidBid)).to.equal(false); - }); - it('should reject bid without siteID', () => { - let invalidBid = { - bidder: 'indexExchange', - params: { - id: '185406' - } - }; - expect(spec.isBidRequestValid(invalidBid)).to.equal(false); - }); - }); - describe('buildRequests', () => { - it('should build correct number of bids', () => { - const requests = spec.buildRequests(bidRequests); - expect(requests).to.be.lengthOf(2); - }); - it('should use correct method', () => { - const requests = spec.buildRequests(bidRequests); - const method = requests[0].method; - expect(method).to.equal('GET') - }); - it('should build correct URL', () => { - const requests = spec.buildRequests(bidRequests); - const url = requests[0].url; - const decodedUrl = decodeURI(url); - expect(decodedUrl).to.match(/https:\/\/as-sec.casalemedia.com\/cygnus\?v=7&fn=cygnus_index_parse_res&s=208209&r={"id":"(\d+)","site":{"page":"http:\/\/localhost:9876\/","ref":"http:\/\/localhost:9876\/\?id=(\d+)"},"imp":\[{"id":"1", "banner":{"w":300,"h":250,"topframe":1},"ext": {"sid":"185406_1","siteID":208209}},{"id":"2", "banner":{"w":300,"h":600,"topframe":1},"ext": {"sid":"185406_2","siteID":208209}}]}&pid=pb%24prebid.version%24/); - }); - it('should have no data', () => { - const requests = spec.buildRequests(bidRequests); - const data = requests[0].data; - expect(data).to.be.empty; - }); - it('should encode URL', () => { - const requests = spec.buildRequests(bidRequests); - const url = requests[0].url; - expect(url).to.not.have.string('{').and.not.have.string('}').and.not.have.string('"'); - }); - }); - describe('interpretResponse', () => { - it('should interpret correct number of empty bid responses', () => { - const bids = spec.interpretResponse(emptyBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids).to.be.lengthOf(1); - }); - it('should interpret empty bid response status', () => { - const bids = spec.interpretResponse(emptyBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].statusMessage).to.equal('Bid returned empty or error response'); - }); - it('should interpret empty bid response request ID', () => { - const bids = spec.interpretResponse(emptyBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].requestId).to.equal(bidRequests[0].bidId); - }); - it('should interpret empty bid response bidder code', () => { - const bids = spec.interpretResponse(emptyBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].bidderCode).to.equal('indexExchange'); - }); - it('should interpret empty bid response CPM', () => { - const bids = spec.interpretResponse(emptyBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].cpm).to.equal(0); - }); - it('should interpret empty bid response width', () => { - const bids = spec.interpretResponse(emptyBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].width).to.equal(0); - }); - it('should interpret empty bid response height', () => { - const bids = spec.interpretResponse(emptyBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].height).to.equal(0); - }); - it('should interpret empty bid response ttl', () => { - const bids = spec.interpretResponse(emptyBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].ttl).to.equal(360); - }); - it('should interpret empty bid response ad', () => { - const bids = spec.interpretResponse(emptyBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0]).to.not.have.property('ad'); - }); - it('should interpret empty bid response creative ID', () => { - const bids = spec.interpretResponse(emptyBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].creativeId).to.be.empty; - }); - it('should interpret empty bid response net revenue flag', () => { - const bids = spec.interpretResponse(emptyBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].netRevenue).to.be.true; - }); - it('should interpret empty bid response currency', () => { - const bids = spec.interpretResponse(emptyBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].currency).to.equal('USD'); - }); - it('should interpret correct number of filled bid responses', () => { - const bids = spec.interpretResponse(filledBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids).to.be.lengthOf(1); - }); - it('should interpret filled bid response status', () => { - const bids = spec.interpretResponse(filledBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].statusMessage).to.equal('Bid available'); - }); - it('should interpret filled bid response request ID', () => { - const bids = spec.interpretResponse(filledBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].requestId).to.equal(bidRequests[0].bidId); - }); - it('should interpret empty bid response bidder code', () => { - const bids = spec.interpretResponse(filledBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].bidderCode).to.equal('indexExchange'); - }); - it('should interpret filled bid response CPM', () => { - const bids = spec.interpretResponse(filledBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].cpm).to.equal(0.27); - }); - it('should interpret filled bid response width', () => { - const bids = spec.interpretResponse(filledBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].width).to.equal(300); - }); - it('should interpret filled bid response height', () => { - const bids = spec.interpretResponse(filledBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].height).to.equal(250); - }); - it('should interpret filled bid response ttl', () => { - const bids = spec.interpretResponse(filledBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].ttl).to.equal(360); - }); - it('should interpret filled bid response ad', () => { - const bids = spec.interpretResponse(filledBidResponse, {'bidRequest': bidRequests[0]}); - expect(bids[0].ad).to.have.string('