Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a4g Bid Adapter: delete adid and use crid if it exists #6409

Merged
merged 2 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
})
});
});