Skip to content

Commit

Permalink
a4g Bid Adapter: delete adid and use crid if it exists (prebid#6409)
Browse files Browse the repository at this point in the history
* Deleted adid

* set crid if it's exist and added unit tests
  • Loading branch information
Junus authored and seergiioo6 committed Mar 23, 2021
1 parent 0d1a30e commit 4104179
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
3 changes: 1 addition & 2 deletions modules/a4gBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ export const spec = {
if (response.cpm > 0) {
const bidResponse = {
requestId: response.id,
creativeId: response.id,
adId: response.id,
creativeId: response.crid || response.id,
cpm: response.cpm,
width: response.width,
height: response.height,
Expand Down
50 changes: 48 additions & 2 deletions test/spec/modules/a4gBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import { spec } from 'modules/a4gBidAdapter.js';
import * as utils from 'src/utils.js';

describe('a4gAdapterTests', function () {
describe('bidRequestValidity', function () {
Expand Down Expand Up @@ -139,15 +140,54 @@ describe('a4gAdapterTests', function () {

const bidResponse = {
body: [{
'id': 'div-gpt-ad-1460505748561-0',
'id': '51ef8751f9aead',
'ad': 'test ad',
'width': 320,
'height': 250,
'cpm': 5.2
'cpm': 5.2,
'crid': '111'
}],
headers: {}
};

it('should get correct bid response for banner ad', function () {
const expectedParse = [
{
requestId: '51ef8751f9aead',
cpm: 5.2,
creativeId: '111',
width: 320,
height: 250,
ad: 'test ad',
currency: 'USD',
ttl: 120,
netRevenue: true
}
];
const result = spec.interpretResponse(bidResponse, bidRequest);
expect(result[0]).to.deep.equal(expectedParse[0]);
});

it('should set creativeId to default value if not provided', function () {
const bidResponseWithoutCrid = utils.deepClone(bidResponse);
delete bidResponseWithoutCrid.body[0].crid;
const expectedParse = [
{
requestId: '51ef8751f9aead',
cpm: 5.2,
creativeId: '51ef8751f9aead',
width: 320,
height: 250,
ad: 'test ad',
currency: 'USD',
ttl: 120,
netRevenue: true
}
];
const result = spec.interpretResponse(bidResponseWithoutCrid, bidRequest);
expect(result[0]).to.deep.equal(expectedParse[0]);
})

it('required keys', function () {
const result = spec.interpretResponse(bidResponse, bidRequest);

Expand All @@ -169,5 +209,11 @@ describe('a4gAdapterTests', function () {
expect(requiredKeys.indexOf(key) !== -1).to.equal(true);
});
})

it('adId should not be equal to requestId', function () {
const result = spec.interpretResponse(bidResponse, bidRequest);

expect(result[0].requestId).to.not.equal(result[0].adId);
})
});
});

0 comments on commit 4104179

Please sign in to comment.