Skip to content

Commit

Permalink
Smartyads Bid Adapter: add coppa field from config (prebid#6402)
Browse files Browse the repository at this point in the history
* update adapter. Add coppa field from config

* move stubs and restores for coppa tests
  • Loading branch information
SmartyAdsSSP authored and seergiioo6 committed Mar 23, 2021
1 parent 620acff commit 69872ef
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions modules/smartyadsBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {registerBidder} from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { config } from '../src/config.js';
import * as utils from '../src/utils.js';

const BIDDER_CODE = 'smartyads';
Expand Down Expand Up @@ -49,6 +50,7 @@ export const spec = {
'secure': 1,
'host': location.host,
'page': location.pathname,
'coppa': config.getConfig('coppa') === true ? 1 : 0,
'placements': placements
};
request.language.indexOf('-') != -1 && (request.language = request.language.split('-')[0])
Expand Down
21 changes: 20 additions & 1 deletion test/spec/modules/smartyadsBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {expect} from 'chai';
import {spec} from '../../../modules/smartyadsBidAdapter.js';
import { config } from '../../../src/config.js';

describe('SmartyadsAdapter', function () {
let bid = {
Expand Down Expand Up @@ -38,9 +39,10 @@ describe('SmartyadsAdapter', function () {
it('Returns valid data if array of bids is valid', function () {
let data = serverRequest.data;
expect(data).to.be.an('object');
expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements');
expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'coppa');
expect(data.deviceWidth).to.be.a('number');
expect(data.deviceHeight).to.be.a('number');
expect(data.coppa).to.be.a('number');
expect(data.language).to.be.a('string');
expect(data.secure).to.be.within(0, 1);
expect(data.host).to.be.a('string');
Expand All @@ -57,6 +59,23 @@ describe('SmartyadsAdapter', function () {
expect(data.placements).to.be.an('array').that.is.empty;
});
});

describe('with COPPA', function() {
beforeEach(function() {
sinon.stub(config, 'getConfig')
.withArgs('coppa')
.returns(true);
});
afterEach(function() {
config.getConfig.restore();
});

it('should send the Coppa "required" flag set to "1" in the request', function () {
let serverRequest = spec.buildRequests([bid]);
expect(serverRequest.data.coppa).to.equal(1);
});
});

describe('interpretResponse', function () {
it('Should interpret banner response', function () {
const banner = {
Expand Down

0 comments on commit 69872ef

Please sign in to comment.