Skip to content

Commit

Permalink
Sublime Bid Adapter : Add support for meta.advertiserDomains (#6920)
Browse files Browse the repository at this point in the history
* Add advertiserDomains stub

* Use utils from require

* Update version

* Replace let to const and fix version
  • Loading branch information
Léo authored Jun 2, 2021
1 parent 7e67b4e commit b105b75
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 31 deletions.
8 changes: 7 additions & 1 deletion modules/sublimeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const DEFAULT_CURRENCY = 'EUR';
const DEFAULT_PROTOCOL = 'https';
const DEFAULT_TTL = 600;
const SUBLIME_ANTENNA = 'antenna.ayads.co';
const SUBLIME_VERSION = '0.7.1';
const SUBLIME_VERSION = '0.7.2';

/**
* Identify the current device type
Expand Down Expand Up @@ -207,6 +207,12 @@ function interpretResponse(serverResponse, bidRequest) {
sspname: response.sspname || null
};

// We don't support advertiserDomains atm
if (response.advertiserDomains) {
// Creating a stub for Prebid.js 5.0 compliance
bidResponse.meta = Object.assign({}, bidResponse.meta, { advertiserDomains: [] });
}

bidResponses.push(bidResponse);
}

Expand Down
77 changes: 47 additions & 30 deletions test/spec/modules/sublimeBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Sublime Adapter', function() {
});

describe('isBidRequestValid', function() {
let bid = {
const bid = {
bidder: 'sublime',
params: {
zoneId: 24549,
Expand All @@ -60,14 +60,14 @@ describe('Sublime Adapter', function() {
});

it('should return false when required params are not passed', function() {
let bid = Object.assign({}, bid);
const bid = Object.assign({}, bid);
bid.params = {};
expect(spec.isBidRequestValid(bid)).to.equal(false);
});
});

describe('buildRequests', function() {
let bidRequests = [
const bidRequests = [
{
bidder: 'sublime',
adUnitCode: 'sublime_code',
Expand All @@ -90,7 +90,7 @@ describe('Sublime Adapter', function() {
}
];

let bidderRequest = {
const bidderRequest = {
gdprConsent: {
consentString: 'EOHEIRCOUCOUIEHZIOEIU-TEST',
gdprApplies: true
Expand All @@ -101,7 +101,7 @@ describe('Sublime Adapter', function() {
}
};

let request = spec.buildRequests(bidRequests, bidderRequest);
const request = spec.buildRequests(bidRequests, bidderRequest);

it('should have a post method', function() {
expect(request[0].method).to.equal('POST');
Expand All @@ -121,7 +121,7 @@ describe('Sublime Adapter', function() {
});

describe('buildRequests: default arguments', function() {
let bidRequests = [{
const bidRequests = [{
bidder: 'sublime',
adUnitCode: 'sublime_code',
bidId: 'abc1234',
Expand All @@ -132,15 +132,15 @@ describe('Sublime Adapter', function() {
}
}];

let request = spec.buildRequests(bidRequests);
const request = spec.buildRequests(bidRequests);

it('should have an url that match the default endpoint', function() {
expect(request[0].url).to.equal('https://pbjs.sskzlabs.com/bid');
});
});

describe('interpretResponse', function() {
let serverResponse = {
const serverResponse = {
'request_id': '3db3773286ee59',
'sspname': 'foo',
'cpm': 0.5,
Expand All @@ -155,7 +155,7 @@ describe('Sublime Adapter', function() {
}
};

let expectedResponse = [
const expectedResponse = [
{
requestId: '',
cpm: 0.5,
Expand All @@ -167,23 +167,23 @@ describe('Sublime Adapter', function() {
sspname: 'foo',
netRevenue: true,
ttl: 600,
pbav: '0.7.1',
pbav: '0.7.2',
ad: '',
},
];
let result = spec.interpretResponse({body: serverResponse});
const result = spec.interpretResponse({body: serverResponse});
expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0]));
});

it('should get correct default size for 1x1', function() {
let serverResponse = {
const serverResponse = {
'requestId': 'xyz654_2',
'sspname': 'sublime',
'cpm': 0.5,
'ad': '<!-- Creative -->',
};

let bidRequest = {
const bidRequest = {
bidder: 'sublime',
adUnitCode: 'sublime_code_2',
bidId: 'abc1234_2',
Expand All @@ -197,9 +197,9 @@ describe('Sublime Adapter', function() {
}
};

let result = spec.interpretResponse({body: serverResponse}, bidRequest);
const result = spec.interpretResponse({body: serverResponse}, bidRequest);

let expectedResponse = {
const expectedResponse = {
requestId: 'xyz654_2',
cpm: 0.5,
width: 1,
Expand All @@ -210,32 +210,32 @@ describe('Sublime Adapter', function() {
netRevenue: true,
ttl: 600,
ad: '<!-- Creative -->',
pbav: '0.7.1',
pbav: '0.7.2',
sspname: 'sublime'
};

expect(result[0]).to.deep.equal(expectedResponse);
});

it('should return bid empty response', function () {
let serverResponse = '';
let bidRequest = {};
const serverResponse = '';
const bidRequest = {};

let result = spec.interpretResponse({ body: serverResponse }, bidRequest);
const result = spec.interpretResponse({ body: serverResponse }, bidRequest);

let expectedResponse = [];
const expectedResponse = [];

expect(result).to.deep.equal(expectedResponse);
});

it('should return bid with default value in response', function () {
let serverResponse = {
const serverResponse = {
'requestId': 'xyz654_2',
'sspname': 'sublime',
'ad': '<!-- ad -->',
};

let bidRequest = {
const bidRequest = {
bidder: 'sublime',
adUnitCode: 'sublime_code_2',
bidId: 'abc1234_2',
Expand All @@ -249,9 +249,9 @@ describe('Sublime Adapter', function() {
}
};

let result = spec.interpretResponse({ body: serverResponse }, bidRequest);
const result = spec.interpretResponse({ body: serverResponse }, bidRequest);

let expectedResponse = {
const expectedResponse = {
requestId: 'xyz654_2',
cpm: 0,
width: 1,
Expand All @@ -263,20 +263,20 @@ describe('Sublime Adapter', function() {
netRevenue: true,
ttl: 600,
ad: '<!-- ad -->',
pbav: '0.7.1',
pbav: '0.7.2',
};

expect(result[0]).to.deep.equal(expectedResponse);
});

it('should return empty bid response because of timeout', function () {
let serverResponse = {
const serverResponse = {
'requestId': 'xyz654_2',
'timeout': true,
'ad': '',
};

let bidRequest = {
const bidRequest = {
bidder: 'sublime',
adUnitCode: 'sublime_code_2',
bidId: 'abc1234_2',
Expand All @@ -290,21 +290,38 @@ describe('Sublime Adapter', function() {
}
};

let result = spec.interpretResponse({ body: serverResponse }, bidRequest);
const result = spec.interpretResponse({ body: serverResponse }, bidRequest);

let expectedResponse = [];
const expectedResponse = [];

expect(result).to.deep.equal(expectedResponse);

describe('On bid Time out', function () {
spec.onTimeout(result);
});
});

it('should add advertiserDomains', function() {
const responseWithAdvertiserDomains = utils.deepClone(serverResponse);
responseWithAdvertiserDomains.advertiserDomains = ['a_sublime_adomain'];

const bidRequest = {
bidder: 'sublime',
params: {
zoneId: 456,
}
};

const result = spec.interpretResponse({ body: responseWithAdvertiserDomains }, bidRequest);

expect(Object.keys(result[0].meta)).to.include.members(['advertiserDomains']);
expect(Object.keys(result[0].meta.advertiserDomains)).to.deep.equal([]);
});
});

describe('onBidWon', function() {
let sandbox;
let bid = { foo: 'bar' };
const bid = { foo: 'bar' };

beforeEach(function () {
sandbox = sinon.sandbox.create();
Expand Down

0 comments on commit b105b75

Please sign in to comment.