Skip to content

Commit

Permalink
Fixed default values in bidResponse and added changes to the descript…
Browse files Browse the repository at this point in the history
…ion (#3051)

* Fixed default values in bidResponse and added changes to the description

* Added unit test for default cpm and netRevenue, removed placementId from tests and description
  • Loading branch information
ignat-one authored and bretg committed Sep 6, 2018
1 parent 55669ac commit d874367
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 11 deletions.
20 changes: 12 additions & 8 deletions modules/betweenBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ export const spec = {
for (var i = 0; i < serverResponse.body.length; i++) {
let bidResponse = {
requestId: serverResponse.body[i].bidid,
cpm: serverResponse.body[i].cpm || 123,
width: serverResponse.body[i].w || 200,
height: serverResponse.body[i].h || 400,
ttl: serverResponse.body[i].ttl || 120,
creativeId: serverResponse.body[i].creativeid || 123,
cpm: serverResponse.body[i].cpm || 0,
width: serverResponse.body[i].w,
height: serverResponse.body[i].h,
ttl: serverResponse.body[i].ttl,
creativeId: serverResponse.body[i].creativeid,
currency: serverResponse.body[i].currency || 'RUB',
netRevenue: serverResponse.body[i].netRevenue || false,
netRevenue: serverResponse.body[i].netRevenue || true,
ad: serverResponse.body[i].ad
};
bidResponses.push(bidResponse);
Expand Down Expand Up @@ -106,10 +106,14 @@ export const spec = {
});
} */

// syncs.push({
// type: 'iframe',
// url: '//acdn.adnxs.com/ib/static/usersync/v3/async_usersync.html'
// });
syncs.push({
type: 'iframe',
url: '//acdn.adnxs.com/ib/static/usersync/v3/async_usersync.html'
})
url: 'http://ads.betweendigital.com/sspmatch-iframe'
});
return syncs;
}
}
Expand Down
67 changes: 66 additions & 1 deletion modules/betweenBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ About us : http://betweendigital.com


# Test Parameters
```
```javascript
var adUnits = [
{
code: 'test-div',
Expand All @@ -28,4 +28,69 @@ About us : http://betweendigital.com
]
}
];
```

Where:

* s - the section id
* code - the id of the iframe tag to which the ads will be rendered

# Example page

```html
<html>
<head>
<script src="prebid.js"></script>
<script>
var PREBID_TIMEOUT = 700;
var adUnits = [{
code: 'example',
sizes: [[300, 250], [200,400]],
bids: [{
bidder: 'between',
params: {
w: 240,
h: 400,
s: 8
}
}]
}];
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
</script>


<script>
pbjs.que.push(function() {
pbjs.setConfig({ userSync: {
iframeEnabled: true
}});
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: function(e) {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
var params = pbjs.getAdserverTargetingForAdUnitCode("example");
var iframe = document.getElementById('example');
var iframeDoc = iframe.contentWindow.document;
if(params && params['hb_adid']) {
pbjs.renderAd(iframeDoc, params['hb_adid']);
}
}
});
});
</script>
</head>

<body>
<h2>Prebid.js BetweenBidAdapter Test</h2>
<iframe id="example"></iframe>
</body>
</html>
```
25 changes: 23 additions & 2 deletions test/spec/modules/betweenBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ describe('betweenBidAdapterTests', function () {
expect(spec.isBidRequestValid({
bidder: 'between',
params: {
placementId: 'example',
w: 240,
h: 400,
s: 1112
Expand All @@ -17,7 +16,7 @@ describe('betweenBidAdapterTests', function () {
let bidRequestData = [{
bidId: 'bid1234',
bidder: 'between',
params: {w: 240, h: 400, s: 1112, placementId: 'example'},
params: {w: 240, h: 400, s: 1112},
sizes: [[240, 400]]
}]
let request = spec.buildRequests(bidRequestData);
Expand All @@ -42,6 +41,28 @@ describe('betweenBidAdapterTests', function () {
expect(bid.currency).to.equal('USD');
expect(bid.width).to.equal(240);
expect(bid.height).to.equal(400);
expect(bid.netRevenue).to.equal(true);
expect(bid.requestId).to.equal('bid1234');
expect(bid.ad).to.equal('Ad html');
});
it('validate_response_params', function () {
let serverResponse = {
body: [{
bidid: 'bid1234',
w: 240,
h: 400,
currency: 'USD',
ad: 'Ad html'
}]
};
let bids = spec.interpretResponse(serverResponse);
expect(bids).to.have.lengthOf(1);
let bid = bids[0];
expect(bid.cpm).to.equal(0);
expect(bid.currency).to.equal('USD');
expect(bid.width).to.equal(240);
expect(bid.height).to.equal(400);
expect(bid.netRevenue).to.equal(true);
expect(bid.requestId).to.equal('bid1234');
expect(bid.ad).to.equal('Ad html');
});
Expand Down

0 comments on commit d874367

Please sign in to comment.