-
-
-
- ]]>
-
-
-
ES
-
-
- `;
- const serverResponse = {
- 'body': xmlStr1,
- }
- const bidResponses = spec.interpretResponse(serverResponse, bidRequest);
- expect(bidResponses.length).to.equal(0);
- })
- it('It should return a banner ad.', () => {
- const serverResponse = {
- 'body': xmlStr,
- }
- setCurrentURL('https://www.sports.com');
- const bidResponses = spec.interpretResponse(serverResponse, bidRequest);
- expect(bidResponses.length).greaterThan(0);
- expect(bidResponses[0].mediaType).to.be.equal(BANNER);
- expect(bidResponses[0].ad).not.to.be.null;
- })
- it('It should return a video ad.', () => {
- const serverResponse = {
- 'body': xmlStr,
- }
- setCurrentURL('https://www.sports.com');
- bidRequest.bidRequest.mediaTypes = {
- video: {
- sizes: [
- [300, 250],
- [300, 600]
- ]
- }
- }
- const bidResponses = spec.interpretResponse(serverResponse, bidRequest);
- expect(bidResponses.length).greaterThan(0);
- expect(bidResponses[0].mediaType).to.be.equal(VIDEO);
- expect(bidResponses[0].vastUrl).not.to.be.null;
- })
- });
-});
diff --git a/test/spec/modules/amxBidAdapter_spec.js b/test/spec/modules/amxBidAdapter_spec.js
deleted file mode 100644
index d1e88b35a..000000000
--- a/test/spec/modules/amxBidAdapter_spec.js
+++ /dev/null
@@ -1,849 +0,0 @@
-import { expect } from 'chai';
-import { spec } from 'modules/amxBidAdapter.js';
-import { createEidsArray } from 'modules/userId/eids.js';
-import { BANNER, VIDEO } from 'src/mediaTypes.js';
-import { config } from 'src/config.js';
-import { server } from 'test/mocks/xhr.js';
-import * as utils from 'src/utils.js';
-import { getGlobal } from '../../../src/prebidGlobal.js';
-
-import {getGlobalVarName} from '../../../src/buildOptions.js';
-
-const sampleRequestId = '82c91e127a9b93e';
-const sampleDisplayAd = ``;
-const sampleDisplayCRID = '78827819';
-// minimal example vast
-const sampleVideoAd = (addlImpression) =>
- `
-
00:00:15${addlImpression}
-`.replace(/\n+/g, '');
-
-const sampleFPD = {
- site: {
- keywords: 'sample keywords',
- ext: {
- data: {
- pageType: 'article',
- },
- },
- },
- user: {
- gender: 'O',
- yob: 1982,
- },
-};
-
-const sampleBidderRequest = {
- gdprConsent: {
- gdprApplies: true,
- consentString: utils.getUniqueIdentifierStr(),
- vendorData: {},
- },
- gppConsent: {
- gppString: 'example',
- applicableSections: 'example',
- },
-
- auctionId: null,
-
- uspConsent: '1YYY',
- refererInfo: {
- reachedTop: true,
- numIframes: 10,
- stack: ['https://www.prebid.org'],
- canonicalUrl: 'https://prebid.org',
- location: 'https://www.prebid.org',
- site: 'prebid.org',
- topmostLocation: 'https://www.prebid.org',
- page: 'https://www.prebid.org/the/link/to/the/page',
- },
- ortb2: sampleFPD,
-};
-
-const sampleImpExt = {
- testKey: 'testValue',
-};
-
-const sampleBidRequestBase = {
- bidder: spec.code,
- params: {
- endpoint: 'https://httpbin.org/post',
- },
- ortb2Imp: {
- ext: sampleImpExt,
- },
- sizes: [[320, 50]],
- getFloor(params) {
- if (
- params.size == null ||
- params.currency == null ||
- params.mediaType == null
- ) {
- throw new Error(
- `getFloor called with incomplete params: ${JSON.stringify(params)}`
- );
- }
- return {
- floor: 0.5,
- currency: 'USD',
- };
- },
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]],
- },
- },
- adUnitCode: 'div-gpt-ad-example',
- transactionId: utils.getUniqueIdentifierStr(),
- bidId: sampleRequestId,
-
- auctionId: null,
-};
-
-const schainConfig = {
- ver: '1.0',
- nodes: [
- {
- asi: 'greatnetwork.exchange',
- sid: '000001',
- hp: 1,
- rid: 'bid_request_1',
- domain: 'publisher.com',
- },
- ],
-};
-
-const sampleBidRequestVideo = {
- ...sampleBidRequestBase,
- bidId: sampleRequestId + '_video',
- sizes: [[300, 150]],
- ortb2: { source: { ext: { schain: schainConfig } } },
- mediaTypes: {
- [VIDEO]: {
- sizes: [[360, 250]],
- context: 'adpod',
- adPodDurationSec: 90,
- contentMode: 'live',
- },
- },
-};
-
-const sampleServerResponse = {
- p: {
- hreq: [
- 'https://1x1.a-mo.net/hbx/g_sync?partner=test',
- 'https://1x1.a-mo.net/hbx/g_syncf?__st=iframe',
- ],
- },
- r: {
- [sampleRequestId]: [
- {
- b: [
- {
- adid: '78827819',
- adm: sampleDisplayAd,
- adomain: ['example.com'],
- crid: sampleDisplayCRID,
- h: 600,
- id: '2014691335735134254',
- impid: '1',
- exp: 90,
- price: 0.25,
- w: 300,
- },
- {
- adid: '222976952',
- adm: sampleVideoAd(''),
- adomain: ['example.com'],
- crid: sampleDisplayCRID,
- ext: {},
- h: 1,
- id: '7735706981389902829',
- impid: '1',
- exp: 90,
- price: 0.25,
- w: 1,
- },
- ],
- },
- ],
- },
-};
-
-describe('AmxBidAdapter', () => {
- describe('isBidRequestValid', () => {
- it('endpoint must be an optional string', () => {
- expect(spec.isBidRequestValid({ params: { endpoint: 1 } })).to.equal(
- false
- );
- expect(spec.isBidRequestValid({ params: { endpoint: 'test' } })).to.equal(
- true
- );
- });
-
- it('tagId is an optional string', () => {
- expect(spec.isBidRequestValid({ params: { tagId: 1 } })).to.equal(false);
- expect(spec.isBidRequestValid({ params: { tagId: 'test' } })).to.equal(
- true
- );
- });
-
- it('testMode is an optional truthy value', () => {
- expect(spec.isBidRequestValid({ params: { testMode: 1 } })).to.equal(
- true
- );
- expect(spec.isBidRequestValid({ params: { testMode: 'true' } })).to.equal(
- true
- );
- // ignore invalid values (falsy)
- expect(
- spec.isBidRequestValid({
- params: { testMode: 'non-truthy-invalid-value' },
- })
- ).to.equal(true);
- expect(spec.isBidRequestValid({ params: { testMode: false } })).to.equal(
- true
- );
- });
-
- it('none of the params are required', () => {
- expect(spec.isBidRequestValid({})).to.equal(true);
- });
- });
- describe('getUserSync', () => {
- it('Will perform an iframe sync even if there is no server response..', () => {
- const syncs = spec.getUserSyncs({ iframeEnabled: true });
- expect(syncs).to.eql([
- {
- type: 'iframe',
- url: 'https://prebid.a-mo.net/isyn?gdpr_consent=&gdpr=0&us_privacy=&gpp=&gpp_sid=',
- },
- ]);
- });
-
- it('will return valid syncs from a server response', () => {
- const syncs = spec.getUserSyncs({ iframeEnabled: true }, [
- { body: sampleServerResponse },
- ]);
- expect(syncs.length).to.equal(2);
- expect(syncs[0].type).to.equal('image');
- expect(syncs[1].type).to.equal('iframe');
- });
-
- it('will filter out iframe syncs based on options', () => {
- const syncs = spec.getUserSyncs({ iframeEnabled: false }, [
- { body: sampleServerResponse },
- { body: sampleServerResponse },
- ]);
- expect(syncs.length).to.equal(2);
- expect(syncs).to.satisfy((allSyncs) =>
- allSyncs.every((sync) => sync.type === 'image')
- );
- });
- });
-
- describe('buildRequests', () => {
- it('will default to prebid.a-mo.net endpoint', () => {
- const { url } = spec.buildRequests([], sampleBidderRequest);
- expect(url).to.equal('https://prebid.a-mo.net/a/c');
- });
-
- it('will read the prebid version & global', () => {
- const {
- data: { V: prebidVersion, vg: prebidGlobal },
- } = spec.buildRequests(
- [
- {
- ...sampleBidRequestBase,
- params: {
- testMode: true,
- },
- },
- ],
- sampleBidderRequest
- );
- expect(prebidVersion).to.equal('$prebid.version$');
- expect(prebidGlobal).to.equal(getGlobalVarName());
- });
-
- it('reads test mode from the first bid request', () => {
- const { data } = spec.buildRequests(
- [
- {
- ...sampleBidRequestBase,
- params: {
- testMode: true,
- },
- },
- ],
- sampleBidderRequest
- );
- expect(data.tm).to.equal(true);
- });
-
- it('will attach additional referrer info data', () => {
- const { data } = spec.buildRequests(
- [sampleBidRequestBase],
- sampleBidderRequest
- );
- expect(data.ri.r).to.equal(
- sampleBidderRequest.refererInfo.topmostLocation
- );
- expect(data.ri.t).to.equal(sampleBidderRequest.refererInfo.reachedTop);
- expect(data.ri.l).to.equal(sampleBidderRequest.refererInfo.numIframes);
- expect(data.ri.s).to.equal(sampleBidderRequest.refererInfo.stack);
- expect(data.ri.c).to.equal(sampleBidderRequest.refererInfo.canonicalUrl);
- });
-
- it('if prebid is in an iframe, will use the frame url as domain, if the topmost is not avialable', () => {
- const { data } = spec.buildRequests([sampleBidRequestBase], {
- ...sampleBidderRequest,
- refererInfo: {
- location: null,
- topmostLocation: null,
- ref: 'http://search-traffic-source.com',
- },
- });
- expect(data.do).to.equal('localhost');
- expect(data.re).to.equal('http://search-traffic-source.com');
- });
-
- it('if prebid is in an iframe, will use the topmost url as domain', () => {
- const { data } = spec.buildRequests([sampleBidRequestBase], {
- ...sampleBidderRequest,
- refererInfo: {
- location: null,
- topmostLocation: 'http://top-site.com',
- ref: 'http://search-traffic-source.com',
- },
- });
- expect(data.do).to.equal('top-site.com');
- expect(data.re).to.equal('http://search-traffic-source.com');
- });
-
- it('handles GDPR, USP Consent, COPPA, and GPP', () => {
- const { data } = spec.buildRequests(
- [sampleBidRequestBase],
- sampleBidderRequest
- );
- delete data.m; // don't deal with 'm' in this test
- expect(data.gs).to.equal(sampleBidderRequest.gdprConsent.gdprApplies);
- expect(data.gc).to.equal(sampleBidderRequest.gdprConsent.consentString);
- expect(data.usp).to.equal(sampleBidderRequest.uspConsent);
- expect(data.gpp).to.equal(sampleBidderRequest.gppConsent);
- expect(data.cpp).to.equal(0);
- });
-
- it('will forward bid request count & wins count data', () => {
- const bidderRequestsCount = Math.floor(Math.random() * 100);
- const bidderWinsCount = Math.floor(Math.random() * 100);
- const { data } = spec.buildRequests(
- [
- {
- ...sampleBidRequestBase,
- bidderRequestsCount,
- bidderWinsCount,
- },
- ],
- sampleBidderRequest
- );
-
- expect(data.brc).to.equal(bidderRequestsCount);
- expect(data.bwc).to.equal(bidderWinsCount);
- expect(data.trc).to.equal(0);
- });
-
- it('will attach sync configuration', () => {
- const request = () =>
- spec.buildRequests([sampleBidRequestBase], sampleBidderRequest);
-
- const setConfig = (filterSettings) =>
- config.setConfig({
- userSync: {
- syncsPerBidder: 2,
- syncDelay: 2300,
- syncEnabled: true,
- filterSettings,
- },
- });
-
- const test = (filterSettings) => {
- setConfig(filterSettings);
- return request().data.sync;
- };
-
- const base = { d: 2300, l: 2, e: true };
-
- const tests = [
- [undefined, { ...base, t: 0 }],
- [
- {
- image: {
- bidders: '*',
- filter: 'include',
- },
- iframe: {
- bidders: '*',
- filter: 'include',
- },
- },
- { ...base, t: 3 },
- ],
- [
- {
- image: {
- bidders: ['amx'],
- },
- iframe: {
- bidders: '*',
- filter: 'include',
- },
- },
- { ...base, t: 3 },
- ],
- [
- {
- image: {
- bidders: ['other'],
- },
- iframe: {
- bidders: '*',
- },
- },
- { ...base, t: 2 },
- ],
- [
- {
- image: {
- bidders: ['amx'],
- },
- iframe: {
- bidders: ['amx'],
- filter: 'exclude',
- },
- },
- { ...base, t: 1 },
- ],
- ];
-
- for (let i = 0, l = tests.length; i < l; i++) {
- const [result, expected] = tests[i];
- expect(test(result), `input: ${JSON.stringify(result)}`).to.deep.equal(
- expected
- );
- }
- });
-
- it('will forward first-party data', () => {
- const { data } = spec.buildRequests(
- [sampleBidRequestBase],
- sampleBidderRequest
- );
- expect(data.fpd2).to.deep.equal(sampleFPD);
- });
-
- it('will collect & forward RTI user IDs', () => {
- const randomRTI = `greatRTI${Math.floor(Math.random() * 100)}`;
- const userId = {
- criteoId: 'sample-criteo',
- digitrustid: { data: { id: 'sample-digitrust' } },
- id5id: { uid: 'sample-id5' },
- idl_env: 'sample-liveramp',
- lipb: { lipbid: 'sample-liveintent' },
- netId: 'sample-netid',
- parrableId: { eid: 'sample-parrable' },
- pubcid: 'sample-pubcid',
- [randomRTI]: 'sample-unknown',
- tdid: 'sample-ttd',
- };
-
- const eids = createEidsArray(userId);
- const bid = {
- ...sampleBidRequestBase,
- userIdAsEids: eids,
- };
-
- const { data } = spec.buildRequests([bid, bid], sampleBidderRequest);
- expect(data.eids).to.deep.equal(eids);
- });
-
- it('can build a banner request', () => {
- const { method, url, data } = spec.buildRequests(
- [
- sampleBidRequestBase,
- {
- ...sampleBidRequestBase,
- bidId: sampleRequestId + '_2',
- params: {
- ...sampleBidRequestBase.params,
- adUnitId: '',
- tagId: 'example',
- },
- },
- ],
- sampleBidderRequest
- );
-
- expect(url).to.equal(sampleBidRequestBase.params.endpoint);
- expect(method).to.equal('POST');
- expect(Object.keys(data.m).length).to.equal(2);
- expect(data.m[sampleRequestId]).to.deep.equal({
- av: true,
- au: 'div-gpt-ad-example',
- vd: {},
- ms: [[[320, 50]], [[300, 250]], []],
- aw: 300,
- sc: {},
- ah: 250,
- tf: 0,
- f: 0.5,
- vr: false,
- rtb: {
- ext: sampleImpExt,
- },
- });
- expect(data.m[sampleRequestId + '_2']).to.deep.equal({
- av: true,
- aw: 300,
- au: 'div-gpt-ad-example',
- sc: {},
- ms: [[[320, 50]], [[300, 250]], []],
- i: 'example',
- ah: 250,
- vd: {},
- tf: 0,
- f: 0.5,
- vr: false,
- rtb: {
- ext: sampleImpExt,
- },
- });
- });
-
- it('can build a video request', () => {
- const { data } = spec.buildRequests(
- [
- {
- ...sampleBidRequestVideo,
- params: {
- ...sampleBidRequestVideo.params,
- adUnitId: 'custom-auid',
- },
- },
- ],
- sampleBidderRequest
- );
- expect(Object.keys(data.m).length).to.equal(1);
- expect(data.m[sampleRequestId + '_video']).to.deep.equal({
- au: 'custom-auid',
- ms: [[[300, 150]], [], [[360, 250]]],
- av: true,
- aw: 360,
- ah: 250,
- sc: schainConfig,
- vd: {
- sizes: [[360, 250]],
- context: 'adpod',
- adPodDurationSec: 90,
- contentMode: 'live',
- },
- tf: 0,
- f: 0.5,
- rtb: {
- ext: sampleImpExt,
- },
- vr: true,
- });
- });
- });
-
- describe('interpretResponse', () => {
- const baseBidResponse = {
- requestId: sampleRequestId,
- cpm: 0.25,
- creativeId: sampleDisplayCRID,
- currency: 'USD',
- netRevenue: true,
- meta: {
- advertiserDomains: ['example.com'],
- },
- };
-
- const baseRequest = {
- data: {
- m: {
- [sampleRequestId]: {
- aw: 300,
- ah: 250,
- },
- },
- },
- };
-
- it('will handle a nobid response', () => {
- const parsed = spec.interpretResponse({ body: '' }, baseRequest);
- expect(parsed).to.eql([]);
- });
-
- const cases = [
- [
- 'pbjs.bidderSettings',
- (conf) => {
- const before = getGlobal().bidderSettings;
- getGlobal().bidderSettings = conf;
- return before;
- },
- (before) => {
- getGlobal().bidderSettings = before;
- },
- ],
- [
- 'setConfig / bidderSettings (legacy)',
- (conf) => {
- const before = config.getConfig();
- config.setConfig({
- bidderSettings: conf,
- });
-
- return before;
- },
- (before) => {
- config.setConfig(before);
- },
- ],
- ];
-
- cases.forEach(([name, setup, teardown]) => {
- it(`will read an bidderCode override from bid.ext.prebid.meta, set with ${name}`, () => {
- const currentConfig = setup({
- amx: {
- allowAlternateBidderCodes: true,
- },
- });
- const parsed = spec.interpretResponse(
- {
- body: {
- ...sampleServerResponse,
- r: {
- [sampleRequestId]: [
- {
- ...sampleServerResponse.r[sampleRequestId][0],
- b: [
- {
- ...sampleServerResponse.r[sampleRequestId][0].b[0],
- ext: {
- bc: 'amx-pmp',
- ds: 'example',
- dsp: 'example-dsp',
- },
- },
- ],
- },
- ],
- },
- },
- },
- baseRequest
- );
-
- teardown(currentConfig);
- expect(parsed.length).to.equal(1); // we removed one
-
- // we should have display, video, display
- expect(parsed[0]).to.deep.equal({
- ...baseBidResponse,
- meta: {
- ...baseBidResponse.meta,
- mediaType: BANNER,
- demandSource: 'example',
- networkId: 'example-dsp',
- },
- mediaType: BANNER,
- bidderCode: 'amx-pmp',
- width: 300,
- height: 600, // from the bid itself
- ttl: 90,
- ad: sampleDisplayAd,
- });
- });
- });
-
- it('can parse a display ad', () => {
- const parsed = spec.interpretResponse(
- { body: sampleServerResponse },
- baseRequest
- );
- expect(parsed.length).to.equal(2);
-
- // we should have display, video, display
- expect(parsed[0]).to.deep.equal({
- ...baseBidResponse,
- meta: {
- ...baseBidResponse.meta,
- mediaType: BANNER,
- },
- mediaType: BANNER,
- width: 300,
- height: 600, // from the bid itself
- ttl: 90,
- ad: sampleDisplayAd,
- });
- });
-
- it('can parse a video ad', () => {
- const parsed = spec.interpretResponse(
- { body: sampleServerResponse },
- baseRequest
- );
- expect(parsed.length).to.equal(2);
- expect(parsed[1]).to.deep.equal({
- ...baseBidResponse,
- meta: {
- ...baseBidResponse.meta,
- mediaType: VIDEO,
- },
- mediaType: VIDEO,
- vastXml: sampleVideoAd(''),
- width: 300,
- height: 250,
- ttl: 90,
- });
- });
- });
-
- describe('analytics methods', () => {
- let firedPixels = [];
- let _Image = window.Image;
- before(() => {
- _Image = window.Image;
- window.Image = class FakeImage {
- _src = '';
-
- get src() {
- return this._src;
- }
-
- set src(value) {
- this._src = value;
- firedPixels.push(value);
- }
- };
- });
-
- beforeEach(() => {
- firedPixels = [];
- });
-
- after(() => {
- window.Image = _Image;
- });
-
- it('will fire an event for onSetTargeting', () => {
- spec.onSetTargeting({
- bidder: 'example',
- width: 300,
- height: 250,
- adId: 'ad-id',
- mediaType: BANNER,
- cpm: 1.23,
- requestId: utils.getUniqueIdentifierStr(),
- adUnitCode: 'div-gpt-ad',
- adserverTargeting: {
- hb_pb: '1.23',
- hb_adid: 'ad-id',
- hb_bidder: 'example',
- },
- });
- expect(firedPixels.length).to.equal(1);
- expect(firedPixels[0]).to.match(/\/hbx\/g_pbst/);
- try {
- const parsed = new URL(firedPixels[0]);
- const nestedData = parsed.searchParams.get('c2');
- expect(nestedData).to.equal(
- utils.formatQS({
- hb_pb: '1.23',
- hb_adid: 'ad-id',
- hb_bidder: 'example',
- })
- );
- } catch (e) {
- // unsupported browser; try testing for string
- const pixel = firedPixels[0];
- expect(pixel).to.have.string(encodeURIComponent('hb_pb=1.23'));
- expect(pixel).to.have.string(encodeURIComponent('hb_adid=ad-id'));
- }
- });
-
- it('will log an event for timeout', () => {
- // this will use sendBeacon..
- spec.onTimeout([
- {
- bidder: 'example',
- bidId: 'test-bid-id',
- adUnitCode: 'div-gpt-ad',
- ortb2: {
- site: {
- ref: 'https://example.com',
- },
- },
- params: {
- tagId: 'tag-id',
- },
- timeout: 300,
- auctionId: utils.getUniqueIdentifierStr(),
- },
- ]);
-
- const [request] = server.requests;
- request.respond(204, { 'Content-Type': 'text/html' }, null);
- expect(request.url).to.equal('https://1x1.a-mo.net/e');
-
- if (typeof Request !== 'undefined' && 'keepalive' in Request.prototype) {
- expect(request.fetch.request.keepalive).to.equal(true);
- }
-
- const { c: common, e: events } = JSON.parse(request.requestBody);
- expect(common).to.deep.equal({
- V: '$prebid.version$',
- vg: getGlobalVarName(),
- U: null,
- re: 'https://example.com',
- });
-
- expect(events.length).to.equal(1);
- const [event] = events;
- expect(event.n).to.equal('g_pbto');
- expect(event.A).to.equal('example');
- expect(event.mid).to.equal('tag-id');
- expect(event.cn).to.equal(300);
- expect(event.bid).to.equal('test-bid-id');
- expect(event.a).to.equal('div-gpt-ad');
- });
-
- it('will log an event for prebid win', () => {
- spec.onBidWon({
- bidder: 'example',
- adId: 'test-ad-id',
- width: 300,
- height: 250,
- mediaType: VIDEO,
- cpm: 1.34,
- adUnitCode: 'div-gpt-ad',
- timeout: 300,
- auctionId: utils.getUniqueIdentifierStr(),
- });
- expect(firedPixels.length).to.equal(1);
- expect(firedPixels[0]).to.match(/\/hbx\/g_pbwin/);
-
- const pixel = firedPixels[0];
- try {
- const url = new URL(pixel);
- expect(url.searchParams.get('C')).to.equal('1');
- expect(url.searchParams.get('np')).to.equal('1.34');
- } catch (e) {
- expect(pixel).to.have.string('C=1');
- expect(pixel).to.have.string('np=1.34');
- }
- });
- });
-});
diff --git a/test/spec/modules/aniviewBidAdapter_spec.js b/test/spec/modules/aniviewBidAdapter_spec.js
deleted file mode 100644
index d86902b47..000000000
--- a/test/spec/modules/aniviewBidAdapter_spec.js
+++ /dev/null
@@ -1,426 +0,0 @@
-import { spec } from 'modules/aniviewBidAdapter.js';
-import { newBidder } from 'src/adapters/bidderFactory.js';
-const { expect } = require('chai');
-
-const PUBLISHER_ID_1 = 'publisher_id_1';
-const CHANNEL_ID_1 = 'channel_id_1';
-const PUBLISHER_ID_2 = 'publisher_id_2';
-const CHANNEL_ID_2 = 'channel_id_2';
-const BID_ID_1 = 'bid_id_1';
-const BID_ID_2 = 'bid_id_2';
-const BIDDER_REQUEST_ID = 'bidder_request_id';
-const CUSTOM_DOMAIN = 'example.com';
-
-const BASE_URL = 'https://' + CUSTOM_DOMAIN + '/track' +
- '?rtbbp=10' +
- '&cpm=${AUCTION_PRICE}' +
- '&aucid=${AUCTION_ID}' +
- '&aucbid=${AUCTION_BID_ID}' +
- '&limid=${AUCTION_IMP_ID}' +
- '&aucseid=${AUCTION_SEAT_ID}' +
- '&aucadid=${AUCTION_AD_ID}';
-const LURL = `${BASE_URL}&e=AV_M40&rcd=\${AUCTION_LOSS}`;
-const NURL = `${BASE_URL}&e=AV_M4`;
-
-const VIDEO_VAST = `
`
-const BANNER_VAST = VIDEO_VAST;
-const BANNER_HTML = '
HTML BANNER
';
-
-const CURRENCY = 'USD';
-const PRICE = 10;
-const FLOOR_PRICE = PRICE * 0.5;
-const TTL = 600;
-
-const VIDEO_SIZE = { width: 640, height: 360 };
-const BANNER_SIZE = { width: 250, height: 250 };
-
-const CUSTOM_RENDERER_URL = `https://${CUSTOM_DOMAIN}/script/6.1/prebidRenderer.js`;
-const DEFAULT_RENDERER_URL = `https://player.aniview.com/script/6.1/prebidRenderer.js`;
-
-const REPLACEMENT_1 = '12345';
-
-const MOCK = {
- bidRequest: () => ({
- bidderCode: 'aniview',
- auctionId: null,
- bidderRequestId: BIDDER_REQUEST_ID,
- bids: [
- {
- bidder: 'aniview',
- params: {
- AV_PUBLISHERID: PUBLISHER_ID_1,
- AV_CHANNELID: CHANNEL_ID_1,
- playerDomain: CUSTOM_DOMAIN,
- },
- mediaTypes: {
- video: {
- playerSize: [[VIDEO_SIZE.width, VIDEO_SIZE.height]],
- context: 'outstream',
- mimes: ['video/mpeg', 'video/mp4', 'application/javascript'],
- }
- },
- bidId: BID_ID_1,
- bidderRequestId: BIDDER_REQUEST_ID,
- sizes: [[VIDEO_SIZE.width, VIDEO_SIZE.height]],
- },
- {
- bidder: 'aniview',
- params: {
- AV_PUBLISHERID: PUBLISHER_ID_2,
- AV_CHANNELID: CHANNEL_ID_2,
- playerDomain: CUSTOM_DOMAIN,
- replacements: {
- AV_CDIM1: REPLACEMENT_1,
- },
- },
- mediaTypes: {
- video: {
- playerSize: [[VIDEO_SIZE.width, VIDEO_SIZE.height]],
- context: 'outstream',
- mimes: ['video/mpeg', 'video/mp4', 'application/javascript'],
- }
- },
- bidId: BID_ID_2,
- bidderRequestId: BIDDER_REQUEST_ID,
- sizes: [[VIDEO_SIZE.width, VIDEO_SIZE.height]],
- floorData: {
- currency: CURRENCY,
- floor: FLOOR_PRICE,
- },
- getFloor: _ => ({
- currency: CURRENCY,
- floor: FLOOR_PRICE,
- }),
- },
- ],
- auctionStart: 1722343584268,
- timeout: 1_000,
- start: 1722343584269,
- ortb2: {
- source: {},
- site: {
- page: 'http://localhost:8080/',
- ref: 'http://localhost:8080/',
- domain: 'http://localhost:8080',
- publisher: {
- domain: 'http://localhost:8080',
- }
- },
- device: {
- w: 1800,
- h: 1169,
- language: 'en',
- },
- },
- }),
-
- bidderResponse: () => ({
- body: {
- id: 'bidder_response_id',
- bidid: 'bidder_response_bid_id',
- cur: CURRENCY,
- ext: {
- aniview: {
- sync: [
- { url: 'https://iframe-1.example.com/sync', e: 'sync', pr: '14', t: 3 },
- { url: 'https://iframe-2.example.com/sync', e: 'sync', pr: '28', t: 3 },
- { url: 'https://image.example.com/sync', e: 'sync', pr: 'abc12', t: 1 }
- ]
- }
- },
- seatbid: [
- {
- seat: '',
- bid: [
- {
- adm: VIDEO_VAST,
- adomain: [''],
- id: 'seatbid_bid_id_1',
- impid: BID_ID_1,
- lurl: LURL,
- nurl: NURL,
- price: PRICE,
- }
- ]
- }
- ]
- },
- })
-}
-
-describe('Aniview Bid Adapter', function () {
- const adapter = newBidder(spec);
-
- describe('Inherited function', function () {
- it('exists and is a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('isBidRequestValid', function () {
- let videoBidRequest;
-
- beforeEach(() => {
- videoBidRequest = MOCK.bidRequest();
- });
-
- it('should return `true` when required params found', function () {
- expect(spec.isBidRequestValid(videoBidRequest.bids[0])).to.be.true;
- });
-
- it('should return `false` when required params are wrong', function () {
- videoBidRequest.bids[0].params = { something: 'is wrong' };
-
- expect(spec.isBidRequestValid(videoBidRequest.bids[0])).to.be.false;
- });
- });
-
- describe('buildRequests', function () {
- let videoBidRequest;
-
- beforeEach(() => {
- videoBidRequest = MOCK.bidRequest();
- });
-
- it('should return expected request object', function () {
- const bidRequest = spec.buildRequests(videoBidRequest.bids, videoBidRequest);
-
- expect(bidRequest).to.exist.and.to.be.a('array').and.to.have.lengthOf(2);
-
- const { url, method, data } = bidRequest[0];
- const { ext, imp } = data;
-
- expect(url).equal('https://rtb.aniview.com/sspRTB2');
- expect(method).equal('POST');
- expect(imp[0].tagid).equal(CHANNEL_ID_1);
- expect(imp[0].id).equal(videoBidRequest.bids[0].bidId);
- expect(ext.aniview.pbjs).equal(1);
- });
-
- it('should have floor data inside imp', function () {
- const bidRequest = spec.buildRequests(videoBidRequest.bids, videoBidRequest);
- const imp = bidRequest[1].data.imp[0];
-
- expect(imp.bidfloor).equal(FLOOR_PRICE);
- expect(imp.bidfloorcur).equal(CURRENCY);
- });
-
- it('should have replacements in request', function () {
- const bidRequest = spec.buildRequests(videoBidRequest.bids, videoBidRequest);
- const { replacements } = bidRequest[1].data.ext.aniview;
-
- expect(replacements.AV_CDIM1).equal(REPLACEMENT_1);
- });
-
- it('should not have floor data in imp if getFloor returns empty object', function () {
- videoBidRequest.bids[1].getFloor = () => ({});
-
- const bidRequest = spec.buildRequests(videoBidRequest.bids, videoBidRequest);
- const imp = bidRequest[1].data.imp[0];
-
- expect(imp.bidfloor).not.exist;
- expect(imp.bidfloorcur).not.exist;
- });
-
- it('should have vastUrl if adm is not provided but nurl is', function () {
- const bidRequests = spec.buildRequests(videoBidRequest.bids, videoBidRequest);
- const bidderResponse = MOCK.bidderResponse();
-
- delete bidderResponse.body.seatbid[0].bid[0].adm
-
- const bids = spec.interpretResponse(bidderResponse, bidRequests[0]);
- const bid = bids[0];
-
- expect(bid.vastXml).to.not.exist;
- expect(bid.vastUrl).to.exist.and.to.not.have.string('${AUCTION_PRICE}');
- expect(bid.vastUrl).to.have.string('cpm=' + PRICE);
- });
-
- it('should use dev environment', function () {
- const DEV_ENDPOINT = 'https://dev.aniview.com/sspRTB2';
- videoBidRequest.bids[0].params.dev = { endpoint: DEV_ENDPOINT };
-
- const bidRequest = spec.buildRequests(videoBidRequest.bids, videoBidRequest);
-
- expect(bidRequest[0].url).to.equal(DEV_ENDPOINT);
- });
- });
-
- describe('interpretResponse', function () {
- describe('Video format', function () {
- let bidRequests, bidderResponse;
-
- beforeEach(function() {
- const videoBidRequest = MOCK.bidRequest();
-
- bidRequests = spec.buildRequests(videoBidRequest.bids, videoBidRequest);
- bidderResponse = MOCK.bidderResponse();
- });
-
- it('should return empty bids array for empty response', function () {
- const emptyResponse = bidderResponse.body = {};
- const bids = spec.interpretResponse(emptyResponse, bidRequests[0]);
-
- expect(bids).to.be.empty;
- });
-
- it('should return valid bids array', function () {
- const bids = spec.interpretResponse(bidderResponse, bidRequests[0]);
- const bid = bids[0];
-
- expect(bids.length).to.greaterThan(0);
- expect(bid.vastXml).to.exist.and.to.not.have.string('${AUCTION_PRICE}');
- expect(bid.vastXml).to.have.string('cpm=' + PRICE);
- expect(bid.vastUrl).to.not.exist;
- expect(bid.requestId).to.equal(bidRequests[0].data.imp[0].id);
- expect(bid.cpm).to.equal(PRICE);
- expect(bid.ttl).to.equal(TTL);
- expect(bid.currency).to.equal(CURRENCY);
- expect(bid.netRevenue).to.equal(true);
- expect(bid.mediaType).to.equal('video');
- expect(bid.meta.advertiserDomains).to.be.an('array');
- expect(bid.creativeId).to.exist;
- expect(bid.width).to.exist;
- expect(bid.height).to.exist;
- });
-
- it('should return bid without required properties if cpm less or equal 0', function () {
- bidderResponse.body.seatbid[0].bid[0].price = 0;
-
- const bids = spec.interpretResponse(bidderResponse, bidRequests[0]);
- const bid = bids[0];
-
- expect(bid.renderer).to.not.exist;
- expect(bid.ad).to.not.exist;
- });
-
- it('should return empty bids array if no bids in response', function () {
- bidderResponse.body.seatbid[0].bid = [];
-
- const bids = spec.interpretResponse(bidderResponse, bidRequests[0]);
-
- expect(bids).to.exist.and.to.be.a('array').and.to.have.lengthOf(0);
- });
-
- it('should add renderer if outstream context', function () {
- const bid = spec.interpretResponse(bidderResponse, bidRequests[0])[0];
-
- expect(bid.renderer.url).to.equal(CUSTOM_RENDERER_URL);
- expect(bid.renderer.config.AV_PUBLISHERID).to.equal(PUBLISHER_ID_1);
- expect(bid.renderer.config.AV_CHANNELID).to.equal(CHANNEL_ID_1);
- expect(bid.renderer.loaded).to.equal(false);
- expect(bid.width).to.equal(VIDEO_SIZE.width);
- expect(bid.height).to.equal(VIDEO_SIZE.height);
- });
-
- it('should use default renderer domain', function () {
- delete bidRequests[0].bids[0].params.playerDomain;
-
- const bid = spec.interpretResponse(bidderResponse, bidRequests[0])[0];
-
- expect(bid.renderer.url).to.equal(DEFAULT_RENDERER_URL);
- });
-
- it('should not add renderer if context is not outstream', function () {
- bidRequests[0].bids[0].mediaTypes.video.context = 'instream';
-
- const bid = spec.interpretResponse(bidderResponse, bidRequests[0])[0];
-
- expect(bidRequests[0].bids[0].mediaTypes.video.context).to.be.not.equal('outstream');
- expect(bid.renderer).to.not.exist;
- });
- });
-
- describe('Banner format', function () {
- let bidRequests, bidderResponse;
-
- beforeEach(function() {
- const bannerBidRequest = MOCK.bidRequest();
-
- // Converting video bid request to banner bid request
-
- delete bannerBidRequest.bids[0].mediaTypes.video;
-
- bannerBidRequest.bids[0].sizes = [[BANNER_SIZE.width, BANNER_SIZE.height]];
- bannerBidRequest.bids[0].mediaTypes.banner = {
- sizes: [
- [BANNER_SIZE.width, BANNER_SIZE.height],
- [BANNER_SIZE.width * 2, BANNER_SIZE.height],
- ],
- };
-
- bidRequests = spec.buildRequests(bannerBidRequest.bids, bannerBidRequest);
- bidderResponse = MOCK.bidderResponse();
- });
-
- it('should return valid banner bids (HTML)', function () {
- bidderResponse.body.seatbid[0].bid[0].adm = BANNER_HTML;
-
- const bid = spec.interpretResponse(bidderResponse, bidRequests[0])[0];
-
- expect(bid.ad).to.exist;
- expect(bid.cpm).to.equal(PRICE);
- expect(bid.width).to.equal(BANNER_SIZE.width);
- expect(bid.height).to.equal(BANNER_SIZE.height);
- expect(bid.renderer).to.not.exist;
- });
-
- it('should return valid banner bids (VAST) with renderer', function () {
- bidderResponse.body.seatbid[0].bid[0].adm = BANNER_VAST;
-
- const bid = spec.interpretResponse(bidderResponse, bidRequests[0])[0];
-
- expect(bid.ad).to.exist;
- expect(bid.ad).to.not.have.string('${AUCTION_PRICE}');
- expect(bid.ad).to.have.string('cpm=' + PRICE);
- expect(bid.cpm).to.equal(PRICE);
- expect(bid.width).to.equal(BANNER_SIZE.width);
- expect(bid.height).to.equal(BANNER_SIZE.height);
- expect(bid.renderer.url).to.equal(CUSTOM_RENDERER_URL);
- expect(bid.renderer.config.AV_PUBLISHERID).to.equal(PUBLISHER_ID_1);
- expect(bid.renderer.config.AV_CHANNELID).to.equal(CHANNEL_ID_1);
- expect(bid.renderer.loaded).to.equal(false);
- });
- });
- });
-
- describe('getUserSyncs', function () {
- let bidRequest, bidderResponse;
-
- beforeEach(function() {
- const videoBidRequest = MOCK.bidRequest();
-
- bidRequest = spec.buildRequests(videoBidRequest.bids, videoBidRequest);
- bidderResponse = MOCK.bidderResponse();
- });
-
- it('should get syncs from response', function () {
- const syncs = spec.getUserSyncs({ iframeEnabled: true, pixelEnabled: true }, [bidderResponse]);
-
- expect(syncs).to.be.a('array').and.to.have.lengthOf(3);
- });
-
- it('should get only pixel syncs from response', function () {
- const syncs = spec.getUserSyncs({ iframeEnabled: false, pixelEnabled: true }, [bidderResponse]);
-
- expect(syncs).to.be.a('array').and.to.have.lengthOf(1);
- expect(syncs[0].type).to.equal('image');
- });
-
- it('should return empty array of syncs if no syncs in response', function () {
- delete bidderResponse.body.ext.aniview.sync
-
- const syncs = spec.getUserSyncs({ iframeEnabled: true, pixelEnabled: false }, [bidderResponse]);
-
- expect(syncs).to.be.a('array').and.to.have.lengthOf(0);
- });
-
- it('should return empty array of syncs if no body in response', function () {
- delete bidderResponse.body
-
- const syncs = spec.getUserSyncs({ iframeEnabled: true, pixelEnabled: true }, [bidderResponse]);
-
- expect(syncs).to.be.a('array').and.to.have.lengthOf(0);
- });
- });
-});
diff --git a/test/spec/modules/anonymisedRtdProvider_spec.js b/test/spec/modules/anonymisedRtdProvider_spec.js
deleted file mode 100644
index 91d3fe1bf..000000000
--- a/test/spec/modules/anonymisedRtdProvider_spec.js
+++ /dev/null
@@ -1,324 +0,0 @@
-import {config} from 'src/config.js';
-import {getRealTimeData, anonymisedRtdSubmodule, storage} from 'modules/anonymisedRtdProvider.js';
-import { loadExternalScriptStub } from 'test/mocks/adloaderStub.js';
-
-describe('anonymisedRtdProvider', function() {
- let getDataFromLocalStorageStub;
-
- const testReqBidsConfigObj = {
- adUnits: [
- {
- bids: ['bid1', 'bid2']
- }
- ]
- };
-
- const onDone = function() { return true };
-
- const cmoduleConfig = {
- 'name': 'anonymised',
- 'params': {
- 'cohortStorageKey': 'cohort_ids'
- }
- }
-
- beforeEach(function() {
- config.resetConfig();
- getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage')
- });
-
- afterEach(function () {
- getDataFromLocalStorageStub.restore();
- });
-
- describe('anonymisedRtdSubmodule', function() {
- it('successfully instantiates', function () {
- expect(anonymisedRtdSubmodule.init()).to.equal(true);
- });
- it('should load external script when params.tagConfig.clientId is set', function () {
- const rtdConfig = {
- params: {
- tagConfig: {
- clientId: 'testId'
- }
- }
- };
- anonymisedRtdSubmodule.init(rtdConfig, {});
- expect(loadExternalScriptStub.called).to.be.true;
- });
- it('should not load external script when params.tagConfig.clientId is not set', function () {
- const rtdConfig = {
- params: {
- tagConfig: {}
- }
- };
- anonymisedRtdSubmodule.init(rtdConfig, {});
- expect(loadExternalScriptStub.called).to.be.false;
- });
- it('should not load external script when params.tagConfig is not defined', function () {
- const rtdConfig = {
- params: {}
- };
- anonymisedRtdSubmodule.init(rtdConfig, {});
- expect(loadExternalScriptStub.called).to.be.false;
- });
- it('should not load external script when params.tagConfig.clientId is empty string', function () {
- const rtdConfig = {
- params: {
- tagConfig: {
- clientId: ' '
- }
- }
- };
- anonymisedRtdSubmodule.init(rtdConfig, {});
- expect(loadExternalScriptStub.called).to.be.false;
- });
- it('should not load external script when params.tagConfig.clientId is not a string', function () {
- const rtdConfig = {
- params: {
- tagConfig: {
- clientId: 123
- }
- }
- };
- anonymisedRtdSubmodule.init(rtdConfig, {});
- expect(loadExternalScriptStub.called).to.be.false;
- });
- it('should load external script with correct attributes', function () {
- const rtdConfig = {
- params: {
- tagConfig: {
- clientId: 'testId'
- }
- }
- };
- anonymisedRtdSubmodule.init(rtdConfig, {});
- const expected = 'https://static.anonymised.io/light/loader.js?ref=prebid';
- const expectedTagConfig = {
- idw_client_id: 'testId'
- };
-
- expect(loadExternalScriptStub.args[0][0]).to.deep.equal(expected);
- expect(loadExternalScriptStub.args[0][5]).to.deep.equal(expectedTagConfig);
- });
- it('should not load external script when it is already loaded', function () {
- const rtdConfig = {
- params: {
- tagConfig: {
- clientId: 'testId'
- }
- }
- };
- const script = document.createElement('script');
- script.src = 'https://static.anonymised.io/light/loader.js?random=quary';
- document.body.appendChild(script);
- anonymisedRtdSubmodule.init(rtdConfig, {});
- expect(loadExternalScriptStub.called).to.be.false;
- });
- it('should load external script from tagUrl when it is set', function () {
- const rtdConfig = {
- params: {
- tagUrl: 'https://example.io/loader.js',
- tagConfig: {
- clientId: 'testId'
- }
- }
- };
- anonymisedRtdSubmodule.init(rtdConfig, {});
- const expected = 'https://example.io/loader.js';
-
- expect(loadExternalScriptStub.args[0][0]).to.deep.equal(expected);
- });
- it('should not load external script from tagUrl when it is already loaded', function () {
- const rtdConfig = {
- params: {
- tagUrl: 'https://example.io/loader.js',
- tagConfig: {
- clientId: 'testId'
- }
- }
- };
- const script = document.createElement('script');
- script.src = 'https://example.io/loader.js';
- document.body.appendChild(script);
- anonymisedRtdSubmodule.init(rtdConfig, {});
- expect(loadExternalScriptStub.called).to.be.false;
- });
- });
-
- describe('Get Real-Time Data', function() {
- it('gets rtd from local storage and set to ortb2.user.data', function() {
- const rtdConfig = {
- params: {
- cohortStorageKey: 'cohort_ids',
- bidders: ['smartadserver'],
- segtax: 503
- }
- };
-
- const bidConfig = {
- ortb2Fragments: {
- global: {}
- }
- };
-
- const rtdUserObj1 = {
- name: 'anonymised.io',
- ext: {
- segtax: 503
- },
- segment: [
- {
- id: 'TCZPQOWPEJG3MJOTUQUF793A'
- },
- {
- id: '93SUG3H540WBJMYNT03KX8N3'
- }
- ]
- };
-
- getDataFromLocalStorageStub.withArgs('cohort_ids')
- .returns(JSON.stringify(['TCZPQOWPEJG3MJOTUQUF793A', '93SUG3H540WBJMYNT03KX8N3']));
-
- getRealTimeData(bidConfig, () => {}, rtdConfig, {});
- expect(bidConfig.ortb2Fragments.global.user.data).to.deep.include.members([rtdUserObj1]);
- expect(bidConfig.ortb2Fragments.global.user.keywords).to.be.undefined;
- });
-
- it('gets rtd from local storage and set to ortb2.user.keywords for appnexus bidders parameter', function() {
- const rtdConfig = {
- params: {
- cohortStorageKey: 'cohort_ids',
- bidders: ['smartadserver', 'appnexus'],
- segtax: 503
- }
- };
-
- const bidConfig = {
- ortb2Fragments: {
- global: {}
- }
- };
-
- const rtdUserObj1 = {
- name: 'anonymised.io',
- ext: {
- segtax: 503
- },
- segment: [
- {
- id: 'TCZPQOWPEJG3MJOTUQUF793A'
- },
- {
- id: '93SUG3H540WBJMYNT03KX8N3'
- }
- ]
- };
-
- getDataFromLocalStorageStub.withArgs('cohort_ids')
- .returns(JSON.stringify(['TCZPQOWPEJG3MJOTUQUF793A', '93SUG3H540WBJMYNT03KX8N3']));
-
- getRealTimeData(bidConfig, () => {}, rtdConfig, {});
- expect(bidConfig.ortb2Fragments.global.user.data).to.deep.include.members([rtdUserObj1]);
- expect(bidConfig.ortb2Fragments.global.user.keywords).to.include('perid=TCZPQOWPEJG3MJOTUQUF793A');
- expect(bidConfig.ortb2Fragments.global.user.keywords).to.include('perid=93SUG3H540WBJMYNT03KX8N3');
- });
-
- it('gets rtd from local storage and set to ortb2.user.data if `bidders` parameter undefined', function() {
- const rtdConfig = {
- params: {
- cohortStorageKey: 'cohort_ids',
- segtax: 503
- }
- };
-
- const bidConfig = {
- ortb2Fragments: {
- global: {}
- }
- };
-
- const rtdUserObj1 = {
- name: 'anonymised.io',
- ext: {
- segtax: 503
- },
- segment: [
- {
- id: 'TCZPQOWPEJG3MJOTUQUF793A'
- },
- {
- id: '93SUG3H540WBJMYNT03KX8N3'
- }
- ]
- };
-
- getDataFromLocalStorageStub.withArgs('cohort_ids')
- .returns(JSON.stringify(['TCZPQOWPEJG3MJOTUQUF793A', '93SUG3H540WBJMYNT03KX8N3']));
-
- getRealTimeData(bidConfig, () => {}, rtdConfig, {});
- expect(bidConfig.ortb2Fragments.global.user.data).to.deep.include.members([rtdUserObj1]);
- expect(bidConfig.ortb2Fragments.global.user.keywords).to.be.undefined;
- });
-
- it('do not set rtd if `cohortStorageKey` parameter undefined', function() {
- const rtdConfig = {
- params: {
- bidders: ['smartadserver']
- }
- };
-
- const bidConfig = {
- ortb2Fragments: {
- global: {}
- }
- };
-
- getDataFromLocalStorageStub.withArgs('cohort_ids')
- .returns(JSON.stringify(['randomsegmentid']));
-
- getRealTimeData(bidConfig, () => {}, rtdConfig, {});
- expect(bidConfig.ortb2Fragments.global.user).to.be.undefined;
- });
-
- it('do not set rtd if local storage empty', function() {
- const rtdConfig = {
- params: {
- cohortStorageKey: 'cohort_ids',
- segtax: 503
- }
- };
-
- const bidConfig = {};
-
- getDataFromLocalStorageStub.withArgs('cohort_ids')
- .returns(null);
-
- expect(config.getConfig().ortb2).to.be.undefined;
- getRealTimeData(bidConfig, () => {}, rtdConfig, {});
- expect(config.getConfig().ortb2).to.be.undefined;
- });
-
- it('do not set rtd if local storage has incorrect value', function() {
- const rtdConfig = {
- params: {
- cohortStorageKey: 'cohort_ids',
- segtax: 503
- }
- };
-
- const bidConfig = {};
-
- getDataFromLocalStorageStub.withArgs('cohort_ids')
- .returns('wrong cohort ids value');
-
- expect(config.getConfig().ortb2).to.be.undefined;
- getRealTimeData(bidConfig, () => {}, rtdConfig, {});
- expect(config.getConfig().ortb2).to.be.undefined;
- });
-
- it('should initialize and return with config', function () {
- expect(getRealTimeData(testReqBidsConfigObj, onDone, cmoduleConfig)).to.equal(undefined)
- });
- });
-});
diff --git a/test/spec/modules/anyclipBidAdapter_spec.js b/test/spec/modules/anyclipBidAdapter_spec.js
deleted file mode 100644
index a25c285e6..000000000
--- a/test/spec/modules/anyclipBidAdapter_spec.js
+++ /dev/null
@@ -1,449 +0,0 @@
-import {expect} from 'chai';
-import {config} from 'src/config.js';
-import {spec} from 'modules/anyclipBidAdapter.js';
-import {deepClone} from 'src/utils';
-import {getBidFloor} from '../../../libraries/xeUtils/bidderUtils.js';
-
-const ENDPOINT = 'https://prebid.anyclip.com';
-
-const defaultRequest = {
- tmax: 0,
- adUnitCode: 'test',
- bidId: '1',
- requestId: 'qwerty',
- ortb2: {
- source: {
- tid: 'auctionId'
- }
- },
- ortb2Imp: {
- ext: {
- tid: 'tr1',
- }
- },
- mediaTypes: {
- banner: {
- sizes: [
- [300, 250],
- [300, 200]
- ]
- }
- },
- bidder: 'anyclip',
- params: {
- publisherId: 'anyclip',
- supplyTagId: '40',
- ext: {}
- },
- bidRequestsCount: 1
-};
-
-const defaultRequestVideo = deepClone(defaultRequest);
-defaultRequestVideo.mediaTypes = {
- video: {
- playerSize: [640, 480],
- context: 'instream',
- skipppable: true
- }
-};
-
-const videoBidderRequest = {
- bidderCode: 'anyclip',
- bids: [{mediaTypes: {video: {}}, bidId: 'qwerty'}]
-};
-
-const displayBidderRequest = {
- bidderCode: 'anyclip',
- bids: [{bidId: 'qwerty'}]
-};
-
-describe('anyclipBidAdapter', () => {
- describe('isBidRequestValid', function () {
- it('should return false when request params is missing', function () {
- const invalidRequest = deepClone(defaultRequest);
- delete invalidRequest.params;
- expect(spec.isBidRequestValid(invalidRequest)).to.equal(false);
- });
-
- it('should return false when required publisherId param is missing', function () {
- const invalidRequest = deepClone(defaultRequest);
- delete invalidRequest.params.publisherId;
- expect(spec.isBidRequestValid(invalidRequest)).to.equal(false);
- });
-
- it('should return false when required supplyTagId param is missing', function () {
- const invalidRequest = deepClone(defaultRequest);
- delete invalidRequest.params.supplyTagId;
- expect(spec.isBidRequestValid(invalidRequest)).to.equal(false);
- });
-
- it('should return false when video.playerSize is missing', function () {
- const invalidRequest = deepClone(defaultRequestVideo);
- delete invalidRequest.mediaTypes.video.playerSize;
- expect(spec.isBidRequestValid(invalidRequest)).to.equal(false);
- });
-
- it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(defaultRequest)).to.equal(true);
- });
- });
-
- describe('buildRequests', function () {
- beforeEach(function () {
- config.resetConfig();
- });
-
- it('should send request with correct structure', function () {
- const request = spec.buildRequests([defaultRequest], {});
- expect(request.method).to.equal('POST');
- expect(request.url).to.equal(ENDPOINT + '/bid');
- expect(request.options).to.have.property('contentType').and.to.equal('application/json');
- expect(request).to.have.property('data');
- });
-
- it('should build basic request structure', function () {
- const request = JSON.parse(spec.buildRequests([defaultRequest], {}).data)[0];
- expect(request).to.have.property('tmax').and.to.equal(defaultRequest.tmax);
- expect(request).to.have.property('bidId').and.to.equal(defaultRequest.bidId);
- expect(request).to.have.property('auctionId').and.to.equal(defaultRequest.ortb2.source.tid);
- expect(request).to.have.property('transactionId').and.to.equal(defaultRequest.ortb2Imp.ext.tid);
- expect(request).to.have.property('tz').and.to.equal(new Date().getTimezoneOffset());
- expect(request).to.have.property('bc').and.to.equal(1);
- expect(request).to.have.property('banner').and.to.deep.equal({sizes: [[300, 250], [300, 200]]});
- expect(request).to.have.property('gdprConsent').and.to.deep.equal({});
- expect(request).to.have.property('userEids').and.to.deep.equal([]);
- expect(request).to.have.property('usPrivacy').and.to.equal('');
- expect(request).to.have.property('sizes').and.to.deep.equal(['300x250', '300x200']);
- expect(request).to.have.property('ext').and.to.deep.equal({});
- expect(request).to.have.property('env').and.to.deep.equal({
- publisherId: 'anyclip',
- supplyTagId: '40',
- floor: null
- });
- expect(request).to.have.property('device').and.to.deep.equal({
- ua: navigator.userAgent,
- lang: navigator.language
- });
- });
-
- it('should build request with schain', function () {
- const schainRequest = deepClone(defaultRequest);
- const bidderRequest = {
- ortb2: {
- source: {
- ext: {
- schain: {
- ver: '1.0'
- }
- }
- }
- }
- };
- const request = JSON.parse(spec.buildRequests([schainRequest], bidderRequest).data)[0];
- expect(request).to.have.property('schain').and.to.deep.equal({
- ver: '1.0'
- });
- });
-
- it('should build request with location', function () {
- const bidderRequest = {
- refererInfo: {
- page: 'page',
- location: 'location',
- domain: 'domain',
- ref: 'ref',
- isAmp: false
- }
- };
- const request = JSON.parse(spec.buildRequests([defaultRequest], bidderRequest).data)[0];
- expect(request).to.have.property('location');
- const location = request.location;
- expect(location).to.have.property('page').and.to.equal('page');
- expect(location).to.have.property('location').and.to.equal('location');
- expect(location).to.have.property('domain').and.to.equal('domain');
- expect(location).to.have.property('ref').and.to.equal('ref');
- expect(location).to.have.property('isAmp').and.to.equal(false);
- });
-
- it('should build request with ortb2 info', function () {
- const ortb2Request = deepClone(defaultRequest);
- ortb2Request.ortb2 = {
- site: {
- name: 'name'
- }
- };
- const request = JSON.parse(spec.buildRequests([ortb2Request], {}).data)[0];
- expect(request).to.have.property('ortb2').and.to.deep.equal({
- site: {
- name: 'name'
- }
- });
- });
-
- it('should build request with ortb2Imp info', function () {
- const ortb2ImpRequest = deepClone(defaultRequest);
- ortb2ImpRequest.ortb2Imp = {
- ext: {
- data: {
- pbadslot: 'home1',
- adUnitSpecificAttribute: '1'
- }
- }
- };
- const request = JSON.parse(spec.buildRequests([ortb2ImpRequest], {}).data)[0];
- expect(request).to.have.property('ortb2Imp').and.to.deep.equal({
- ext: {
- data: {
- pbadslot: 'home1',
- adUnitSpecificAttribute: '1'
- }
- }
- });
- });
-
- it('should build request with valid bidfloor', function () {
- const bfRequest = deepClone(defaultRequest);
- bfRequest.getFloor = () => ({floor: 5, currency: 'USD'});
- const request = JSON.parse(spec.buildRequests([bfRequest], {}).data)[0].env;
- expect(request).to.have.property('floor').and.to.equal(5);
- });
-
- it('should build request with usp consent data if applies', function () {
- const bidderRequest = {
- uspConsent: '1YA-'
- };
- const request = JSON.parse(spec.buildRequests([defaultRequest], bidderRequest).data)[0];
- expect(request).to.have.property('usPrivacy').and.equals('1YA-');
- });
-
- it('should build request with extended ids', function () {
- const idRequest = deepClone(defaultRequest);
- idRequest.userIdAsEids = [
- {source: 'adserver.org', uids: [{id: 'TTD_ID_FROM_USER_ID_MODULE', atype: 1, ext: {rtiPartner: 'TDID'}}]},
- {source: 'pubcid.org', uids: [{id: 'pubCommonId_FROM_USER_ID_MODULE', atype: 1}]}
- ];
- const request = JSON.parse(spec.buildRequests([idRequest], {}).data)[0];
- expect(request).to.have.property('userEids').and.deep.equal(idRequest.userIdAsEids);
- });
-
- it('should build request with video', function () {
- const request = JSON.parse(spec.buildRequests([defaultRequestVideo], {}).data)[0];
- expect(request).to.have.property('video').and.to.deep.equal({
- playerSize: [640, 480],
- context: 'instream',
- skipppable: true
- });
- expect(request).to.have.property('sizes').and.to.deep.equal(['640x480']);
- });
- });
-
- describe('interpretResponse', function () {
- it('should return empty bids', function () {
- const serverResponse = {
- body: {
- data: null
- }
- };
-
- const invalidResponse = spec.interpretResponse(serverResponse, {});
- expect(invalidResponse).to.be.an('array').that.is.empty;
- });
-
- it('should interpret valid response', function () {
- const serverResponse = {
- body: {
- data: [{
- requestId: 'qwerty',
- cpm: 1,
- currency: 'USD',
- width: 300,
- height: 250,
- ttl: 600,
- meta: {
- advertiserDomains: ['anyclip']
- },
- ext: {
- pixels: [
- ['iframe', 'surl1'],
- ['image', 'surl2'],
- ]
- }
- }]
- }
- };
-
- const validResponse = spec.interpretResponse(serverResponse, {bidderRequest: displayBidderRequest});
- const bid = validResponse[0];
- expect(validResponse).to.be.an('array').that.is.not.empty;
- expect(bid.requestId).to.equal('qwerty');
- expect(bid.cpm).to.equal(1);
- expect(bid.currency).to.equal('USD');
- expect(bid.width).to.equal(300);
- expect(bid.height).to.equal(250);
- expect(bid.ttl).to.equal(600);
- expect(bid.meta).to.deep.equal({advertiserDomains: ['anyclip']});
- });
-
- it('should interpret valid banner response', function () {
- const serverResponse = {
- body: {
- data: [{
- requestId: 'qwerty',
- cpm: 1,
- currency: 'USD',
- width: 300,
- height: 250,
- ttl: 600,
- mediaType: 'banner',
- creativeId: 'xe-demo-banner',
- ad: 'ad',
- meta: {}
- }]
- }
- };
-
- const validResponseBanner = spec.interpretResponse(serverResponse, {bidderRequest: displayBidderRequest});
- const bid = validResponseBanner[0];
- expect(validResponseBanner).to.be.an('array').that.is.not.empty;
- expect(bid.mediaType).to.equal('banner');
- expect(bid.creativeId).to.equal('xe-demo-banner');
- expect(bid.ad).to.equal('ad');
- });
-
- it('should interpret valid video response', function () {
- const serverResponse = {
- body: {
- data: [{
- requestId: 'qwerty',
- cpm: 1,
- currency: 'USD',
- width: 600,
- height: 480,
- ttl: 600,
- mediaType: 'video',
- creativeId: 'xe-demo-video',
- ad: 'vast-xml',
- meta: {}
- }]
- }
- };
-
- const validResponseBanner = spec.interpretResponse(serverResponse, {bidderRequest: videoBidderRequest});
- const bid = validResponseBanner[0];
- expect(validResponseBanner).to.be.an('array').that.is.not.empty;
- expect(bid.mediaType).to.equal('video');
- expect(bid.creativeId).to.equal('xe-demo-video');
- expect(bid.ad).to.equal('vast-xml');
- });
- });
-
- describe('getUserSyncs', function () {
- it('shoukd handle no params', function () {
- const opts = spec.getUserSyncs({}, []);
- expect(opts).to.be.an('array').that.is.empty;
- });
-
- it('should return empty if sync is not allowed', function () {
- const opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: false});
- expect(opts).to.be.an('array').that.is.empty;
- });
-
- it('should allow iframe sync', function () {
- const opts = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: false}, [{
- body: {
- data: [{
- requestId: 'qwerty',
- ext: {
- pixels: [
- ['iframe', 'surl1?a=b'],
- ['image', 'surl2?a=b'],
- ]
- }
- }]
- }
- }]);
- expect(opts.length).to.equal(1);
- expect(opts[0].type).to.equal('iframe');
- expect(opts[0].url).to.equal('surl1?a=b&us_privacy=&gdpr=0&gdpr_consent=');
- });
-
- it('should allow pixel sync', function () {
- const opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [{
- body: {
- data: [{
- requestId: 'qwerty',
- ext: {
- pixels: [
- ['iframe', 'surl1?a=b'],
- ['image', 'surl2?a=b'],
- ]
- }
- }]
- }
- }]);
- expect(opts.length).to.equal(1);
- expect(opts[0].type).to.equal('image');
- expect(opts[0].url).to.equal('surl2?a=b&us_privacy=&gdpr=0&gdpr_consent=');
- });
-
- it('should allow pixel sync and parse consent params', function () {
- const opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [{
- body: {
- data: [{
- requestId: 'qwerty',
- ext: {
- pixels: [
- ['iframe', 'surl1?a=b'],
- ['image', 'surl2?a=b'],
- ]
- }
- }]
- }
- }], {
- gdprApplies: 1,
- consentString: '1YA-'
- });
- expect(opts.length).to.equal(1);
- expect(opts[0].type).to.equal('image');
- expect(opts[0].url).to.equal('surl2?a=b&us_privacy=&gdpr=1&gdpr_consent=1YA-');
- });
- });
-
- describe('getBidFloor', function () {
- it('should return null when getFloor is not a function', () => {
- const bid = {getFloor: 2};
- const result = getBidFloor(bid);
- expect(result).to.be.null;
- });
-
- it('should return null when getFloor doesnt return an object', () => {
- const bid = {getFloor: () => 2};
- const result = getBidFloor(bid);
- expect(result).to.be.null;
- });
-
- it('should return null when floor is not a number', () => {
- const bid = {
- getFloor: () => ({floor: 'string', currency: 'USD'})
- };
- const result = getBidFloor(bid);
- expect(result).to.be.null;
- });
-
- it('should return null when currency is not USD', () => {
- const bid = {
- getFloor: () => ({floor: 5, currency: 'EUR'})
- };
- const result = getBidFloor(bid);
- expect(result).to.be.null;
- });
-
- it('should return floor value when everything is correct', () => {
- const bid = {
- getFloor: () => ({floor: 5, currency: 'USD'})
- };
- const result = getBidFloor(bid);
- expect(result).to.equal(5);
- });
- });
-});
diff --git a/test/spec/modules/apacdexBidAdapter_spec.js b/test/spec/modules/apacdexBidAdapter_spec.js
deleted file mode 100644
index 7bcbcac5e..000000000
--- a/test/spec/modules/apacdexBidAdapter_spec.js
+++ /dev/null
@@ -1,734 +0,0 @@
-import { expect } from 'chai'
-import { spec, validateGeoObject, getDomain } from '../../../modules/apacdexBidAdapter.js'
-import { newBidder } from 'src/adapters/bidderFactory.js'
-import { userSync } from '../../../src/userSync.js';
-import { config } from 'src/config.js';
-import { deepClone } from 'src/utils.js';
-
-describe('ApacdexBidAdapter', function () {
- const adapter = newBidder(spec)
-
- describe('.code', function () {
- it('should return a bidder code of apacdex', function () {
- expect(spec.code).to.equal('apacdex')
- })
- })
-
- describe('inherited functions', function () {
- it('should exist and be a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function')
- })
- })
-
- describe('.isBidRequestValid', function () {
- it('should return false if there are no params', () => {
- const bid = {
- 'bidder': 'apacdex',
- 'adUnitCode': 'adunit-code',
- 'mediaTypes': {
- banner: {
- sizes: [[300, 250], [300, 600]]
- }
- },
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- };
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return false if there is no siteId or placementId param', () => {
- const bid = {
- 'bidder': 'apacdex',
- 'adUnitCode': 'adunit-code',
- params: {
- site_id: '1a2b3c4d5e6f1a2b3c4d',
- placement_id: 'plcm12345678',
- },
- 'mediaTypes': {
- banner: {
- sizes: [[300, 250], [300, 600]]
- }
- },
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- };
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return false if there is no mediaTypes', () => {
- const bid = {
- 'bidder': 'apacdex',
- 'adUnitCode': 'adunit-code',
- params: {
- siteId: '1a2b3c4d5e6f1a2b3c4d'
- },
- 'mediaTypes': {
- },
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- };
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return true if the bid is valid', () => {
- const bid = {
- 'bidder': 'apacdex',
- 'adUnitCode': 'adunit-code',
- params: {
- siteId: '1a2b3c4d5e6f1a2b3c4d'
- },
- 'mediaTypes': {
- banner: {
- sizes: [[300, 250], [300, 600]]
- }
- },
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- };
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- describe('banner', () => {
- it('should return false if there are no banner sizes', () => {
- const bid = {
- 'bidder': 'apacdex',
- 'adUnitCode': 'adunit-code',
- params: {
- siteId: '1a2b3c4d5e6f1a2b3c4d'
- },
- 'mediaTypes': {
- banner: {
-
- }
- },
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- };
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return true if there is banner sizes', () => {
- const bid = {
- 'bidder': 'apacdex',
- 'adUnitCode': 'adunit-code',
- params: {
- siteId: '1a2b3c4d5e6f1a2b3c4d'
- },
- 'mediaTypes': {
- banner: {
- sizes: [[300, 250], [300, 600]]
- }
- },
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- };
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
- });
-
- describe('video', () => {
- it('should return false if there is no playerSize defined in the video mediaType', () => {
- const bid = {
- 'bidder': 'apacdex',
- 'adUnitCode': 'adunit-code',
- params: {
- siteId: '1a2b3c4d5e6f1a2b3c4d',
- sizes: [[300, 250], [300, 600]]
- },
- 'mediaTypes': {
- video: {
- context: 'instream'
- }
- },
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- };
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return true if there is playerSize defined on the video mediaType', () => {
- const bid = {
- 'bidder': 'apacdex',
- 'adUnitCode': 'adunit-code',
- params: {
- siteId: '1a2b3c4d5e6f1a2b3c4d',
- },
- 'mediaTypes': {
- video: {
- context: 'instream',
- playerSize: [[640, 480]]
- }
- },
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- };
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
- });
- });
-
- describe('.buildRequests', function () {
- beforeEach(function () {
- sinon.stub(userSync, 'canBidderRegisterSync');
- });
- afterEach(function () {
- userSync.canBidderRegisterSync.restore();
- });
- const bidRequest = [{
- 'ortb2': {
- 'source': {
- 'ext': {
- 'schain': {
- 'ver': '1.0',
- 'complete': 1,
- 'nodes': [
- {
- 'asi': 'indirectseller.com',
- 'sid': '00001',
- 'hp': 1
- },
- {
- 'asi': 'indirectseller-2.com',
- 'sid': '00002',
- 'hp': 0
- },
- ]
- }
- }
- }
- },
- 'bidder': 'apacdex',
- 'params': {
- 'siteId': '1a2b3c4d5e6f1a2b3c4d'
- },
- 'adUnitCode': 'adunit-code-1',
- 'sizes': [[300, 250], [300, 600]],
- 'targetKey': 0,
- 'bidId': '30b31c1838de1f',
- 'userIdAsEids': [{
- 'source': 'criteo.com',
- 'uids': [{
- 'id': 'p0cCLF9JazY1ZUFjazJRb3NKbEprVTcwZ0IwRUlGalBjOG9laUZNbFJ0ZGpOSnVFbE9VMjBNMzNBTzladGt4cUVGQzBybDY2Y1FqT1dkUkFsMmJIWDRHNjlvNXJjbiUyQlZDd1dOTmt6VlV2TDhRd0F0RTlBcmpyZU5WRHBPU25GQXpyMnlT',
- 'atype': 1
- }]
- }, {
- 'source': 'pubcid.org',
- 'uids': [{
- 'id': '2ae366c2-2576-45e5-bd21-72ed10598f17',
- 'atype': 1
- }]
- }],
- },
- {
- 'bidder': 'apacdex',
- 'params': {
- 'ad_unit': '/7780971/sparks_prebid_LB',
- 'sizes': [[300, 250], [300, 600]],
- 'referrer': 'overrides_top_window_location'
- },
- 'adUnitCode': 'adunit-code-2',
- 'sizes': [[120, 600], [300, 600], [160, 600]],
- 'targetKey': 1,
- 'bidId': '30b31c1838de1e',
- }];
-
- const bidderRequests = {
- 'gdprConsent': {
- 'consentString': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==',
- 'vendorData': {},
- 'gdprApplies': true
- },
- 'refererInfo': {
- 'numIframes': 0,
- 'reachedTop': true,
- 'referer': 'https://example.com',
- 'stack': ['https://example.com']
- },
- uspConsent: 'someCCPAString'
- };
-
- it('should return a properly formatted request', function () {
- const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
- expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/pbjs')
- expect(bidRequests.method).to.equal('POST')
- expect(bidRequests.bidderRequests).to.eql(bidRequest);
- })
-
- it('should return a properly formatted request with GDPR applies set to true', function () {
- const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
- expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/pbjs')
- expect(bidRequests.method).to.equal('POST')
- expect(bidRequests.data.gdpr.gdprApplies).to.equal(true)
- expect(bidRequests.data.gdpr.consentString).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==')
- })
-
- it('should return a properly formatted request with GDPR applies set to false', function () {
- bidderRequests.gdprConsent.gdprApplies = false;
- const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
- expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/pbjs')
- expect(bidRequests.method).to.equal('POST')
- expect(bidRequests.data.gdpr.gdprApplies).to.equal(false)
- expect(bidRequests.data.gdpr.consentString).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==')
- })
- it('should return a properly formatted request with GDPR applies set to false with no consent_string param', function () {
- const bidderRequests = {
- 'gdprConsent': {
- 'consentString': undefined,
- 'vendorData': {},
- 'gdprApplies': false
- },
- 'refererInfo': {
- 'numIframes': 0,
- 'reachedTop': true,
- 'referer': 'https://example.com',
- 'stack': ['https://example.com']
- }
- };
- const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
- expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/pbjs')
- expect(bidRequests.method).to.equal('POST')
- expect(bidRequests.data.gdpr.gdprApplies).to.equal(false)
- expect(bidRequests.data.gdpr).to.not.include.keys('consentString')
- })
- it('should return a properly formatted request with GDPR applies set to true with no consentString param', function () {
- const bidderRequests = {
- 'gdprConsent': {
- 'consentString': undefined,
- 'vendorData': {},
- 'gdprApplies': true
- },
- 'refererInfo': {
- 'numIframes': 0,
- 'reachedTop': true,
- 'referer': 'https://example.com',
- 'stack': ['https://example.com']
- }
- };
- const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
- expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/pbjs')
- expect(bidRequests.method).to.equal('POST')
- expect(bidRequests.data.gdpr.gdprApplies).to.equal(true)
- expect(bidRequests.data.gdpr).to.not.include.keys('consentString')
- })
- it('should return a properly formatted request with schain defined', function () {
- const bidRequests = spec.buildRequests(bidRequest, bidderRequests);
- expect(bidRequests.data.schain).to.deep.equal(bidRequest[0].ortb2.source.ext.schain)
- });
- it('should return a properly formatted request with eids defined', function () {
- const bidRequests = spec.buildRequests(bidRequest, bidderRequests);
- expect(bidRequests.data.eids).to.deep.equal(bidRequest[0].userIdAsEids)
- });
- it('should return a properly formatted request with us_privacy included', function () {
- const bidRequests = spec.buildRequests(bidRequest, bidderRequests);
- expect(bidRequests.data.us_privacy).to.equal('someCCPAString');
- });
- it('should attach bidFloor param when either bid param floorPrice or getFloor function exists', function () {
- const getFloorResponse = { currency: 'USD', floor: 3 };
- let singleBidRequest; let request; let payload = null;
-
- // 1 -> floorPrice not defined, getFloor not defined > empty
- singleBidRequest = deepClone(bidRequest[0]);
- request = spec.buildRequests([singleBidRequest], bidderRequests);
- payload = request.data;
- expect(payload.bids[0].bidFloor).to.not.exist;
-
- // 2 -> floorPrice is defined, getFloor not defined > floorPrice is used
- singleBidRequest = deepClone(bidRequest[0]);
- singleBidRequest.params = {
- 'siteId': '1890909',
- 'floorPrice': 0.5
- };
- request = spec.buildRequests([singleBidRequest], bidderRequests);
- payload = request.data
- expect(payload.bids[0].bidFloor).to.exist.and.to.equal(0.5);
-
- // 3 -> floorPrice is defined, getFloor is defined > getFloor is used
- singleBidRequest = deepClone(bidRequest[0]);
- singleBidRequest.params = {
- 'siteId': '1890909',
- 'floorPrice': 0.5
- };
- singleBidRequest.getFloor = () => getFloorResponse;
- request = spec.buildRequests([singleBidRequest], bidderRequests);
- payload = request.data
- expect(payload.bids[0].bidFloor).to.exist.and.to.equal(3);
-
- // 4 -> floorPrice not defined, getFloor is defined > getFloor is used
- singleBidRequest = deepClone(bidRequest[0]);
- singleBidRequest.getFloor = () => getFloorResponse;
- request = spec.buildRequests([singleBidRequest], bidderRequests);
- payload = request.data
- expect(payload.bids[0].bidFloor).to.exist.and.to.equal(3);
- });
- describe('debug test', function () {
- beforeEach(function () {
- config.setConfig({ debug: true });
- });
- afterEach(function () {
- config.setConfig({ debug: false });
- });
- it('should return a properly formatted request with pbjs_debug is true', function () {
- const bidRequests = spec.buildRequests(bidRequest, bidderRequests);
- expect(bidRequests.data.test).to.equal(1);
- });
- });
- });
-
- describe('.interpretResponse', function () {
- const bidRequests = {
- 'method': 'POST',
- 'url': 'https://useast.quantumdex.io/auction/pbjs',
- 'withCredentials': true,
- 'data': {
- 'device': {
- 'ua': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36',
- 'height': 937,
- 'width': 1920,
- 'dnt': 0,
- 'language': 'vi'
- },
- 'site': {
- 'id': '343',
- 'page': 'https://www.example.com/page',
- 'referrer': '',
- 'hostname': 'www.example.com'
- }
- },
- 'bidderRequests': [
- {
- 'bidder': 'apacdex',
- 'params': {
- 'siteId': '343'
- },
- 'crumbs': {
- 'pubcid': 'c2b2ba08-9954-4850-8ee5-2bf4a2b35eff'
- },
- 'mediaTypes': {
- 'banner': {
- 'sizes': [[160, 600], [120, 600]]
- }
- },
- 'adUnitCode': 'vi_3431035_1',
- 'transactionId': '994d8404-4a28-4c43-98d8-a38dbb061910',
- 'sizes': [[160, 600], [120, 600]],
- 'bidId': '3000aa31c41a29c21',
- 'bidderRequestId': '299926b3d3628cdd7',
- 'auctionId': '22445943-a0aa-4c63-a413-4deb64fcff1c',
- 'src': 'client',
- 'bidRequestsCount': 41,
- 'bidderRequestsCount': 41,
- 'bidderWinsCount': 0,
- 'schain': {
- 'ver': '1.0',
- 'complete': 1,
- 'nodes': [
- {
- 'asi': 'freegames66.com',
- 'sid': '343',
- 'hp': 1
- }
- ]
- }
- },
- {
- 'bidder': 'apacdex',
- 'params': {
- 'siteId': '343'
- },
- 'crumbs': {
- 'pubcid': 'c2b2ba08-9954-4850-8ee5-2bf4a2b35eff'
- },
- 'mediaTypes': {
- 'banner': {
- 'sizes': [[300, 250], [250, 250], [200, 200], [180, 150]]
- }
- },
- 'adUnitCode': 'vi_3431033_1',
- 'transactionId': '800fe87e-bfec-43a5-ace0-c4e2373ff4b5',
- 'sizes': [[300, 250], [250, 250], [200, 200], [180, 150]],
- 'bidId': '30024615be22ef66a',
- 'bidderRequestId': '299926b3d3628cdd7',
- 'auctionId': '22445943-a0aa-4c63-a413-4deb64fcff1c',
- 'src': 'client',
- 'bidRequestsCount': 41,
- 'bidderRequestsCount': 41,
- 'bidderWinsCount': 0,
- 'schain': {
- 'ver': '1.0',
- 'complete': 1,
- 'nodes': [
- {
- 'asi': 'freegames66.com',
- 'sid': '343',
- 'hp': 1
- }
- ]
- }
- },
- {
- 'bidder': 'apacdex',
- 'params': {
- 'siteId': '343'
- },
- 'crumbs': {
- 'pubcid': 'c2b2ba08-9954-4850-8ee5-2bf4a2b35eff'
- },
- 'mediaTypes': {
- 'video': {
- 'playerSize': [[640, 480]],
- 'context': 'instream',
- 'mimes': [
- 'video/mp4',
- 'video/x-flv',
- 'video/x-ms-wmv',
- 'application/vnd.apple.mpegurl',
- 'application/x-mpegurl',
- 'video/3gpp',
- 'video/mpeg',
- 'video/ogg',
- 'video/quicktime',
- 'video/webm',
- 'video/x-m4v',
- 'video/ms-asf',
- 'video/x-msvideo'
- ],
- 'protocols': [1, 2, 3, 4, 5, 6],
- 'playbackmethod': [6],
- 'maxduration': 120,
- 'linearity': 1,
- 'api': [2]
- }
- },
- 'adUnitCode': 'vi_3431909',
- 'transactionId': '33d83d87-43cc-499b-aabe-5c22eb6acfbb',
- 'sizes': [[640, 480]],
- 'bidId': '1854b40107d6745c',
- 'bidderRequestId': '1840763b6bda185d',
- 'auctionId': 'df495de0-5d42-471f-a501-73bcd7254b80',
- 'src': 'client',
- 'bidRequestsCount': 1,
- 'bidderRequestsCount': 1,
- 'bidderWinsCount': 0,
- 'schain': {
- 'ver': '1.0',
- 'complete': 1,
- 'nodes': [
- {
- 'asi': 'freegames66.com',
- 'sid': '343',
- 'hp': 1
- }
- ]
- }
- }
- ]
- };
-
- const serverResponse = {
- 'body': {
- 'bids': [
- {
- 'requestId': '3000aa31c41a29c21',
- 'cpm': 1.07,
- 'width': 160,
- 'height': 600,
- 'ad': `
Apacdex AD
`,
- 'ttl': 500,
- 'creativeId': '1234abcd',
- 'netRevenue': true,
- 'currency': 'USD',
- 'dealId': 'apacdex',
- 'mediaType': 'banner',
- 'meta': {
- 'advertiserDomains': ['https://example.com']
- }
- },
- {
- 'requestId': '30024615be22ef66a',
- 'cpm': 1,
- 'width': 300,
- 'height': 250,
- 'ad': `
Apacdex AD
`,
- 'ttl': 500,
- 'creativeId': '1234abcd',
- 'netRevenue': true,
- 'currency': 'USD',
- 'dealId': 'apacdex',
- 'mediaType': 'banner',
- 'meta': {
- 'advertiserDomains': ['https://example.com']
- }
- },
- {
- 'requestId': '1854b40107d6745c',
- 'cpm': 1.25,
- 'width': 300,
- 'height': 250,
- 'vastXml': '
apacdex',
- 'ttl': 500,
- 'creativeId': '30292e432662bd5f86d90774b944b038',
- 'netRevenue': true,
- 'currency': 'USD',
- 'dealId': 'apacdex',
- 'mediaType': 'video',
- 'meta': {
- 'advertiserDomains': ['https://example.com']
- }
- }
- ],
- 'pixel': [{
- 'url': 'https://example.com/pixel.png',
- 'type': 'image'
- }]
- }
- };
-
- const prebidResponse = [
- {
- 'requestId': '3000aa31c41a29c21',
- 'cpm': 1.07,
- 'width': 160,
- 'height': 600,
- 'ad': `
Apacdex AD
`,
- 'ttl': 500,
- 'creativeId': '1234abcd',
- 'netRevenue': true,
- 'currency': 'USD',
- 'dealId': 'apacdex',
- 'mediaType': 'banner'
- },
- {
- 'requestId': '30024615be22ef66a',
- 'cpm': 1,
- 'width': 300,
- 'height': 250,
- 'ad': `
Apacdex AD
`,
- 'ttl': 500,
- 'creativeId': '1234abcd',
- 'netRevenue': true,
- 'currency': 'USD',
- 'dealId': 'apacdex',
- 'mediaType': 'banner'
- },
- {
- 'requestId': '1854b40107d6745c',
- 'cpm': 1.25,
- 'width': 300,
- 'height': 250,
- 'vastXml': '
apacdex',
- 'ttl': 500,
- 'creativeId': '30292e432662bd5f86d90774b944b038',
- 'netRevenue': true,
- 'currency': 'USD',
- 'dealId': 'apacdex',
- 'mediaType': 'video'
- }
- ];
-
- it('should map bidResponse to prebidResponse', function () {
- const response = spec.interpretResponse(serverResponse, bidRequests);
- response.forEach((resp, i) => {
- expect(resp.requestId).to.equal(prebidResponse[i].requestId);
- expect(resp.cpm).to.equal(prebidResponse[i].cpm);
- expect(resp.width).to.equal(prebidResponse[i].width);
- expect(resp.height).to.equal(prebidResponse[i].height);
- expect(resp.ttl).to.equal(prebidResponse[i].ttl);
- expect(resp.creativeId).to.equal(prebidResponse[i].creativeId);
- expect(resp.netRevenue).to.equal(prebidResponse[i].netRevenue);
- expect(resp.currency).to.equal(prebidResponse[i].currency);
- expect(resp.dealId).to.equal(prebidResponse[i].dealId);
- if (resp.mediaType === 'video') {
- expect(resp.vastXml.indexOf('apacdex')).to.be.greaterThan(0);
- }
- if (resp.mediaType === 'banner') {
- expect(resp.ad.indexOf('Apacdex AD')).to.be.greaterThan(0);
- }
- expect(resp.meta.advertiserDomains).to.deep.equal(['https://example.com']);
- });
- });
- });
-
- describe('.getUserSyncs', function () {
- const bidResponse = [{
- 'body': {
- 'pixel': [{
- 'url': 'https://pixel-test',
- 'type': 'image'
- }]
- }
- }];
-
- it('should return one sync pixel', function () {
- expect(spec.getUserSyncs({ pixelEnabled: true }, bidResponse)).to.deep.equal([{
- type: 'image',
- url: 'https://pixel-test'
- }]);
- });
- it('should return an empty array when sync is enabled but there are no bidResponses', function () {
- expect(spec.getUserSyncs({ pixelEnabled: true }, [])).to.have.length(0);
- });
-
- it('should return an empty array when sync is enabled but no sync pixel returned', function () {
- const pixel = Object.assign({}, bidResponse);
- delete pixel[0].body.pixel;
- expect(spec.getUserSyncs({ pixelEnabled: true }, bidResponse)).to.have.length(0);
- });
-
- it('should return an empty array', function () {
- expect(spec.getUserSyncs({ pixelEnabled: false }, bidResponse)).to.have.length(0);
- expect(spec.getUserSyncs({ pixelEnabled: true }, [])).to.have.length(0);
- });
- });
-
- describe('validateGeoObject', function () {
- it('should return true if the geo object is valid', () => {
- const geoObject = {
- lat: 123.5624234,
- lon: 23.6712341,
- accuracy: 20
- };
- expect(validateGeoObject(geoObject)).to.equal(true);
- });
-
- it('should return false if the geo object is not plain object', () => {
- const geoObject = [{
- lat: 123.5624234,
- lon: 23.6712341,
- accuracy: 20
- }];
- expect(validateGeoObject(geoObject)).to.equal(false);
- });
-
- it('should return false if the geo object is missing lat attribute', () => {
- const geoObject = {
- lon: 23.6712341,
- accuracy: 20
- };
- expect(validateGeoObject(geoObject)).to.equal(false);
- });
-
- it('should return false if the geo object is missing lon attribute', () => {
- const geoObject = {
- lat: 123.5624234,
- accuracy: 20
- };
- expect(validateGeoObject(geoObject)).to.equal(false);
- });
-
- it('should return false if the geo object is missing accuracy attribute', () => {
- const geoObject = {
- lat: 123.5624234,
- lon: 23.6712341
- };
- expect(validateGeoObject(geoObject)).to.equal(false);
- });
- });
-});
diff --git a/test/spec/modules/appStockSSPBidAdapter_spec.js b/test/spec/modules/appStockSSPBidAdapter_spec.js
deleted file mode 100644
index 7ee7d739d..000000000
--- a/test/spec/modules/appStockSSPBidAdapter_spec.js
+++ /dev/null
@@ -1,534 +0,0 @@
-import { expect } from 'chai';
-import { spec } from '../../../modules/appStockSSPBidAdapter.js';
-import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js';
-import { getUniqueIdentifierStr } from '../../../src/utils.js';
-import { config } from '../../../src/config.js';
-import { USERSYNC_DEFAULT_CONFIG } from '../../../src/userSync.js';
-
-const bidder = 'appStockSSP';
-
-describe('AppStockSSPBidAdapter', function () {
- const userIdAsEids = [{
- source: 'test.org',
- uids: [{
- id: '01**********',
- atype: 1,
- ext: {
- third: '01***********'
- }
- }]
- }];
- const bids = [
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
- region: 'eu',
- placementId: 'testBanner'
- },
- userIdAsEids
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [VIDEO]: {
- playerSize: [[300, 300]],
- minduration: 5,
- maxduration: 60
- }
- },
- params: {
- placementId: 'testVideo'
- },
- userIdAsEids
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [NATIVE]: {
- native: {
- title: {
- required: true
- },
- body: {
- required: true
- },
- icon: {
- required: true,
- size: [64, 64]
- }
- }
- }
- },
- params: {
- region: 'eu',
- placementId: 'testNative'
- },
- userIdAsEids
- }
- ];
-
- const invalidBid = {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
-
- }
- }
-
- const bidderRequest = {
- uspConsent: '1---',
- gdprConsent: {
- consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw',
- vendorData: {}
- },
- refererInfo: {
- referer: 'https://test.com',
- page: 'https://test.com'
- },
- ortb2: {
- device: {
- w: 1512,
- h: 982,
- language: 'en-UK'
- }
- },
- timeout: 500
- };
-
- describe('isBidRequestValid', function () {
- it('Should return true if there are bidId, params and key parameters present', function () {
- expect(spec.isBidRequestValid(bids[0])).to.be.true;
- });
- it('Should return false if at least one of parameters is not present', function () {
- expect(spec.isBidRequestValid(invalidBid)).to.be.false;
- });
- });
-
- describe('buildRequests', function () {
- let serverRequest = spec.buildRequests(bids, bidderRequest);
-
- it('Creates a ServerRequest object with method, URL and data', function () {
- expect(serverRequest).to.exist;
- expect(serverRequest.method).to.exist;
- expect(serverRequest.url).to.exist;
- expect(serverRequest.data).to.exist;
- });
-
- it('Returns POST method', function () {
- expect(serverRequest.method).to.equal('POST');
- });
-
- it('Returns valid EU URL', function () {
- bids[0].params.region = 'eu';
- serverRequest = spec.buildRequests(bids, bidderRequest);
- expect(serverRequest.url).to.equal('https://ortb-eu.al-ad.com/pbjs');
- });
-
- it('Returns valid EAST URL', function () {
- bids[0].params.region = 'us-east';
- serverRequest = spec.buildRequests(bids, bidderRequest);
- expect(serverRequest.url).to.equal('https://lb.al-ad.com/pbjs');
- });
-
- it('Returns valid APAC URL', function () {
- bids[0].params.region = 'apac';
- serverRequest = spec.buildRequests(bids, bidderRequest);
- expect(serverRequest.url).to.equal('https://ortb-apac.al-ad.com/pbjs');
- });
-
- it('Returns general data valid', function () {
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.all.keys('deviceWidth',
- 'deviceHeight',
- 'device',
- 'language',
- 'secure',
- 'host',
- 'page',
- 'placements',
- 'coppa',
- 'ccpa',
- 'gdpr',
- 'tmax',
- 'bcat',
- 'badv',
- 'bapp',
- 'battr'
- );
- expect(data.deviceWidth).to.be.a('number');
- expect(data.deviceHeight).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');
- expect(data.page).to.be.a('string');
- expect(data.coppa).to.be.a('number');
- expect(data.gdpr).to.be.a('object');
- expect(data.ccpa).to.be.a('string');
- expect(data.tmax).to.be.a('number');
- expect(data.placements).to.have.lengthOf(3);
- });
-
- it('Returns valid placements', function () {
- const { placements } = serverRequest.data;
- for (let i = 0, len = placements.length; i < len; i++) {
- const placement = placements[i];
- expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']);
- expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]);
- expect(placement.bidId).to.be.a('string');
- expect(placement.schain).to.be.an('object');
- expect(placement.bidfloor).to.exist.and.to.equal(0);
- expect(placement.type).to.exist.and.to.equal('publisher');
- expect(placement.eids).to.exist.and.to.be.deep.equal(userIdAsEids);
-
- if (placement.adFormat === BANNER) {
- expect(placement.sizes).to.be.an('array');
- }
- switch (placement.adFormat) {
- case BANNER:
- expect(placement.sizes).to.be.an('array');
- break;
- case VIDEO:
- expect(placement.playerSize).to.be.an('array');
- expect(placement.minduration).to.be.an('number');
- expect(placement.maxduration).to.be.an('number');
- break;
- case NATIVE:
- expect(placement.native).to.be.an('object');
- break;
- }
- }
- });
-
- it('Returns valid endpoints', function () {
- const bids = [
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
- endpointId: 'testBanner',
- },
- userIdAsEids
- }
- ];
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
-
- const { placements } = serverRequest.data;
- for (let i = 0, len = placements.length; i < len; i++) {
- const placement = placements[i];
- expect(placement.endpointId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']);
- expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]);
- expect(placement.bidId).to.be.a('string');
- expect(placement.schain).to.be.an('object');
- expect(placement.bidfloor).to.exist.and.to.equal(0);
- expect(placement.type).to.exist.and.to.equal('network');
- expect(placement.eids).to.exist.and.to.be.deep.equal(userIdAsEids);
-
- if (placement.adFormat === BANNER) {
- expect(placement.sizes).to.be.an('array');
- }
- switch (placement.adFormat) {
- case BANNER:
- expect(placement.sizes).to.be.an('array');
- break;
- case VIDEO:
- expect(placement.playerSize).to.be.an('array');
- expect(placement.minduration).to.be.an('number');
- expect(placement.maxduration).to.be.an('number');
- break;
- case NATIVE:
- expect(placement.native).to.be.an('object');
- break;
- }
- }
- });
-
- it('Returns data with gdprConsent and without uspConsent', function () {
- delete bidderRequest.uspConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.gdpr).to.exist;
- expect(data.gdpr).to.be.a('object');
- expect(data.gdpr).to.have.property('consentString');
- expect(data.gdpr).to.not.have.property('vendorData');
- expect(data.gdpr.consentString).to.equal(bidderRequest.gdprConsent.consentString);
- expect(data.ccpa).to.not.exist;
- delete bidderRequest.gdprConsent;
- });
-
- it('Returns data with uspConsent and without gdprConsent', function () {
- bidderRequest.uspConsent = '1---';
- delete bidderRequest.gdprConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.ccpa).to.exist;
- expect(data.ccpa).to.be.a('string');
- expect(data.ccpa).to.equal(bidderRequest.uspConsent);
- expect(data.gdpr).to.not.exist;
- });
- });
-
- describe('gpp consent', function () {
- it('bidderRequest.gppConsent', () => {
- bidderRequest.gppConsent = {
- gppString: 'abc123',
- applicableSections: [8]
- };
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
-
- delete bidderRequest.gppConsent;
- })
-
- it('bidderRequest.ortb2.regs.gpp', () => {
- bidderRequest.ortb2 = bidderRequest.ortb2 || {};
- bidderRequest.ortb2.regs = bidderRequest.ortb2.regs || {};
- bidderRequest.ortb2.regs.gpp = 'abc123';
- bidderRequest.ortb2.regs.gpp_sid = [8];
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
- })
- });
-
- describe('interpretResponse', function () {
- it('Should interpret banner response', function () {
- const banner = {
- body: [{
- mediaType: 'banner',
- width: 300,
- height: 250,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const bannerResponses = spec.interpretResponse(banner);
- expect(bannerResponses).to.be.an('array').that.is.not.empty;
- const dataItem = bannerResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal(banner.body[0].requestId);
- expect(dataItem.cpm).to.equal(banner.body[0].cpm);
- expect(dataItem.width).to.equal(banner.body[0].width);
- expect(dataItem.height).to.equal(banner.body[0].height);
- expect(dataItem.ad).to.equal(banner.body[0].ad);
- expect(dataItem.ttl).to.equal(banner.body[0].ttl);
- expect(dataItem.creativeId).to.equal(banner.body[0].creativeId);
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal(banner.body[0].currency);
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should interpret video response', function () {
- const video = {
- body: [{
- vastUrl: 'test.com',
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const videoResponses = spec.interpretResponse(video);
- expect(videoResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = videoResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.5);
- expect(dataItem.vastUrl).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should interpret native response', function () {
- const native = {
- body: [{
- mediaType: 'native',
- native: {
- clickUrl: 'test.com',
- title: 'Test',
- image: 'test.com',
- impressionTrackers: ['test.com'],
- },
- ttl: 120,
- cpm: 0.4,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const nativeResponses = spec.interpretResponse(native);
- expect(nativeResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = nativeResponses[0];
- expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta');
- expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image')
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.4);
- expect(dataItem.native.clickUrl).to.equal('test.com');
- expect(dataItem.native.title).to.equal('Test');
- expect(dataItem.native.image).to.equal('test.com');
- expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty;
- expect(dataItem.native.impressionTrackers[0]).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should return an empty array if invalid banner response is passed', function () {
- const invBanner = {
- body: [{
- width: 300,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
-
- const serverResponses = spec.interpretResponse(invBanner);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid video response is passed', function () {
- const invVideo = {
- body: [{
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invVideo);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid native response is passed', function () {
- const invNative = {
- body: [{
- mediaType: 'native',
- clickUrl: 'test.com',
- title: 'Test',
- impressionTrackers: ['test.com'],
- ttl: 120,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- }]
- };
- const serverResponses = spec.interpretResponse(invNative);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid response is passed', function () {
- const invalid = {
- body: [{
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invalid);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- });
-
- describe('getUserSyncs', function() {
- it('Should return array of objects with proper sync config , include GDPR', function() {
- const syncData = spec.getUserSyncs({}, {}, {
- consentString: 'ALL',
- gdprApplies: true,
- }, {});
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://csync.al-ad.com/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0')
- });
- it('Should return array of objects with proper sync config , include CCPA', function() {
- const syncData = spec.getUserSyncs({}, {}, {}, {
- consentString: '1---'
- });
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://csync.al-ad.com/image?pbjs=1&ccpa_consent=1---&coppa=0')
- });
- it('Should return array of objects with proper sync config , include GPP', function() {
- const syncData = spec.getUserSyncs({}, {}, {}, {}, {
- gppString: 'abc123',
- applicableSections: [8]
- });
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://csync.al-ad.com/image?pbjs=1&gpp=abc123&gpp_sid=8&coppa=0')
- });
- });
-});
diff --git a/test/spec/modules/appierAnalyticsAdapter_spec.js b/test/spec/modules/appierAnalyticsAdapter_spec.js
deleted file mode 100644
index e380672b7..000000000
--- a/test/spec/modules/appierAnalyticsAdapter_spec.js
+++ /dev/null
@@ -1,705 +0,0 @@
-import {
- appierAnalyticsAdapter, getCpmInUsd, parseBidderCode, parseAdUnitCode,
- ANALYTICS_VERSION, BIDDER_STATUS
-} from 'modules/appierAnalyticsAdapter.js';
-import {expect} from 'chai';
-const events = require('src/events');
-const constants = require('src/constants.js');
-
-const affiliateId = 'WhctHaViHtI';
-const configId = 'd9cc9a9be9b240eda17cf1c9a8a4b29c';
-const serverUrl = 'https://analytics.server.url/v1';
-const autoPick = 'none';
-const predictionId = '2a91ca5de54a4a2e89950af439f7a27f';
-const auctionId = 'b0b39610-b941-4659-a87c-de9f62d3e13e';
-
-describe('Appier Prebid AnalyticsAdapter Testing', function () {
- describe('event tracking and message cache manager', function () {
- beforeEach(function () {
- const configOptions = {
- affiliateId: affiliateId,
- configId: configId,
- server: serverUrl,
- autoPick: autoPick,
- predictionId: predictionId,
- sampling: 0,
- adSampling: 1,
- };
-
- appierAnalyticsAdapter.enableAnalytics({
- provider: 'appierAnalytics',
- options: configOptions
- });
- });
-
- afterEach(function () {
- appierAnalyticsAdapter.disableAnalytics();
- });
-
- describe('#getCpmInUsd()', function() {
- it('should get bid cpm as currency is USD', function() {
- const receivedBids = [
- {
- auctionId: auctionId,
- adUnitCode: 'adunit_1',
- bidder: 'appier',
- bidderCode: 'APPIER',
- requestId: 'a1b2c3d4',
- timeToRespond: 72,
- cpm: 0.1,
- currency: 'USD',
- originalCpm: 0.1,
- originalCurrency: 'USD',
- ad: 'fake ad1'
- },
- ]
- const result = getCpmInUsd(receivedBids[0]);
- expect(result).to.equal(0.1);
- });
- });
-
- describe('#parseBidderCode()', function() {
- it('should get lower case bidder code from bidderCode field value', function() {
- const receivedBids = [
- {
- auctionId: auctionId,
- adUnitCode: 'adunit_1',
- bidder: 'appier',
- bidderCode: 'APPIER',
- requestId: 'a1b2c3d4',
- timeToRespond: 72,
- cpm: 0.1,
- currency: 'USD',
- originalCpm: 0.1,
- originalCurrency: 'USD',
- ad: 'fake ad1'
- },
- ];
- const result = parseBidderCode(receivedBids[0]);
- expect(result).to.equal('appier');
- });
- it('should get lower case bidder code from bidder field value as bidderCode field is missing', function() {
- const receivedBids = [
- {
- auctionId: auctionId,
- adUnitCode: 'adunit_1',
- bidder: 'APPIER',
- bidderCode: '',
- requestId: 'a1b2c3d4',
- timeToRespond: 72,
- cpm: 0.1,
- currency: 'USD',
- originalCpm: 0.1,
- originalCurrency: 'USD',
- ad: 'fake ad1'
- },
- ];
- const result = parseBidderCode(receivedBids[0]);
- expect(result).to.equal('appier');
- });
- });
-
- describe('#parseAdUnitCode()', function() {
- it('should get lower case adUnit code from adUnitCode field value', function() {
- const receivedBids = [
- {
- auctionId: auctionId,
- adUnitCode: 'ADUNIT',
- bidder: 'appier',
- bidderCode: 'APPIER',
- requestId: 'a1b2c3d4',
- timeToRespond: 72,
- cpm: 0.1,
- currency: 'USD',
- originalCpm: 0.1,
- originalCurrency: 'USD',
- ad: 'fake ad1'
- },
- ];
- const result = parseAdUnitCode(receivedBids[0]);
- expect(result).to.equal('adunit');
- });
- });
-
- describe('#getCachedAuction()', function() {
- const existing = {timeoutBids: [{}]};
- appierAnalyticsAdapter.cachedAuctions['test_auction_id'] = existing;
-
- it('should get the existing cached object if it exists', function() {
- const result = appierAnalyticsAdapter.getCachedAuction('test_auction_id');
-
- expect(result).to.equal(existing);
- });
-
- it('should create a new object and store it in the cache on cache miss', function() {
- const result = appierAnalyticsAdapter.getCachedAuction('no_such_id');
-
- expect(result).to.deep.include({
- timeoutBids: [],
- });
- });
- });
-
- describe('when formatting JSON payload sent to backend', function() {
- const receivedBids = [
- {
- auctionId: auctionId,
- adUnitCode: 'adunit_1',
- bidder: 'appier',
- bidderCode: 'appier',
- requestId: 'a1b2c3d4',
- timeToRespond: 72,
- cpm: 0.1,
- currency: 'USD',
- originalCpm: 0.1,
- originalCurrency: 'USD',
- ad: 'fake ad1'
- },
- {
- auctionId: auctionId,
- adUnitCode: 'adunit_1',
- bidder: 'reippa',
- bidderCode: 'reippa',
- requestId: 'b2c3d4e5',
- timeToRespond: 100,
- cpm: 0.08,
- currency: 'USD',
- originalCpm: 0.08,
- originalCurrency: 'USD',
- ad: 'fake ad2'
- },
- {
- auctionId: auctionId,
- adUnitCode: 'adunit_2',
- bidder: 'appier',
- bidderCode: 'appier',
- requestId: 'c3d4e5f6',
- timeToRespond: 120,
- cpm: 0.09,
- currency: 'USD',
- originalCpm: 0.09,
- originalCurrency: 'USD',
- ad: 'fake ad3'
- },
- ];
- const highestCpmBids = [
- {
- auctionId: auctionId,
- adUnitCode: 'adunit_1',
- bidder: 'appier',
- bidderCode: 'appier',
- // No requestId
- timeToRespond: 72,
- cpm: 0.1,
- currency: 'USD',
- originalCpm: 0.1,
- originalCurrency: 'USD',
- ad: 'fake ad1'
- }
- ];
- const noBids = [
- {
- auctionId: auctionId,
- adUnitCode: 'adunit_2',
- bidder: 'appier',
- bidderCode: 'appier',
- bidId: 'a1b2c3d4',
- }
- ];
- const timeoutBids = [
- {
- auctionId: auctionId,
- adUnitCode: 'adunit_2',
- bidder: 'reippa',
- bidderCode: 'reippa',
- bidId: '00123d4c',
- }
- ];
- const withoutOriginalCpmBids = [
- {
- auctionId: auctionId,
- adUnitCode: 'adunit_2',
- bidder: 'appier',
- bidderCode: 'appier',
- requestId: 'c3d4e5f6',
- timeToRespond: 120,
- cpm: 0.29,
- currency: 'USD',
- originalCpm: '',
- originalCurrency: 'USD',
- ad: 'fake ad3'
- },
- ];
- const withoutOriginalCurrencyBids = [
- {
- auctionId: auctionId,
- adUnitCode: 'adunit_2',
- bidder: 'appier',
- bidderCode: 'appier',
- requestId: 'c3d4e5f6',
- timeToRespond: 120,
- cpm: 0.09,
- currency: 'USD',
- originalCpm: 0.09,
- originalCurrency: '',
- ad: 'fake ad3'
- },
- ];
- function assertHavingRequiredMessageFields(message) {
- expect(message).to.include({
- version: ANALYTICS_VERSION,
- auctionId: auctionId,
- affiliateId: affiliateId,
- configId: configId,
- // referrer: window.location.href,
- sampling: 0,
- adSampling: 1,
- prebid: '$prebid.version$',
- // autoPick: 'manual',
- });
- }
-
- describe('#createCommonMessage', function() {
- it('should correctly serialize some common fields', function() {
- const message = appierAnalyticsAdapter.createCommonMessage(auctionId);
-
- assertHavingRequiredMessageFields(message);
- });
- });
-
- describe('#serializeBidResponse', function() {
- it('should handle BID properly and serialize bid price related fields', function() {
- const result = appierAnalyticsAdapter.serializeBidResponse(receivedBids[0], BIDDER_STATUS.BID);
-
- expect(result).to.include({
- prebidWon: false,
- isTimeout: false,
- status: BIDDER_STATUS.BID,
- time: 72,
- cpm: 0.1,
- currency: 'USD',
- originalCpm: 0.1,
- originalCurrency: 'USD',
- cpmUsd: 0.1,
- });
- });
-
- it('should handle NO_BID properly and set status to noBid', function() {
- const result = appierAnalyticsAdapter.serializeBidResponse(noBids[0], BIDDER_STATUS.NO_BID);
-
- expect(result).to.include({
- prebidWon: false,
- isTimeout: false,
- status: BIDDER_STATUS.NO_BID,
- });
- });
-
- it('should handle BID_WON properly and serialize bid price related fields', function() {
- const result = appierAnalyticsAdapter.serializeBidResponse(receivedBids[0], BIDDER_STATUS.BID_WON);
-
- expect(result).to.include({
- prebidWon: true,
- isTimeout: false,
- status: BIDDER_STATUS.BID_WON,
- time: 72,
- cpm: 0.1,
- currency: 'USD',
- originalCpm: 0.1,
- originalCurrency: 'USD',
- cpmUsd: 0.1,
- });
- });
-
- it('should handle TIMEOUT properly and set status to timeout and isTimeout to true', function() {
- const result = appierAnalyticsAdapter.serializeBidResponse(noBids[0], BIDDER_STATUS.TIMEOUT);
-
- expect(result).to.include({
- prebidWon: false,
- isTimeout: true,
- status: BIDDER_STATUS.TIMEOUT,
- });
- });
-
- it('should handle BID_WON properly and fill originalCpm field with cpm in missing originalCpm case', function() {
- const result = appierAnalyticsAdapter.serializeBidResponse(withoutOriginalCpmBids[0], BIDDER_STATUS.BID_WON);
-
- expect(result).to.include({
- prebidWon: true,
- isTimeout: false,
- status: BIDDER_STATUS.BID_WON,
- time: 120,
- cpm: 0.29,
- currency: 'USD',
- originalCpm: 0.29,
- originalCurrency: 'USD',
- cpmUsd: 0.29,
- });
- });
-
- it('should handle BID_WON properly and fill originalCurrency field with currency in missing originalCurrency case', function() {
- const result = appierAnalyticsAdapter.serializeBidResponse(withoutOriginalCurrencyBids[0], BIDDER_STATUS.BID_WON);
- expect(result).to.include({
- prebidWon: true,
- isTimeout: false,
- status: BIDDER_STATUS.BID_WON,
- time: 120,
- cpm: 0.09,
- currency: 'USD',
- originalCpm: 0.09,
- originalCurrency: 'USD',
- cpmUsd: 0.09,
- });
- });
- });
-
- describe('#addBidResponseToMessage()', function() {
- it('should add a bid response in the output message, grouped by adunit_id and bidder', function() {
- const message = {
- adUnits: {}
- };
- appierAnalyticsAdapter.addBidResponseToMessage(message, noBids[0], BIDDER_STATUS.NO_BID);
-
- expect(message.adUnits).to.deep.include({
- 'adunit_2': {
- 'appier': {
- prebidWon: false,
- isTimeout: false,
- status: BIDDER_STATUS.NO_BID,
- }
- }
- });
- });
- });
-
- describe('#createBidMessage()', function() {
- it('should format auction message sent to the backend', function() {
- const args = {
- auctionId: auctionId,
- timestamp: 1234567890,
- timeout: 3000,
- auctionEnd: 1234567990,
- adUnitCodes: ['adunit_1', 'adunit_2'],
- bidsReceived: receivedBids,
- noBids: noBids
- };
-
- const result = appierAnalyticsAdapter.createBidMessage(args, highestCpmBids, timeoutBids);
-
- assertHavingRequiredMessageFields(result);
- expect(result).to.deep.include({
- auctionElapsed: 100,
- timeout: 3000,
- adUnits: {
- 'adunit_1': {
- 'appier': {
- prebidWon: true,
- isTimeout: false,
- status: BIDDER_STATUS.BID,
- time: 72,
- cpm: 0.1,
- currency: 'USD',
- originalCpm: 0.1,
- originalCurrency: 'USD',
- cpmUsd: 0.1,
- },
- 'reippa': {
- prebidWon: false,
- isTimeout: false,
- status: BIDDER_STATUS.BID,
- time: 100,
- cpm: 0.08,
- currency: 'USD',
- originalCpm: 0.08,
- originalCurrency: 'USD',
- cpmUsd: 0.08,
- }
- },
- 'adunit_2': {
- // this bid result exists in both bid and noBid arrays and should be treated as bid
- 'appier': {
- prebidWon: false,
- isTimeout: false,
- time: 120,
- cpm: 0.09,
- currency: 'USD',
- originalCpm: 0.09,
- originalCurrency: 'USD',
- cpmUsd: 0.09,
- status: BIDDER_STATUS.BID,
- },
- 'reippa': {
- prebidWon: false,
- isTimeout: true,
- status: BIDDER_STATUS.TIMEOUT,
- }
- }
- }
- });
- });
- });
-
- describe('#createImpressionMessage()', function() {
- it('should format message sent to the backend with the bid result', function() {
- const bid = receivedBids[0];
- const result = appierAnalyticsAdapter.createImpressionMessage(bid);
-
- assertHavingRequiredMessageFields(result);
- expect(result.adUnits).to.deep.include({
- 'adunit_1': {
- 'appier': {
- prebidWon: true,
- isTimeout: false,
- status: BIDDER_STATUS.BID_WON,
- time: 72,
- cpm: 0.1,
- currency: 'USD',
- originalCpm: 0.1,
- originalCurrency: 'USD',
- cpmUsd: 0.1,
- }
- }
- });
- });
- });
-
- describe('#createCreativeMessage()', function() {
- it('should generate message sent to the backend with ad html grouped by adunit and bidder', function() {
- const result = appierAnalyticsAdapter.createCreativeMessage(auctionId, receivedBids);
-
- assertHavingRequiredMessageFields(result);
- expect(result.adUnits).to.deep.include({
- 'adunit_1': {
- 'appier': {
- ad: 'fake ad1'
- },
- 'reippa': {
- ad: 'fake ad2'
- },
- },
- 'adunit_2': {
- 'appier': {
- ad: 'fake ad3'
- }
- }
- });
- });
- });
- describe('#handleBidTimeout()', function() {
- it('should cached the timeout bid as BID_TIMEOUT event was triggered', function() {
- appierAnalyticsAdapter.cachedAuctions['test_timeout_auction_id'] = { 'timeoutBids': [] };
- const args = [{
- auctionId: 'test_timeout_auction_id',
- timestamp: 1234567890,
- timeout: 3000,
- auctionEnd: 1234567990,
- bidsReceived: receivedBids,
- noBids: noBids
- }];
-
- appierAnalyticsAdapter.handleBidTimeout(args);
- const result = appierAnalyticsAdapter.getCachedAuction('test_timeout_auction_id');
- expect(result).to.deep.include({
- timeoutBids: [{
- auctionId: 'test_timeout_auction_id',
- timestamp: 1234567890,
- timeout: 3000,
- auctionEnd: 1234567990,
- bidsReceived: receivedBids,
- noBids: noBids
- }]
- });
- });
- });
- describe('#handleBidWon()', function() {
- it('should call createImpressionMessage once as BID_WON event was triggered', function() {
- sinon.spy(appierAnalyticsAdapter, 'createImpressionMessage');
- const receivedBids = [
- {
- auctionId: auctionId,
- adUnitCode: 'adunit_1',
- bidder: 'appier',
- bidderCode: 'appier',
- requestId: 'a1b2c3d4',
- timeToRespond: 72,
- cpm: 0.1,
- currency: 'USD',
- originalCpm: 0.1,
- originalCurrency: 'USD',
- ad: 'fake ad1'
- },
- ]
-
- appierAnalyticsAdapter.handleBidWon(receivedBids[0]);
- sinon.assert.callCount(appierAnalyticsAdapter.createImpressionMessage, 1);
- appierAnalyticsAdapter.createImpressionMessage.restore();
- });
- });
- });
- });
-
- describe('Appier Analytics Adapter track handler ', function () {
- const configOptions = {
- affiliateId: affiliateId,
- configId: configId,
- server: serverUrl,
- autoPick: autoPick,
- sampling: 1,
- adSampling: 1,
- };
-
- beforeEach(function () {
- sinon.stub(events, 'getEvents').returns([]);
- appierAnalyticsAdapter.enableAnalytics({
- provider: 'appierAnalytics',
- options: configOptions
- });
- });
-
- afterEach(function () {
- appierAnalyticsAdapter.disableAnalytics();
- events.getEvents.restore();
- });
-
- it('should call handleBidWon as BID_WON trigger event', function() {
- sinon.spy(appierAnalyticsAdapter, 'handleBidWon');
- events.emit(constants.EVENTS.BID_WON, {});
- sinon.assert.callCount(appierAnalyticsAdapter.handleBidWon, 1);
- appierAnalyticsAdapter.handleBidWon.restore();
- });
-
- it('should call handleBidTimeout as BID_TIMEOUT trigger event', function() {
- sinon.spy(appierAnalyticsAdapter, 'handleBidTimeout');
- events.emit(constants.EVENTS.BID_TIMEOUT, {});
- sinon.assert.callCount(appierAnalyticsAdapter.handleBidTimeout, 1);
- appierAnalyticsAdapter.handleBidTimeout.restore();
- });
-
- it('should call handleAuctionEnd as AUCTION_END trigger event', function() {
- sinon.spy(appierAnalyticsAdapter, 'handleAuctionEnd');
- events.emit(constants.EVENTS.AUCTION_END, {});
- sinon.assert.callCount(appierAnalyticsAdapter.handleAuctionEnd, 1);
- appierAnalyticsAdapter.handleAuctionEnd.restore();
- });
-
- it('should call createCreativeMessage as AUCTION_END trigger event in adSampled is true', function() {
- const configOptions = {
- options: {
- affiliateId: affiliateId,
- configId: configId,
- server: serverUrl,
- autoPick: autoPick,
- sampling: 1,
- adSampling: 1,
- adSampled: true,
- }
- };
- const args = {
- auctionId: 'test_timeout_auction_id',
- timestamp: 1234567890,
- timeout: 3000,
- auctionEnd: 1234567990,
- };
- appierAnalyticsAdapter.initConfig(configOptions);
- sinon.stub(appierAnalyticsAdapter, 'sendEventMessage').returns({});
- sinon.stub(appierAnalyticsAdapter, 'createBidMessage').returns({});
- sinon.spy(appierAnalyticsAdapter, 'createCreativeMessage');
- events.emit(constants.EVENTS.AUCTION_END, args);
- sinon.assert.callCount(appierAnalyticsAdapter.createCreativeMessage, 1);
- appierAnalyticsAdapter.sendEventMessage.restore();
- appierAnalyticsAdapter.createBidMessage.restore();
- appierAnalyticsAdapter.createCreativeMessage.restore();
- });
- });
-
- describe('enableAnalytics and config parser', function () {
- const configOptions = {
- affiliateId: affiliateId,
- configId: configId,
- server: serverUrl,
- autoPick: autoPick,
- sampling: 0,
- adSampling: 1,
- };
-
- beforeEach(function () {
- appierAnalyticsAdapter.enableAnalytics({
- provider: 'appierAnalytics',
- options: configOptions
- });
- });
-
- afterEach(function () {
- appierAnalyticsAdapter.disableAnalytics();
- });
-
- it('should parse config correctly with optional values', function () {
- expect(appierAnalyticsAdapter.getAnalyticsOptions().options).to.deep.equal(configOptions);
- expect(appierAnalyticsAdapter.getAnalyticsOptions().affiliateId).to.equal(configOptions.affiliateId);
- expect(appierAnalyticsAdapter.getAnalyticsOptions().configId).to.equal(configOptions.configId);
- expect(appierAnalyticsAdapter.getAnalyticsOptions().server).to.equal(configOptions.server);
- expect(appierAnalyticsAdapter.getAnalyticsOptions().autoPick).to.equal(configOptions.autoPick);
- expect(appierAnalyticsAdapter.getAnalyticsOptions().sampled).to.equal(false);
- expect(appierAnalyticsAdapter.getAnalyticsOptions().adSampled).to.equal(true);
- });
-
- it('should not enable Analytics when affiliateId is missing', function () {
- const configOptions = {
- options: {
- configId: configId
- }
- };
- const validConfig = appierAnalyticsAdapter.initConfig(configOptions);
- expect(validConfig).to.equal(false);
- });
-
- it('should use DEFAULT_SERVER when server is missing', function () {
- const configOptions = {
- options: {
- configId: configId,
- affiliateId: affiliateId
- }
- };
- appierAnalyticsAdapter.initConfig(configOptions);
- expect(appierAnalyticsAdapter.getAnalyticsOptions().server).to.equal('https://prebid-analytics.c.appier.net/v1');
- });
-
- it('should use null when autoPick is missing', function () {
- const configOptions = {
- options: {
- configId: configId,
- affiliateId: affiliateId
- }
- };
- appierAnalyticsAdapter.initConfig(configOptions);
- expect(appierAnalyticsAdapter.getAnalyticsOptions().autoPick).to.equal(null);
- });
-
- it('should not enable Analytics when configId is missing', function () {
- const configOptions = {
- options: {
- affiliateId: affiliateId
- }
- };
- const validConfig = appierAnalyticsAdapter.initConfig(configOptions);
- expect(validConfig).to.equal(false);
- });
-
- it('should fall back to default value when sampling factor is not number', function () {
- const configOptions = {
- options: {
- affiliateId: affiliateId,
- configId: configId,
- sampling: 'string',
- adSampling: 'string'
- }
- };
- appierAnalyticsAdapter.enableAnalytics({
- provider: 'appierAnalytics',
- options: configOptions
- });
-
- expect(appierAnalyticsAdapter.getAnalyticsOptions().sampled).to.equal(false);
- expect(appierAnalyticsAdapter.getAnalyticsOptions().adSampled).to.equal(true);
- });
- });
-});
diff --git a/test/spec/modules/appierBidAdapter_spec.js b/test/spec/modules/appierBidAdapter_spec.js
deleted file mode 100644
index 93f95fbd1..000000000
--- a/test/spec/modules/appierBidAdapter_spec.js
+++ /dev/null
@@ -1,178 +0,0 @@
-import { expect } from 'chai';
-import { spec, API_SERVERS_MAP, ADAPTER_VERSION } from 'modules/appierBidAdapter.js';
-import { newBidder } from 'src/adapters/bidderFactory.js';
-import { config } from 'src/config.js';
-
-describe('AppierAdapter', function () {
- const adapter = newBidder(spec);
-
- describe('inherited functions', function () {
- it('exists and is a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('isBidRequestValid', function () {
- const bid = {
- 'bidder': 'appier',
- 'params': {
- 'hzid': 'abcd'
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [[300, 250], [300, 600]],
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- };
-
- it('should return true when required params zoneId found', function () {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should return false when required param zoneId is missing', function () {
- const invalidBid = Object.assign({}, bid);
- invalidBid.params = {};
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
-
- it('should return false when required param zoneId has wrong type', function () {
- const invalidBid = Object.assign({}, bid);
- invalidBid.params = {
- 'hzid': null
- };
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
- });
-
- describe('buildRequests', function() {
- it('should return an empty list when there are no bid requests', function() {
- const fakeBidRequests = [];
- const fakeBidderRequest = {};
- expect(spec.buildRequests(fakeBidRequests, fakeBidderRequest)).to.be.an('array').that.is.empty;
- });
-
- it('should generate a POST bid request with method, url, and data fields', function() {
- const bid = {
- 'bidder': 'appier',
- 'params': {
- 'hzid': 'abcd'
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [[300, 250], [300, 600]],
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- };
- const fakeBidRequests = [bid];
- const fakeBidderRequest = {
- refererInfo: {
- legacy: {
- 'referer': 'fakeReferer',
- 'reachedTop': true,
- 'numIframes': 1,
- 'stack': []
- }
- }
- };
-
- const builtRequests = spec.buildRequests(fakeBidRequests, fakeBidderRequest);
- expect(builtRequests.length).to.equal(1);
- expect(builtRequests[0].method).to.equal('POST');
- expect(builtRequests[0].url).match(/v1\/prebid\/bid/);
- expect(builtRequests[0].data).deep.equal({
- 'bids': fakeBidRequests,
- 'refererInfo': fakeBidderRequest.refererInfo.legacy,
- 'version': ADAPTER_VERSION
- });
- });
- });
-
- describe('interpretResponse', function() {
- const bid = {
- 'bidder': 'appier',
- 'params': {
- 'hzid': 'abcd'
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [[300, 250], [300, 600]],
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- };
- const fakeBidRequests = [bid];
-
- it('should return an empty aray to indicate no valid bids', function() {
- const fakeServerResponse = {};
-
- const bidResponses = spec.interpretResponse(fakeServerResponse, fakeBidRequests);
-
- expect(bidResponses).is.an('array').that.is.empty;
- });
-
- it('should generate correct response array for bidder', function() {
- const fakeBidResult = {
- 'requestId': '30b31c1838de1e',
- 'cpm': 0.0029346001,
- 'creativeId': 'Idl0P0d5S3Ca5kVWcia-wQ',
- 'width': 300,
- 'height': 250,
- 'currency': 'USD',
- 'netRevenue': true,
- 'ttl': 300,
- 'ad': '
fake html
',
- 'appierParams': {
- 'hzid': 'test_hzid'
- }
- };
- const fakeServerResponse = {
- headers: [],
- body: [fakeBidResult]
- };
-
- const bidResponses = spec.interpretResponse(fakeServerResponse, fakeBidRequests);
- expect(bidResponses).deep.equal([fakeBidResult]);
- });
- });
-
- describe('getApiServer', function() {
- it('should use the server specified by setConfig(appier.server)', function() {
- config.setConfig({
- 'appier': {'server': 'fake_server'}
- });
-
- const server = spec.getApiServer();
-
- expect(server).equals('fake_server');
- });
-
- it('should retrieve a farm specific hostname if server is not specpfied', function() {
- config.setConfig({
- 'appier': {'farm': 'tw'}
- });
-
- const server = spec.getApiServer();
-
- expect(server).equals(API_SERVERS_MAP['tw']);
- });
-
- it('if farm is not recognized, use the default farm', function() {
- config.setConfig({
- 'appier': {'farm': 'no_this_farm'}
- });
-
- const server = spec.getApiServer();
-
- expect(server).equals(API_SERVERS_MAP['default']);
- });
-
- it('if farm is not specified, use the default farm', function() {
- config.setConfig({
- 'appier': {}
- });
-
- const server = spec.getApiServer();
-
- expect(server).equals(API_SERVERS_MAP['default']);
- });
- });
-});
diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js
deleted file mode 100644
index f4a00bfb2..000000000
--- a/test/spec/modules/appnexusBidAdapter_spec.js
+++ /dev/null
@@ -1,2522 +0,0 @@
-import { expect } from 'chai';
-import { spec } from 'modules/appnexusBidAdapter.js';
-import { newBidder } from 'src/adapters/bidderFactory.js';
-import { auctionManager } from 'src/auctionManager.js';
-import { deepClone } from 'src/utils.js';
-import * as utils from 'src/utils.js';
-import { config } from 'src/config.js';
-import {getGlobal} from '../../../src/prebidGlobal.js';
-
-const ENDPOINT = 'https://ib.adnxs.com/ut/v3/prebid';
-
-describe('AppNexusAdapter', function () {
- const adapter = newBidder(spec);
-
- describe('inherited functions', function () {
- it('exists and is a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- function expectKeywords(actual, expected) {
- expect(actual.length).to.equal(expected.length);
- actual.forEach(el => {
- const match = expected.find(ob => ob.key === el.key);
- if (el.value) {
- expect(el.value).to.have.members(match.value);
- } else {
- expect(match.value).to.not.exist;
- }
- })
- }
-
- describe('isBidRequestValid', function () {
- const bid = {
- 'bidder': 'appnexus',
- 'params': {
- 'placementId': '10433394'
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [[300, 250], [300, 600]],
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- };
-
- it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should return true when required params found', function () {
- const bid1 = deepClone(bid);
- bid1.params = {
- 'placement_id': 123423
- }
- expect(spec.isBidRequestValid(bid1)).to.equal(true);
- });
-
- it('should return true when required params found', function () {
- const bid1 = deepClone(bid);
- bid1.params = {
- 'member': '1234',
- 'invCode': 'ABCD'
- };
-
- expect(spec.isBidRequestValid(bid1)).to.equal(true);
- });
-
- it('should return true when required params found', function () {
- const bid1 = deepClone(bid);
- bid1.params = {
- 'member': '1234',
- 'inv_code': 'ABCD'
- };
-
- expect(spec.isBidRequestValid(bid1)).to.equal(true);
- });
-
- it('should return false when required params are not passed', function () {
- const invalidBid = Object.assign({}, bid);
- delete invalidBid.params;
- invalidBid.params = {
- 'placementId': 0
- };
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
-
- it('should return false when required params are not passed', function () {
- const invalidBid = Object.assign({}, bid);
- delete invalidBid.params;
- invalidBid.params = {
- 'placement_id': 0
- };
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
- });
-
- describe('buildRequests', function () {
- let getAdUnitsStub;
- const bidRequests = [
- {
- 'bidder': 'appnexus',
- 'params': {
- 'placementId': '10433394'
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [[300, 250], [300, 600]],
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- 'transactionId': '04f2659e-c005-4eb1-a57c-fa93145e3843'
- }
- ];
-
- beforeEach(function () {
- getAdUnitsStub = sinon.stub(auctionManager, 'getAdUnits').callsFake(function () {
- return [];
- });
- });
-
- afterEach(function () {
- getAdUnitsStub.restore();
- });
-
- it('should parse out private sizes', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: {
- placementId: '10433394',
- privateSizes: [300, 250]
- }
- }
- );
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].private_sizes).to.exist;
- expect(payload.tags[0].private_sizes).to.deep.equal([{ width: 300, height: 250 }]);
- });
-
- it('should parse out private sizes', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: {
- placementId: '10433394',
- private_sizes: [300, 250]
- }
- }
- );
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].private_sizes).to.exist;
- expect(payload.tags[0].private_sizes).to.deep.equal([{ width: 300, height: 250 }]);
- });
-
- it('should add position in request', function () {
- // set from bid.params
- let bidRequest = deepClone(bidRequests[0]);
- bidRequest.params.position = 'above';
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].position).to.exist;
- expect(payload.tags[0].position).to.deep.equal(1);
-
- // set from mediaTypes.banner.pos = 1
- bidRequest = deepClone(bidRequests[0]);
- bidRequest.mediaTypes = {
- banner: { pos: 1 }
- };
-
- const request2 = spec.buildRequests([bidRequest]);
- const payload2 = JSON.parse(request2.data);
-
- expect(payload2.tags[0].position).to.exist;
- expect(payload2.tags[0].position).to.deep.equal(1);
-
- // set from mediaTypes.video.pos = 3
- bidRequest = deepClone(bidRequests[0]);
- bidRequest.mediaTypes = {
- video: { pos: 3 }
- };
-
- const request3 = spec.buildRequests([bidRequest]);
- const payload3 = JSON.parse(request3.data);
-
- expect(payload3.tags[0].position).to.exist;
- expect(payload3.tags[0].position).to.deep.equal(2);
-
- // bid.params trumps mediatypes
- bidRequest = deepClone(bidRequests[0]);
- bidRequest.params.position = 'above';
- bidRequest.mediaTypes = {
- banner: { pos: 3 }
- };
-
- const request4 = spec.buildRequests([bidRequest]);
- const payload4 = JSON.parse(request4.data);
-
- expect(payload4.tags[0].position).to.exist;
- expect(payload4.tags[0].position).to.deep.equal(1);
- });
-
- it('should add publisher_id in request', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: {
- placementId: '10433394',
- publisherId: '1231234'
- }
- });
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].publisher_id).to.exist;
- expect(payload.tags[0].publisher_id).to.deep.equal(1231234);
- expect(payload.publisher_id).to.exist;
- expect(payload.publisher_id).to.deep.equal(1231234);
- });
-
- it('should add publisher_id in request', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: {
- placement_id: '10433394',
- publisher_id: '1231234'
- }
- });
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].publisher_id).to.exist;
- expect(payload.tags[0].publisher_id).to.deep.equal(1231234);
- expect(payload.publisher_id).to.exist;
- expect(payload.publisher_id).to.deep.equal(1231234);
- });
-
- it('should add source and verison to the tag', function () {
- const request = spec.buildRequests(bidRequests);
- const payload = JSON.parse(request.data);
- expect(payload.sdk).to.exist;
- expect(payload.sdk).to.deep.equal({
- source: 'pbjs',
- version: '$prebid.version$'
- });
- });
-
- it('should populate the ad_types array on all requests', function () {
- const adUnits = [{
- code: 'adunit-code',
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [300, 600]]
- }
- },
- bids: [{
- bidder: 'appnexus',
- params: {
- placement_id: '10433394'
- }
- }],
- transactionId: '04f2659e-c005-4eb1-a57c-fa93145e3843'
- }];
-
- const types = ['banner'];
- if (FEATURES.NATIVE) {
- types.push('native');
- }
-
- if (FEATURES.VIDEO) {
- types.push('video');
- }
-
- types.forEach(type => {
- getAdUnitsStub.callsFake(function (...args) {
- return adUnits;
- });
-
- const bidRequest = Object.assign({}, bidRequests[0]);
- bidRequest.mediaTypes = {};
- bidRequest.mediaTypes[type] = {};
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].ad_types).to.deep.equal([type]);
-
- if (type === 'banner') {
- delete adUnits[0].mediaTypes;
- }
- });
- });
-
- it('should not populate the ad_types array when adUnit.mediaTypes is undefined', function () {
- const bidRequest = Object.assign({}, bidRequests[0]);
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].ad_types).to.not.exist;
- });
-
- if (FEATURES.VIDEO) {
- it('should populate the ad_types array on outstream requests', function () {
- const bidRequest = Object.assign({}, bidRequests[0]);
- bidRequest.mediaTypes = {};
- bidRequest.mediaTypes.video = { context: 'outstream' };
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].ad_types).to.deep.equal(['video']);
- expect(payload.tags[0].hb_source).to.deep.equal(1);
- });
-
- it('should attach valid video params to the tag', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: {
- placementId: '10433394',
- video: {
- id: 123,
- minduration: 100,
- foobar: 'invalid'
- }
- }
- }
- );
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
- expect(payload.tags[0].video).to.deep.equal({
- id: 123,
- minduration: 100
- });
- expect(payload.tags[0].hb_source).to.deep.equal(1);
- });
-
- it('should include ORTB video values when matching video params were not all set', function () {
- const bidRequest = deepClone(bidRequests[0]);
- bidRequest.params = {
- placementId: '1234235',
- video: {
- skippable: true,
- playback_method: ['auto_play_sound_off', 'auto_play_sound_unknown'],
- context: 'outstream'
- }
- };
- bidRequest.mediaTypes = {
- video: {
- playerSize: [640, 480],
- context: 'outstream',
- mimes: ['video/mp4'],
- skip: 0,
- minduration: 5,
- api: [1, 5, 6],
- playbackmethod: [2, 4]
- }
- };
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].video).to.deep.equal({
- minduration: 5,
- playback_method: 2,
- skippable: true,
- context: 4
- });
- expect(payload.tags[0].video_frameworks).to.deep.equal([1, 4])
- });
-
- it('should include ORTB video values when video params is empty - case 1', function () {
- const bidRequest = deepClone(bidRequests[0]);
- bidRequest.mediaTypes = {
- video: {
- playerSize: [640, 480],
- context: 'outstream',
- placement: 3,
- mimes: ['video/mp4'],
- skip: 0,
- minduration: 5,
- api: [1, 5, 6],
- playbackmethod: [2, 4]
- }
- };
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].video).to.deep.equal({
- minduration: 5,
- playback_method: 2,
- skippable: false,
- context: 4
- });
- expect(payload.tags[0].video_frameworks).to.deep.equal([1, 4])
- });
-
- it('should include ORTB video values when video params is empty - case 2', function () {
- const bidRequest = deepClone(bidRequests[0]);
- bidRequest.mediaTypes = {
- video: {
- playerSize: [640, 480],
- context: 'outstream',
- plcmt: 2,
- startdelay: 0,
- mimes: ['video/mp4'],
- skip: 1,
- minduration: 5,
- api: [1, 5, 6],
- playbackmethod: [2, 4]
- }
- };
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].video).to.deep.equal({
- minduration: 5,
- playback_method: 2,
- skippable: true,
- context: 8
- });
- expect(payload.tags[0].video_frameworks).to.deep.equal([1, 4])
- });
-
- it('should include ORTB video values when video params is empty - case 1', function () {
- const bidRequest = deepClone(bidRequests[0]);
- bidRequest.mediaTypes = {
- video: {
- playerSize: [640, 480],
- context: 'outstream',
- mimes: ['video/mp4'],
- startdelay: 0,
- skip: 0,
- minduration: 5,
- api: [1, 5, 6],
- playbackmethod: [2, 4]
- }
- };
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].video).to.deep.equal({
- minduration: 5,
- playback_method: 2,
- skippable: false,
- context: 1
- });
- expect(payload.tags[0].video_frameworks).to.deep.equal([1, 4])
- });
-
- it('should convert and include ORTB2 device data when available', function () {
- const bidRequest = deepClone(bidRequests[0]);
- const bidderRequest = {
- ortb2: {
- device: {
- w: 980,
- h: 1720,
- dnt: 0,
- ua: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/125.0.6422.80 Mobile/15E148 Safari/604.1',
- language: 'en',
- devicetype: 1,
- make: 'Apple',
- model: 'iPhone 12 Pro Max',
- os: 'iOS',
- osv: '17.4',
- },
- },
- };
-
- const expectedDeviceResult = {
- useragent: bidderRequest.ortb2.device.ua,
- devicetype: 'Mobile/Tablet - General',
- make: bidderRequest.ortb2.device.make,
- model: bidderRequest.ortb2.device.model,
- os: bidderRequest.ortb2.device.os,
- os_version: bidderRequest.ortb2.device.osv,
- w: bidderRequest.ortb2.device.w,
- h: bidderRequest.ortb2.device.h,
- };
-
- const request = spec.buildRequests([bidRequest], bidderRequest);
- const payload = JSON.parse(request.data);
-
- expect(payload.device).to.deep.equal(expectedDeviceResult);
- });
-
- it('should add video property when adUnit includes a renderer', function () {
- const videoData = {
- mediaTypes: {
- video: {
- context: 'outstream',
- mimes: ['video/mp4']
- }
- },
- params: {
- placementId: '10433394',
- video: {
- skippable: true,
- playback_method: ['auto_play_sound_off']
- }
- }
- };
-
- let bidRequest1 = deepClone(bidRequests[0]);
- bidRequest1 = Object.assign({}, bidRequest1, videoData, {
- renderer: {
- url: 'https://test.renderer.url',
- render: function () { }
- }
- });
-
- let bidRequest2 = deepClone(bidRequests[0]);
- bidRequest2.adUnitCode = 'adUnit_code_2';
- bidRequest2 = Object.assign({}, bidRequest2, videoData);
-
- const request = spec.buildRequests([bidRequest1, bidRequest2]);
- const payload = JSON.parse(request.data);
- expect(payload.tags[0].video).to.deep.equal({
- skippable: true,
- playback_method: 2,
- custom_renderer_present: true
- });
- expect(payload.tags[1].video).to.deep.equal({
- skippable: true,
- playback_method: 2
- });
- });
-
- it('should duplicate adpod placements into batches and set correct maxduration', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: { placementId: '14542875' }
- },
- {
- mediaTypes: {
- video: {
- context: 'adpod',
- playerSize: [640, 480],
- adPodDurationSec: 300,
- durationRangeSec: [15, 30],
- }
- }
- }
- );
-
- const request = spec.buildRequests([bidRequest]);
- const payload1 = JSON.parse(request[0].data);
- const payload2 = JSON.parse(request[1].data);
-
- // 300 / 15 = 20 total
- expect(payload1.tags.length).to.equal(15);
- expect(payload2.tags.length).to.equal(5);
-
- expect(payload1.tags[0]).to.deep.equal(payload1.tags[1]);
- expect(payload1.tags[0].video.maxduration).to.equal(30);
-
- expect(payload2.tags[0]).to.deep.equal(payload1.tags[1]);
- expect(payload2.tags[0].video.maxduration).to.equal(30);
- });
-
- it('should round down adpod placements when numbers are uneven', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: { placementId: '14542875' }
- },
- {
- mediaTypes: {
- video: {
- context: 'adpod',
- playerSize: [640, 480],
- adPodDurationSec: 123,
- durationRangeSec: [45],
- }
- }
- }
- );
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
- expect(payload.tags.length).to.equal(2);
- });
-
- it('should duplicate adpod placements when requireExactDuration is set', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: { placementId: '14542875' }
- },
- {
- mediaTypes: {
- video: {
- context: 'adpod',
- playerSize: [640, 480],
- adPodDurationSec: 300,
- durationRangeSec: [15, 30],
- requireExactDuration: true,
- }
- }
- }
- );
-
- // 20 total placements with 15 max impressions = 2 requests
- const request = spec.buildRequests([bidRequest]);
- expect(request.length).to.equal(2);
-
- // 20 spread over 2 requests = 15 in first request, 5 in second
- const payload1 = JSON.parse(request[0].data);
- const payload2 = JSON.parse(request[1].data);
- expect(payload1.tags.length).to.equal(15);
- expect(payload2.tags.length).to.equal(5);
-
- // 10 placements should have max/min at 15
- // 10 placemenst should have max/min at 30
- const payload1tagsWith15 = payload1.tags.filter(tag => tag.video.maxduration === 15);
- const payload1tagsWith30 = payload1.tags.filter(tag => tag.video.maxduration === 30);
- expect(payload1tagsWith15.length).to.equal(10);
- expect(payload1tagsWith30.length).to.equal(5);
-
- // 5 placemenst with min/max at 30 were in the first request
- // so 5 remaining should be in the second
- const payload2tagsWith30 = payload2.tags.filter(tag => tag.video.maxduration === 30);
- expect(payload2tagsWith30.length).to.equal(5);
- });
-
- it('should set durations for placements when requireExactDuration is set and numbers are uneven', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: { placementId: '14542875' }
- },
- {
- mediaTypes: {
- video: {
- context: 'adpod',
- playerSize: [640, 480],
- adPodDurationSec: 105,
- durationRangeSec: [15, 30, 60],
- requireExactDuration: true,
- }
- }
- }
- );
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
- expect(payload.tags.length).to.equal(7);
-
- const tagsWith15 = payload.tags.filter(tag => tag.video.maxduration === 15);
- const tagsWith30 = payload.tags.filter(tag => tag.video.maxduration === 30);
- const tagsWith60 = payload.tags.filter(tag => tag.video.maxduration === 60);
- expect(tagsWith15.length).to.equal(3);
- expect(tagsWith30.length).to.equal(3);
- expect(tagsWith60.length).to.equal(1);
- });
-
- it('should break adpod request into batches', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: { placementId: '14542875' }
- },
- {
- mediaTypes: {
- video: {
- context: 'adpod',
- playerSize: [640, 480],
- adPodDurationSec: 225,
- durationRangeSec: [5],
- }
- }
- }
- );
-
- const request = spec.buildRequests([bidRequest]);
- const payload1 = JSON.parse(request[0].data);
- const payload2 = JSON.parse(request[1].data);
- const payload3 = JSON.parse(request[2].data);
-
- expect(payload1.tags.length).to.equal(15);
- expect(payload2.tags.length).to.equal(15);
- expect(payload3.tags.length).to.equal(15);
- });
-
- it('should contain hb_source value for adpod', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: { placementId: '14542875' }
- },
- {
- mediaTypes: {
- video: {
- context: 'adpod',
- playerSize: [640, 480],
- adPodDurationSec: 300,
- durationRangeSec: [15, 30],
- }
- }
- }
- );
- const request = spec.buildRequests([bidRequest])[0];
- const payload = JSON.parse(request.data);
- expect(payload.tags[0].hb_source).to.deep.equal(7);
- });
- } // VIDEO
-
- it('sends bid request to ENDPOINT via POST', function () {
- const request = spec.buildRequests(bidRequests);
- expect(request.url).to.equal(ENDPOINT);
- expect(request.method).to.equal('POST');
- });
-
- it('should attach valid user params to the tag', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: {
- placement_id: '10433394',
- user: {
- externalUid: '123',
- segments: [123, { id: 987, value: 876 }],
- foobar: 'invalid'
- }
- }
- }
- );
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.user).to.exist;
- expect(payload.user).to.deep.equal({
- external_uid: '123',
- segments: [{ id: 123 }, { id: 987, value: 876 }]
- });
- });
-
- it('should add debug params from query', function () {
- const getParamStub = sinon.stub(utils, 'getParameterByName').callsFake(function(par) {
- if (par === 'apn_debug_dongle') return 'abcdef';
- if (par === 'apn_debug_member_id') return '1234';
- if (par === 'apn_debug_timeout') return '1000';
-
- return '';
- });
-
- const bidRequest = deepClone(bidRequests[0]);
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.debug).to.exist.and.to.deep.equal({
- 'dongle': 'abcdef',
- 'enabled': true,
- 'member_id': 1234,
- 'debug_timeout': 1000
- });
-
- getParamStub.restore();
- });
-
- it('should attach reserve param when either bid param or getFloor function exists', function () {
- const getFloorResponse = { currency: 'USD', floor: 3 };
- let request; let payload = null;
- const bidRequest = deepClone(bidRequests[0]);
-
- // 1 -> reserve not defined, getFloor not defined > empty
- request = spec.buildRequests([bidRequest]);
- payload = JSON.parse(request.data);
-
- expect(payload.tags[0].reserve).to.not.exist;
-
- // 2 -> reserve is defined, getFloor not defined > reserve is used
- bidRequest.params = {
- 'placement_id': '10433394',
- 'reserve': 0.5
- };
- request = spec.buildRequests([bidRequest]);
- payload = JSON.parse(request.data);
-
- expect(payload.tags[0].reserve).to.exist.and.to.equal(0.5);
-
- // 3 -> reserve is defined, getFloor is defined > getFloor is used
- bidRequest.getFloor = () => getFloorResponse;
-
- request = spec.buildRequests([bidRequest]);
- payload = JSON.parse(request.data);
-
- expect(payload.tags[0].reserve).to.exist.and.to.equal(3);
- });
-
- it('should contain hb_source value for other media', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- mediaType: 'banner',
- params: {
- sizes: [[300, 250], [300, 600]],
- placement_id: 13144370
- }
- }
- );
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
- expect(payload.tags[0].hb_source).to.deep.equal(1);
- });
-
- it('adds brand_category_exclusion to request when set', function () {
- const bidRequest = Object.assign({}, bidRequests[0]);
- sinon
- .stub(config, 'getConfig')
- .withArgs('adpod.brandCategoryExclusion')
- .returns(true);
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.brand_category_uniqueness).to.equal(true);
-
- config.getConfig.restore();
- });
-
- it('adds auction level keywords and ortb2 keywords to request when set', function () {
- const bidRequest = Object.assign({}, bidRequests[0]);
- sinon
- .stub(config, 'getConfig')
- .withArgs('appnexusAuctionKeywords')
- .returns({
- gender: 'm',
- music: ['rock', 'pop'],
- test: '',
- tools: 'power'
- });
-
- const bidderRequest = {
- ortb2: {
- site: {
- keywords: 'power tools, drills, tools=industrial',
- content: {
- keywords: 'video, source=streaming'
- }
- },
- user: {
- keywords: 'tools=home,renting'
- },
- app: {
- keywords: 'app=iphone 11',
- content: {
- keywords: 'appcontent=home repair, dyi'
- }
- }
- }
- };
-
- const request = spec.buildRequests([bidRequest], bidderRequest);
- const payload = JSON.parse(request.data);
-
- expectKeywords(payload.keywords, [{
- 'key': 'gender',
- 'value': ['m']
- }, {
- 'key': 'music',
- 'value': ['rock', 'pop']
- }, {
- 'key': 'test'
- }, {
- 'key': 'tools',
- 'value': ['power', 'industrial', 'home']
- }, {
- 'key': 'power tools'
- }, {
- 'key': 'drills'
- }, {
- 'key': 'video'
- }, {
- 'key': 'source',
- 'value': ['streaming']
- }, {
- 'key': 'renting'
- }, {
- 'key': 'app',
- 'value': ['iphone 11']
- }, {
- 'key': 'appcontent',
- 'value': ['home repair']
- }, {
- 'key': 'dyi'
- }]);
-
- config.getConfig.restore();
- });
-
- it('adds ortb2 segments to auction request as keywords', function() {
- const bidRequest = Object.assign({}, bidRequests[0]);
- const bidderRequest = {
- ortb2: {
- site: {
- keywords: 'drill',
- content: {
- data: [{
- name: 'siteseg1',
- ext: {
- segtax: 540
- },
- segment: [{
- id: 's123',
- }, {
- id: 's234'
- }]
- }, {
- name: 'sitseg2',
- ext: {
- segtax: 1
- },
- segment: [{
- id: 'unknown'
- }]
- }, {
- name: 'siteseg3',
- ext: {
- segtax: 526
- },
- segment: [{
- id: 'dog'
- }]
- }]
- }
- },
- user: {
- data: [{
- name: 'userseg1',
- ext: {
- segtax: 526
- },
- segment: [{
- id: 'cat'
- }]
- }]
- }
- }
- };
- const request = spec.buildRequests([bidRequest], bidderRequest);
- const payload = JSON.parse(request.data);
-
- expectKeywords(payload.keywords, [{
- 'key': 'drill'
- }, {
- 'key': '1plusX',
- 'value': ['cat', 'dog']
- }, {
- 'key': 'perid',
- 'value': ['s123', 's234']
- }]);
- });
-
- if (FEATURES.NATIVE) {
- it('should attach native params to the request', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- mediaType: 'native',
- nativeParams: {
- title: { required: true },
- body: { required: true },
- body2: { required: true },
- image: { required: true, sizes: [100, 100] },
- icon: { required: true },
- cta: { required: false },
- rating: { required: true },
- sponsoredBy: { required: true },
- privacyLink: { required: true },
- displayUrl: { required: true },
- address: { required: true },
- downloads: { required: true },
- likes: { required: true },
- phone: { required: true },
- price: { required: true },
- salePrice: { required: true }
- }
- }
- );
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].native.layouts[0]).to.deep.equal({
- title: { required: true },
- description: { required: true },
- desc2: { required: true },
- main_image: { required: true, sizes: [{ width: 100, height: 100 }] },
- icon: { required: true },
- ctatext: { required: false },
- rating: { required: true },
- sponsored_by: { required: true },
- privacy_link: { required: true },
- displayurl: { required: true },
- address: { required: true },
- downloads: { required: true },
- likes: { required: true },
- phone: { required: true },
- price: { required: true },
- saleprice: { required: true },
- privacy_supported: true
- });
- expect(payload.tags[0].hb_source).to.equal(1);
- });
-
- it('should always populated tags[].sizes with 1,1 for native if otherwise not defined', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- mediaType: 'native',
- nativeParams: {
- image: { required: true }
- }
- }
- );
- bidRequest.sizes = [[150, 100], [300, 250]];
-
- let request = spec.buildRequests([bidRequest]);
- let payload = JSON.parse(request.data);
- expect(payload.tags[0].sizes).to.deep.equal([{ width: 150, height: 100 }, { width: 300, height: 250 }]);
-
- delete bidRequest.sizes;
-
- request = spec.buildRequests([bidRequest]);
- payload = JSON.parse(request.data);
-
- expect(payload.tags[0].sizes).to.deep.equal([{ width: 1, height: 1 }]);
- });
- }
-
- it('should convert keyword params (when there are no ortb keywords) to proper form and attaches to request', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: {
- placement_id: '10433394',
- keywords: {
- single: 'val',
- singleArr: ['val'],
- singleArrNum: [5],
- multiValMixed: ['value1', 2, 'value3'],
- singleValNum: 123,
- emptyStr: '',
- emptyArr: [''],
- badValue: { 'foo': 'bar' } // should be dropped
- }
- }
- }
- );
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expectKeywords(payload.tags[0].keywords, [
- {
- 'key': 'single',
- 'value': ['val']
- }, {
- 'key': 'singleArr',
- 'value': ['val']
- }, {
- 'key': 'singleArrNum',
- 'value': ['5']
- }, {
- 'key': 'multiValMixed',
- 'value': ['value1', '2', 'value3']
- }, {
- 'key': 'singleValNum',
- 'value': ['123']
- }, {
- 'key': 'emptyStr'
- }, {
- 'key': 'emptyArr'
- }
- ])
- });
-
- it('should convert adUnit ortb2 keywords (when there are no bid param keywords) to proper form and attaches to request', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- ortb2Imp: {
- ext: {
- data: {
- keywords: 'ortb2=yes,ortb2test, multiValMixed=4, singleValNum=456'
- }
- }
- }
- }
- );
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expectKeywords(payload.tags[0].keywords, [{
- 'key': 'ortb2',
- 'value': ['yes']
- }, {
- 'key': 'ortb2test'
- }, {
- 'key': 'multiValMixed',
- 'value': ['4']
- }, {
- 'key': 'singleValNum',
- 'value': ['456']
- }]);
- });
-
- it('should convert keyword params and adUnit ortb2 keywords to proper form and attaches to request', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: {
- placementId: '10433394',
- keywords: {
- single: 'val',
- singleArr: ['val'],
- singleArrNum: [5],
- multiValMixed: ['value1', 2, 'value3'],
- singleValNum: 123,
- emptyStr: '',
- emptyArr: [''],
- badValue: { 'foo': 'bar' } // should be dropped
- }
- },
- ortb2Imp: {
- ext: {
- data: {
- keywords: 'ortb2=yes,ortb2test, multiValMixed=4, singleValNum=456'
- }
- }
- }
- }
- );
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expectKeywords(payload.tags[0].keywords, [{
- 'key': 'single',
- 'value': ['val']
- }, {
- 'key': 'singleArr',
- 'value': ['val']
- }, {
- 'key': 'singleArrNum',
- 'value': ['5']
- }, {
- 'key': 'multiValMixed',
- 'value': ['value1', '2', 'value3', '4']
- }, {
- 'key': 'singleValNum',
- 'value': ['123', '456']
- }, {
- 'key': 'emptyStr'
- }, {
- 'key': 'emptyArr'
- }, {
- 'key': 'ortb2',
- 'value': ['yes']
- }, {
- 'key': 'ortb2test'
- }]);
- });
-
- it('should add payment rules to the request', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: {
- placementId: '10433394',
- usePaymentRule: true
- }
- }
- );
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].use_pmt_rule).to.equal(true);
- });
-
- it('should add payment rules to the request', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: {
- placement_id: '10433394',
- use_payment_rule: true
- }
- }
- );
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].use_pmt_rule).to.equal(true);
- });
-
- it('should add preferred gpid to the request', function () {
- const testGpid = '/12345/my-gpt-tag-0';
- const bidRequest = deepClone(bidRequests[0]);
- bidRequest.ortb2Imp = { ext: { gpid: testGpid } };
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].gpid).to.exist.and.equal(testGpid);
- });
-
- it('should add backup gpid to the request', function () {
- const testGpid = '/12345/my-gpt-tag-0';
- const bidRequest = deepClone(bidRequests[0]);
- bidRequest.ortb2Imp = { ext: { data: {}, gpid: testGpid } };
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].gpid).to.exist.and.equal(testGpid);
- });
-
- it('should add tid to the request', function () {
- const testTid = '1234test';
- const bidRequest = deepClone(bidRequests[0]);
- bidRequest.ortb2Imp = { ext: { tid: testTid } };
- // bidRequest.ortb2 = { source: { tid: testTid } };
-
- const bidderRequest = {
- 'bidderCode': 'appnexus',
- 'auctionId': '1d1a030790a475',
- 'bidderRequestId': '22edbae2733bf6',
- 'timeout': 3000,
- ortb2: {
- source: {
- tid: testTid
- }
- }
- };
- bidderRequest.bids = [bidRequest];
-
- const request = spec.buildRequests([bidRequest], bidderRequest);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].tid).to.exist.and.equal(testTid);
- expect(payload.source.tid).to.exist.and.equal(testTid);
- });
-
- it('should add gdpr consent information to the request', function () {
- const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==';
- const bidderRequest = {
- 'bidderCode': 'appnexus',
- 'auctionId': '1d1a030790a475',
- 'bidderRequestId': '22edbae2733bf6',
- 'timeout': 3000,
- 'gdprConsent': {
- consentString: consentString,
- gdprApplies: true,
- addtlConsent: '1~7.12.35.62.66.70.89.93.108'
- }
- };
- bidderRequest.bids = bidRequests;
-
- const request = spec.buildRequests(bidRequests, bidderRequest);
- expect(request.options).to.deep.equal({ withCredentials: true });
- const payload = JSON.parse(request.data);
-
- expect(payload.gdpr_consent).to.exist;
- expect(payload.gdpr_consent.consent_string).to.exist.and.to.equal(consentString);
- expect(payload.gdpr_consent.consent_required).to.exist.and.to.be.true;
- expect(payload.gdpr_consent.addtl_consent).to.exist.and.to.deep.equal([7, 12, 35, 62, 66, 70, 89, 93, 108]);
- });
-
- it('should add us privacy string to payload', function () {
- const consentString = '1YA-';
- const bidderRequest = {
- 'bidderCode': 'appnexus',
- 'auctionId': '1d1a030790a475',
- 'bidderRequestId': '22edbae2733bf6',
- 'timeout': 3000,
- 'uspConsent': consentString
- };
- bidderRequest.bids = bidRequests;
-
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const payload = JSON.parse(request.data);
-
- expect(payload.us_privacy).to.exist;
- expect(payload.us_privacy).to.exist.and.to.equal(consentString);
- });
-
- it('should add gpp information to the request via bidderRequest.gppConsent', function () {
- const consentString = 'abc1234';
- const bidderRequest = {
- 'bidderCode': 'appnexus',
- 'auctionId': '1d1a030790a475',
- 'bidderRequestId': '22edbae2733bf6',
- 'timeout': 3000,
- 'gppConsent': {
- 'gppString': consentString,
- 'applicableSections': [8]
- }
- };
- bidderRequest.bids = bidRequests;
-
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const payload = JSON.parse(request.data);
-
- expect(payload.privacy).to.exist;
- expect(payload.privacy.gpp).to.equal(consentString);
- expect(payload.privacy.gpp_sid).to.deep.equal([8]);
- });
-
- it('should add gpp information to the request via bidderRequest.ortb2.regs', function () {
- const consentString = 'abc1234';
- const bidderRequest = {
- 'bidderCode': 'appnexus',
- 'auctionId': '1d1a030790a475',
- 'bidderRequestId': '22edbae2733bf6',
- 'timeout': 3000,
- 'ortb2': {
- 'regs': {
- 'gpp': consentString,
- 'gpp_sid': [7]
- }
- }
- };
- bidderRequest.bids = bidRequests;
-
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const payload = JSON.parse(request.data);
-
- expect(payload.privacy).to.exist;
- expect(payload.privacy.gpp).to.equal(consentString);
- expect(payload.privacy.gpp_sid).to.deep.equal([7]);
- });
-
- it('should add dsa information to the request via bidderRequest.ortb2.regs.ext.dsa', function () {
- const bidderRequest = {
- 'bidderCode': 'appnexus',
- 'auctionId': '1d1a030790a475',
- 'bidderRequestId': '22edbae2733bf6',
- 'timeout': 3000,
- 'ortb2': {
- 'regs': {
- 'ext': {
- 'dsa': {
- 'dsarequired': 1,
- 'pubrender': 0,
- 'datatopub': 1,
- 'transparency': [{
- 'domain': 'good-domain',
- 'dsaparams': [1, 2]
- }, {
- 'domain': 'bad-setup',
- 'dsaparams': ['1', 3]
- }]
- }
- }
- }
- }
- };
- bidderRequest.bids = bidRequests;
-
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const payload = JSON.parse(request.data);
-
- expect(payload.dsa).to.exist;
- expect(payload.dsa.dsarequired).to.equal(1);
- expect(payload.dsa.pubrender).to.equal(0);
- expect(payload.dsa.datatopub).to.equal(1);
- expect(payload.dsa.transparency).to.deep.equal([{
- 'domain': 'good-domain',
- 'dsaparams': [1, 2]
- }]);
- });
-
- it('supports sending hybrid mobile app parameters', function () {
- const appRequest = Object.assign({},
- bidRequests[0],
- {
- params: {
- placementId: '10433394',
- app: {
- id: 'B1O2W3M4AN.com.prebid.webview',
- geo: {
- lat: 40.0964439,
- lng: -75.3009142
- },
- device_id: {
- idfa: '4D12078D-3246-4DA4-AD5E-7610481E7AE', // Apple advertising identifier
- aaid: '38400000-8cf0-11bd-b23e-10b96e40000d', // Android advertising identifier
- md5udid: '5756ae9022b2ea1e47d84fead75220c8', // MD5 hash of the ANDROID_ID
- sha1udid: '4DFAA92388699AC6539885AEF1719293879985BF', // SHA1 hash of the ANDROID_ID
- windowsadid: '750c6be243f1c4b5c9912b95a5742fc5' // Windows advertising identifier
- }
- }
- }
- }
- );
- const request = spec.buildRequests([appRequest]);
- const payload = JSON.parse(request.data);
- expect(payload.app).to.exist;
- expect(payload.app).to.deep.equal({
- appid: 'B1O2W3M4AN.com.prebid.webview'
- });
- expect(payload.device.device_id).to.exist;
- expect(payload.device.device_id).to.deep.equal({
- aaid: '38400000-8cf0-11bd-b23e-10b96e40000d',
- idfa: '4D12078D-3246-4DA4-AD5E-7610481E7AE',
- md5udid: '5756ae9022b2ea1e47d84fead75220c8',
- sha1udid: '4DFAA92388699AC6539885AEF1719293879985BF',
- windowsadid: '750c6be243f1c4b5c9912b95a5742fc5'
- });
- expect(payload.device.geo).to.exist;
- expect(payload.device.geo).to.deep.equal({
- lat: 40.0964439,
- lng: -75.3009142
- });
- });
-
- it('should add referer info to payload', function () {
- const bidRequest = Object.assign({}, bidRequests[0]);
- const bidderRequest = {
- refererInfo: {
- topmostLocation: 'https://example.com/page.html',
- reachedTop: true,
- numIframes: 2,
- stack: [
- 'https://example.com/page.html',
- 'https://example.com/iframe1.html',
- 'https://example.com/iframe2.html'
- ]
- }
- }
- const request = spec.buildRequests([bidRequest], bidderRequest);
- const payload = JSON.parse(request.data);
-
- expect(payload.referrer_detection).to.exist;
- expect(payload.referrer_detection).to.deep.equal({
- rd_ref: 'https%3A%2F%2Fexample.com%2Fpage.html',
- rd_top: true,
- rd_ifs: 2,
- rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',')
- });
- });
-
- it('if defined, should include publisher pageUrl to normal referer info in payload', function () {
- const bidRequest = Object.assign({}, bidRequests[0]);
-
- const bidderRequest = {
- refererInfo: {
- canonicalUrl: 'https://mypub.override.com/test/page.html',
- topmostLocation: 'https://example.com/page.html',
- reachedTop: true,
- numIframes: 2,
- stack: [
- 'https://example.com/page.html',
- 'https://example.com/iframe1.html',
- 'https://example.com/iframe2.html'
- ]
- }
- }
- const request = spec.buildRequests([bidRequest], bidderRequest);
- const payload = JSON.parse(request.data);
-
- expect(payload.referrer_detection).to.exist;
- expect(payload.referrer_detection).to.deep.equal({
- rd_ref: 'https%3A%2F%2Fexample.com%2Fpage.html',
- rd_top: true,
- rd_ifs: 2,
- rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(','),
- rd_can: 'https://mypub.override.com/test/page.html'
- });
- });
-
- it('should populate schain if available', function () {
- const bidRequest = Object.assign({}, bidRequests[0], {
- ortb2: {
- source: {
- ext: {
- schain: {
- ver: '1.0',
- complete: 1,
- nodes: [
- {
- 'asi': 'blob.com',
- 'sid': '001',
- 'hp': 1
- }
- ]
- }
- }
- }
- }
- });
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
- expect(payload.schain).to.deep.equal({
- ver: '1.0',
- complete: 1,
- nodes: [
- {
- 'asi': 'blob.com',
- 'sid': '001',
- 'hp': 1
- }
- ]
- });
- });
-
- it('should populate coppa if set in config', function () {
- const bidRequest = Object.assign({}, bidRequests[0]);
- sinon.stub(config, 'getConfig')
- .withArgs('coppa')
- .returns(true);
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.user.coppa).to.equal(true);
-
- config.getConfig.restore();
- });
-
- describe('ast_override_div', function () {
- let getParamStub;
- const bidRequest = Object.assign({}, bidRequests[0]);
- const bidRequest2 = deepClone(bidRequests[0]);
- bidRequest2.adUnitCode = 'adUnit_code_2';
- const bidRequest3 = deepClone(bidRequests[0]);
- bidRequest3.adUnitCode = 'adUnit_code_3';
-
- before(function () {
- getParamStub = sinon.stub(utils, 'getParameterByName');
- });
-
- it('should set forced creative id if one adUnitCode passed', function () {
- getParamStub.callsFake(function(par) {
- if (par === 'ast_override_div') return 'adunit-code:1234';
- return '';
- });
-
- const request = spec.buildRequests([bidRequest, bidRequest2]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].force_creative_id).to.deep.equal(1234);
- expect(payload.tags[1].force_creative_id).to.not.exist;
- });
-
- it('should set forced creative id if `ast_override_div` is set to override multiple adUnitCode', function () {
- getParamStub.callsFake(function(par) {
- if (par === 'ast_override_div') return 'adunit-code:1234,adUnit_code_2:5678';
- return '';
- });
-
- const request = spec.buildRequests([bidRequest, bidRequest2, bidRequest3]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].force_creative_id).to.deep.equal(1234);
- expect(payload.tags[1].force_creative_id).to.deep.equal(5678);
- expect(payload.tags[2].force_creative_id).to.not.exist;
- });
-
- it('should not set forced creative id if `ast_override_div` is missing creativeId', function () {
- getParamStub.callsFake(function(par) {
- if (par === 'ast_override_div') return 'adunit-code';
- return '';
- });
-
- const request = spec.buildRequests([bidRequest, bidRequest2]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].force_creative_id).to.not.exist;
- expect(payload.tags[1].force_creative_id).to.not.exist;
- });
-
- it('should not set forced creative id if `ast_override_div` is in the wrong format', function () {
- getParamStub.callsFake(function(par) {
- if (par === 'ast_override_div') return 'adunit-code;adUnit_code_2:5678';
- return '';
- }); ;
-
- const request = spec.buildRequests([bidRequest, bidRequest2]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].force_creative_id).to.not.exist;
- expect(payload.tags[1].force_creative_id).to.not.exist;
- });
-
- it('should not set forced creative id if `ast_override_div` is missing', function () {
- getParamStub.callsFake(function(par) {
- return '';
- }); ;
-
- const request = spec.buildRequests([bidRequest, bidRequest2]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].force_creative_id).to.not.exist;
- expect(payload.tags[1].force_creative_id).to.not.exist;
- });
-
- after(function () {
- getParamStub.restore();
- });
- });
-
- it('should set the X-Is-Test customHeader if test flag is enabled', function () {
- const bidRequest = Object.assign({}, bidRequests[0]);
- sinon.stub(config, 'getConfig')
- .withArgs('apn_test')
- .returns(true);
-
- const request = spec.buildRequests([bidRequest]);
- expect(request.options.customHeaders).to.deep.equal({ 'X-Is-Test': 1 });
-
- config.getConfig.restore();
- });
-
- it('should always set withCredentials: true on the request.options', function () {
- const bidRequest = Object.assign({}, bidRequests[0]);
- const request = spec.buildRequests([bidRequest]);
- expect(request.options.withCredentials).to.equal(true);
- });
-
- it('should set simple domain variant if purpose 1 consent is not given', function () {
- const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==';
- const bidderRequest = {
- 'bidderCode': 'appnexus',
- 'auctionId': '1d1a030790a475',
- 'bidderRequestId': '22edbae2733bf6',
- 'timeout': 3000,
- 'gdprConsent': {
- consentString: consentString,
- gdprApplies: true,
- apiVersion: 2,
- vendorData: {
- purpose: {
- consents: {
- 1: false
- }
- }
- }
- }
- };
- bidderRequest.bids = bidRequests;
-
- const request = spec.buildRequests(bidRequests, bidderRequest);
- expect(request.url).to.equal('https://ib.adnxs-simple.com/ut/v3/prebid');
- });
-
- it('should populate eids when supported userIds are available', function () {
- const bidRequest = Object.assign({}, bidRequests[0], {
- userIdAsEids: [{
- source: 'adserver.org',
- uids: [{ id: 'sample-userid' }]
- }, {
- source: 'criteo.com',
- uids: [{ id: 'sample-criteo-userid' }]
- }, {
- source: 'netid.de',
- uids: [{ id: 'sample-netId-userid' }]
- }, {
- source: 'liveramp.com',
- uids: [{ id: 'sample-idl-userid' }]
- }, {
- source: 'uidapi.com',
- uids: [{ id: 'sample-uid2-value' }]
- }, {
- source: 'puburl.com',
- uids: [{ id: 'pubid1' }]
- }, {
- source: 'puburl2.com',
- uids: [{ id: 'pubid2' }, { id: 'pubid2-123' }]
- }]
- });
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
- expect(payload.eids).to.deep.include({
- source: 'adserver.org',
- id: 'sample-userid',
- rti_partner: 'TDID'
- });
-
- expect(payload.eids).to.deep.include({
- source: 'criteo.com',
- id: 'sample-criteo-userid',
- });
-
- expect(payload.eids).to.deep.include({
- source: 'netid.de',
- id: 'sample-netId-userid',
- });
-
- expect(payload.eids).to.deep.include({
- source: 'liveramp.com',
- id: 'sample-idl-userid'
- });
-
- expect(payload.eids).to.deep.include({
- source: 'uidapi.com',
- id: 'sample-uid2-value',
- rti_partner: 'UID2'
- });
-
- expect(payload.eids).to.deep.include({
- source: 'puburl.com',
- id: 'pubid1'
- });
-
- expect(payload.eids).to.deep.include({
- source: 'puburl2.com',
- id: 'pubid2'
- });
- expect(payload.eids).to.deep.include({
- source: 'puburl2.com',
- id: 'pubid2-123'
- });
- });
-
- it('should populate iab_support object at the root level if omid support is detected', function () {
- let request, payload;
-
- if (FEATURES.VIDEO) {
- // with bid.params.frameworks
- const bidRequest_A = Object.assign({}, bidRequests[0], {
- params: {
- frameworks: [1, 2, 5, 6],
- video: {
- frameworks: [1, 2, 5, 6]
- }
- }
- });
- request = spec.buildRequests([bidRequest_A]);
- payload = JSON.parse(request.data);
- expect(payload.iab_support).to.be.an('object');
- expect(payload.iab_support).to.deep.equal({
- omidpn: 'Appnexus',
- omidpv: '$prebid.version$'
- });
- expect(payload.tags[0].banner_frameworks).to.be.an('array');
- expect(payload.tags[0].banner_frameworks).to.deep.equal([1, 2, 5, 6]);
- expect(payload.tags[0].video_frameworks).to.be.an('array');
- expect(payload.tags[0].video_frameworks).to.deep.equal([1, 2, 5, 6]);
- expect(payload.tags[0].video.frameworks).to.not.exist;
- }
-
- // without bid.params.frameworks
- const bidRequest_B = Object.assign({}, bidRequests[0]);
- request = spec.buildRequests([bidRequest_B]);
- payload = JSON.parse(request.data);
- expect(payload.iab_support).to.not.exist;
- expect(payload.tags[0].banner_frameworks).to.not.exist;
- expect(payload.tags[0].video_frameworks).to.not.exist;
-
- if (FEATURES.VIDEO) {
- // with video.frameworks but it is not an array
- const bidRequest_C = Object.assign({}, bidRequests[0], {
- params: {
- video: {
- frameworks: "'1', '2', '3', '6'"
- }
- }
- });
- request = spec.buildRequests([bidRequest_C]);
- payload = JSON.parse(request.data);
- expect(payload.iab_support).to.not.exist;
- expect(payload.tags[0].banner_frameworks).to.not.exist;
- expect(payload.tags[0].video_frameworks).to.not.exist;
- }
- });
- })
-
- describe('interpretResponse', function () {
- let bidderSettingsStorage;
-
- before(function () {
- bidderSettingsStorage = getGlobal().bidderSettings;
- });
-
- after(function () {
- getGlobal().bidderSettings = bidderSettingsStorage;
- });
-
- const response = {
- 'version': '3.0.0',
- 'tags': [
- {
- 'uuid': '3db3773286ee59',
- 'tag_id': 10433394,
- 'auction_id': '4534722592064951574',
- 'nobid': false,
- 'no_ad_url': 'https://lax1-ib.adnxs.com/no-ad',
- 'timeout_ms': 10000,
- 'ad_profile_id': 27079,
- 'ads': [
- {
- 'content_source': 'rtb',
- 'ad_type': 'banner',
- 'buyer_member_id': 958,
- 'creative_id': 29681110,
- 'media_type_id': 1,
- 'media_subtype_id': 1,
- 'cpm': 0.5,
- 'cpm_publisher_currency': 0.5,
- 'publisher_currency_code': '$',
- 'client_initiated_ad_counting': true,
- 'viewability': {
- 'config': ''
- },
- 'dsa': {
- 'behalf': 'test-behalf',
- 'paid': 'test-paid',
- 'transparency': [{
- 'domain': 'good-domain',
- 'params': [1, 2, 3]
- }],
- 'adrender': 1
- },
- 'rtb': {
- 'banner': {
- 'content': '',
- 'width': 300,
- 'height': 250
- },
- 'trackers': [
- {
- 'impression_urls': [
- 'https://lax1-ib.adnxs.com/impression',
- 'https://www.test.com/tracker'
- ],
- 'video_events': {}
- }
- ]
- }
- }
- ]
- }
- ]
- };
-
- it('should get correct bid response', function () {
- const expectedResponse = [
- {
- 'adId': '3a1f23123e',
- 'requestId': '3db3773286ee59',
- 'cpm': 0.5,
- 'creativeId': 29681110,
- 'dealId': undefined,
- 'width': 300,
- 'height': 250,
- 'ad': '',
- 'mediaType': 'banner',
- 'currency': 'USD',
- 'ttl': 300,
- 'netRevenue': true,
- 'adUnitCode': 'code',
- 'appnexus': {
- 'buyerMemberId': 958
- },
- 'meta': {
- 'dchain': {
- 'ver': '1.0',
- 'complete': 0,
- 'nodes': [{
- 'bsid': '958'
- }]
- },
- 'dsa': {
- 'behalf': 'test-behalf',
- 'paid': 'test-paid',
- 'transparency': [{
- 'domain': 'good-domain',
- 'params': [1, 2, 3]
- }],
- 'adrender': 1
- }
- }
- }
- ];
- const bidderRequest = {
- bids: [{
- bidId: '3db3773286ee59',
- adUnitCode: 'code'
- }]
- };
- const result = spec.interpretResponse({ body: response }, { bidderRequest });
- expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0]));
- });
-
- it('should reject 0 cpm bids', function () {
- const zeroCpmResponse = deepClone(response);
- zeroCpmResponse.tags[0].ads[0].cpm = 0;
-
- const bidderRequest = {
- bidderCode: 'appnexus'
- };
-
- const result = spec.interpretResponse({ body: zeroCpmResponse }, { bidderRequest });
- expect(result.length).to.equal(0);
- });
-
- it('should allow 0 cpm bids if allowZeroCpmBids setConfig is true', function () {
- getGlobal().bidderSettings = {
- appnexus: {
- allowZeroCpmBids: true
- }
- };
-
- const zeroCpmResponse = deepClone(response);
- zeroCpmResponse.tags[0].ads[0].cpm = 0;
-
- const bidderRequest = {
- bidderCode: 'appnexus',
- bids: [{
- bidId: '3db3773286ee59',
- adUnitCode: 'code'
- }]
- };
-
- const result = spec.interpretResponse({ body: zeroCpmResponse }, { bidderRequest });
- expect(result.length).to.equal(1);
- expect(result[0].cpm).to.equal(0);
- });
-
- it('handles nobid responses', function () {
- const response = {
- 'version': '0.0.1',
- 'tags': [{
- 'uuid': '84ab500420319d',
- 'tag_id': 5976557,
- 'auction_id': '297492697822162468',
- 'nobid': true
- }]
- };
- let bidderRequest;
-
- const result = spec.interpretResponse({ body: response }, { bidderRequest });
- expect(result.length).to.equal(0);
- });
-
- if (FEATURES.VIDEO) {
- it('handles outstream video responses', function () {
- const response = {
- 'tags': [{
- 'uuid': '84ab500420319d',
- 'ads': [{
- 'ad_type': 'video',
- 'cpm': 0.500000,
- 'notify_url': 'imptracker.com',
- 'rtb': {
- 'video': {
- 'content': ''
- }
- },
- 'javascriptTrackers': ''
- }]
- }]
- };
- const bidderRequest = {
- bids: [{
- bidId: '84ab500420319d',
- adUnitCode: 'code',
- mediaTypes: {
- video: {
- context: 'outstream'
- }
- }
- }]
- }
-
- const result = spec.interpretResponse({ body: response }, { bidderRequest });
- expect(result[0]).to.have.property('vastXml');
- expect(result[0]).to.have.property('vastImpUrl');
- expect(result[0]).to.have.property('mediaType', 'video');
- });
-
- it('handles instream video responses', function () {
- const response = {
- 'tags': [{
- 'uuid': '84ab500420319d',
- 'ads': [{
- 'ad_type': 'video',
- 'cpm': 0.500000,
- 'notify_url': 'imptracker.com',
- 'rtb': {
- 'video': {
- 'asset_url': 'https://sample.vastURL.com/here/vid'
- }
- },
- 'javascriptTrackers': ''
- }]
- }]
- };
- const bidderRequest = {
- bids: [{
- bidId: '84ab500420319d',
- adUnitCode: 'code',
- mediaTypes: {
- video: {
- context: 'instream'
- }
- }
- }]
- }
-
- const result = spec.interpretResponse({ body: response }, { bidderRequest });
- expect(result[0]).to.have.property('vastUrl');
- expect(result[0]).to.have.property('vastImpUrl');
- expect(result[0]).to.have.property('mediaType', 'video');
- });
-
- it('handles adpod responses', function () {
- const response = {
- 'tags': [{
- 'uuid': '84ab500420319d',
- 'ads': [{
- 'ad_type': 'video',
- 'brand_category_id': 10,
- 'cpm': 0.500000,
- 'notify_url': 'imptracker.com',
- 'rtb': {
- 'video': {
- 'asset_url': 'https://sample.vastURL.com/here/adpod',
- 'duration_ms': 30000,
- }
- },
- 'viewability': {
- 'config': ''
- }
- }]
- }]
- };
-
- const bidderRequest = {
- bids: [{
- bidId: '84ab500420319d',
- adUnitCode: 'code',
- mediaTypes: {
- video: {
- context: 'adpod'
- }
- }
- }]
- };
-
- const result = spec.interpretResponse({ body: response }, { bidderRequest });
- expect(result[0]).to.have.property('vastUrl');
- expect(result[0].video.context).to.equal('adpod');
- expect(result[0].video.durationSeconds).to.equal(30);
- });
- }
-
- if (FEATURES.NATIVE) {
- const BASE_NATIVE = {
- 'title': 'Native Creative',
- 'desc': 'Cool description great stuff',
- 'desc2': 'Additional body text',
- 'ctatext': 'Do it',
- 'sponsored': 'AppNexus',
- 'icon': {
- 'width': 0,
- 'height': 0,
- 'url': 'https://cdn.adnxs.com/icon.png'
- },
- 'main_img': {
- 'width': 2352,
- 'height': 1516,
- 'url': 'https://cdn.adnxs.com/img.png'
- },
- 'link': {
- 'url': 'https://www.appnexus.com',
- 'fallback_url': '',
- 'click_trackers': ['https://nym1-ib.adnxs.com/click']
- },
- 'impression_trackers': ['https://example.com'],
- 'rating': '5',
- 'displayurl': 'https://AppNexus.com/?url=display_url',
- 'likes': '38908320',
- 'downloads': '874983',
- 'price': '9.99',
- 'saleprice': 'FREE',
- 'phone': '1234567890',
- 'address': '28 W 23rd St, New York, NY 10010',
- 'privacy_link': 'https://appnexus.com/?url=privacy_url',
- 'javascriptTrackers': '',
- 'video': {
- 'content': ''
- }
- };
-
- it('handles native responses', function () {
- const response1 = deepClone(response);
- response1.tags[0].ads[0].ad_type = 'native';
- response1.tags[0].ads[0].rtb.native = BASE_NATIVE;
- const bidderRequest = {
- bids: [{
- bidId: '3db3773286ee59',
- adUnitCode: 'code'
- }]
- }
-
- const result = spec.interpretResponse({ body: response1 }, { bidderRequest });
- expect(result[0].native.title).to.equal('Native Creative');
- expect(result[0].native.body).to.equal('Cool description great stuff');
- expect(result[0].native.body2).to.equal('Additional body text');
- expect(result[0].native.cta).to.equal('Do it');
- expect(result[0].native.image.url).to.equal('https://cdn.adnxs.com/img.png');
- // Video is technically not a base Prebid native field, so it should be included as part of the ext
- // But it's also included here for backwards compatibility if people read the bid directly
- expect(result[0].native.video.content).to.equal('');
- });
-
- it('handles custom native fields as ext', function () {
- const response1 = deepClone(response);
- response1.tags[0].ads[0].ad_type = 'native';
- response1.tags[0].ads[0].rtb.native = {
- ...BASE_NATIVE,
- // 'video' is included in base native
- 'title1': 'Custom Title 1',
- 'title2': 'Custom Title 2',
- 'title3': 'Custom Title 3',
- 'title4': 'Custom Title 4',
- 'title5': 'Custom Title 5',
- // Not to be confused with Prebid's base native body & body2
- 'body1': 'Custom Body 1',
- 'body2': 'Custom Body 2',
- 'body3': 'Custom Body 3',
- 'body4': 'Custom Body 4',
- 'body5': 'Custom Body 5',
- 'image1': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/custom_image_1.jpg?[fullhash]',
- 'height': 627,
- 'width': 1200,
- },
- 'image2': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/custom_image_2.jpg?[fullhash]',
- 'height': 627,
- 'width': 1200,
- },
- 'image3': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/custom_image_3.jpg?[fullhash]',
- 'height': 627,
- 'width': 1200,
- },
- 'image4': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/custom_image_4.jpg?[fullhash]',
- 'height': 627,
- 'width': 1200,
- },
- 'image5': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/custom_image_5.jpg?[fullhash]',
- 'height': 627,
- 'width': 1200,
- },
- 'icon1': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'icon2': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'icon3': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'icon4': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'icon5': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'socialicon1': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'socialicon2': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'socialicon3': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'socialicon4': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'socialicon5': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'socialurl1': 'https://www.xandr.com/platform/monetize/#socialUrl1',
- 'socialurl2': 'https://www.xandr.com/platform/monetize/#socialUrl2',
- 'socialurl3': 'https://www.xandr.com/platform/monetize/#socialUrl3',
- 'socialurl4': 'https://www.xandr.com/platform/monetize/#socialUrl4',
- 'socialurl5': 'https://www.xandr.com/platform/monetize/#socialUrl5',
- 'displayurl1': 'https://www.xandr.com/platform/monetize/#displayUrl1',
- 'displayurl2': 'https://www.xandr.com/platform/monetize/#displayUrl2',
- 'displayurl3': 'https://www.xandr.com/platform/monetize/#displayUrl3',
- 'displayurl4': 'https://www.xandr.com/platform/monetize/#displayUrl4',
- 'displayurl5': 'https://www.xandr.com/platform/monetize/#displayUrl5',
- 'ctatext1': 'Custom CTA 1',
- 'ctatext2': 'Custom CTA 2',
- 'ctatext3': 'Custom CTA 3',
- 'ctatext4': 'Custom CTA 4',
- 'ctatext5': 'Custom CTA 5',
- };
- const bidderRequest = {
- bids: [{
- bidId: '3db3773286ee59',
- adUnitCode: 'code'
- }]
- }
-
- const result = spec.interpretResponse({ body: response1 }, { bidderRequest });
- expect(result[0].native.ext).to.deep.equal({
- 'video': {
- 'content': ''
- },
- 'customTitle1': 'Custom Title 1',
- 'customTitle2': 'Custom Title 2',
- 'customTitle3': 'Custom Title 3',
- 'customTitle4': 'Custom Title 4',
- 'customTitle5': 'Custom Title 5',
- 'customBody1': 'Custom Body 1',
- 'customBody2': 'Custom Body 2',
- 'customBody3': 'Custom Body 3',
- 'customBody4': 'Custom Body 4',
- 'customBody5': 'Custom Body 5',
- 'customImage1': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/custom_image_1.jpg?[fullhash]',
- 'height': 627,
- 'width': 1200,
- },
- 'customImage2': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/custom_image_2.jpg?[fullhash]',
- 'height': 627,
- 'width': 1200,
- },
- 'customImage3': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/custom_image_3.jpg?[fullhash]',
- 'height': 627,
- 'width': 1200,
- },
- 'customImage4': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/custom_image_4.jpg?[fullhash]',
- 'height': 627,
- 'width': 1200,
- },
- 'customImage5': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/custom_image_5.jpg?[fullhash]',
- 'height': 627,
- 'width': 1200,
- },
- 'customIcon1': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'customIcon2': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'customIcon3': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'customIcon4': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'customIcon5': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'customSocialIcon1': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'customSocialIcon2': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'customSocialIcon3': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'customSocialIcon4': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'customSocialIcon5': {
- 'url': 'https://monetize.xandr.com/creative-ui/assets/logo.jpg?[fullhash]',
- 'height': 128,
- 'width': 128,
- },
- 'customSocialUrl1': 'https://www.xandr.com/platform/monetize/#socialUrl1',
- 'customSocialUrl2': 'https://www.xandr.com/platform/monetize/#socialUrl2',
- 'customSocialUrl3': 'https://www.xandr.com/platform/monetize/#socialUrl3',
- 'customSocialUrl4': 'https://www.xandr.com/platform/monetize/#socialUrl4',
- 'customSocialUrl5': 'https://www.xandr.com/platform/monetize/#socialUrl5',
- 'customDisplayUrl1': 'https://www.xandr.com/platform/monetize/#displayUrl1',
- 'customDisplayUrl2': 'https://www.xandr.com/platform/monetize/#displayUrl2',
- 'customDisplayUrl3': 'https://www.xandr.com/platform/monetize/#displayUrl3',
- 'customDisplayUrl4': 'https://www.xandr.com/platform/monetize/#displayUrl4',
- 'customDisplayUrl5': 'https://www.xandr.com/platform/monetize/#displayUrl5',
- 'customCta1': 'Custom CTA 1',
- 'customCta2': 'Custom CTA 2',
- 'customCta3': 'Custom CTA 3',
- 'customCta4': 'Custom CTA 4',
- 'customCta5': 'Custom CTA 5',
- });
- });
- }
-
- if (FEATURES.VIDEO) {
- it('supports configuring outstream renderers', function () {
- const outstreamResponse = deepClone(response);
- outstreamResponse.tags[0].ads[0].rtb.video = {};
- outstreamResponse.tags[0].ads[0].renderer_url = 'renderer.js';
-
- const bidderRequest = {
- bids: [{
- bidId: '3db3773286ee59',
- renderer: {
- options: {
- adText: 'configured'
- }
- },
- mediaTypes: {
- video: {
- context: 'outstream'
- }
- }
- }]
- };
-
- const result = spec.interpretResponse({ body: outstreamResponse }, { bidderRequest });
- expect(result[0].renderer.config).to.deep.equal(
- bidderRequest.bids[0].renderer.options
- );
- });
-
- it('should add deal_priority and deal_code', function () {
- const responseWithDeal = deepClone(response);
- responseWithDeal.tags[0].ads[0].ad_type = 'video';
- responseWithDeal.tags[0].ads[0].deal_priority = 5;
- responseWithDeal.tags[0].ads[0].deal_code = '123';
- responseWithDeal.tags[0].ads[0].rtb.video = {
- duration_ms: 1500,
- player_width: 640,
- player_height: 340,
- };
-
- const bidderRequest = {
- bids: [{
- bidId: '3db3773286ee59',
- adUnitCode: 'code',
- mediaTypes: {
- video: {
- context: 'adpod'
- }
- }
- }]
- }
- const result = spec.interpretResponse({ body: responseWithDeal }, { bidderRequest });
- expect(Object.keys(result[0].appnexus)).to.include.members(['buyerMemberId', 'dealPriority', 'dealCode']);
- expect(result[0].video.dealTier).to.equal(5);
- });
- }
-
- it('should add advertiser id', function () {
- const responseAdvertiserId = deepClone(response);
- responseAdvertiserId.tags[0].ads[0].advertiser_id = '123';
-
- const bidderRequest = {
- bids: [{
- bidId: '3db3773286ee59',
- adUnitCode: 'code'
- }]
- }
- const result = spec.interpretResponse({ body: responseAdvertiserId }, { bidderRequest });
- expect(Object.keys(result[0].meta)).to.include.members(['advertiserId']);
- });
-
- it('should add brand id', function () {
- const responseBrandId = deepClone(response);
- responseBrandId.tags[0].ads[0].brand_id = 123;
-
- const bidderRequest = {
- bids: [{
- bidId: '3db3773286ee59',
- adUnitCode: 'code'
- }]
- }
- const result = spec.interpretResponse({ body: responseBrandId }, { bidderRequest });
- expect(Object.keys(result[0].meta)).to.include.members(['brandId']);
- });
-
- it('should add advertiserDomains', function () {
- const responseAdvertiserId = deepClone(response);
- responseAdvertiserId.tags[0].ads[0].adomain = '123';
-
- const bidderRequest = {
- bids: [{
- bidId: '3db3773286ee59',
- adUnitCode: 'code'
- }]
- }
- const result = spec.interpretResponse({ body: responseAdvertiserId }, { bidderRequest });
- expect(Object.keys(result[0].meta)).to.include.members(['advertiserDomains']);
- expect(result[0].meta.advertiserDomains).to.deep.equal(['123']);
- });
- });
-
- describe('getUserSyncs', function() {
- let syncOptions, gdprConsent;
-
- beforeEach(() => {
- gdprConsent = {
- gdprApplies: true,
- consentString: 'CPJl4C8PJl4C8OoAAAENAwCMAP_AAH_AAAAAAPgAAAAIAPgAAAAIAAA.IGLtV_T9fb2vj-_Z99_tkeYwf95y3p-wzhheMs-8NyZeH_B4Wv2MyvBX4JiQKGRgksjLBAQdtHGlcTQgBwIlViTLMYk2MjzNKJrJEilsbO2dYGD9Pn8HT3ZCY70-vv__7v3ff_3g',
- vendorData: {
- purpose: {
- consents: {
- '1': true
- }
- }
- }
- }
- });
-
- describe('pixel', function () {
- beforeEach(() => {
- syncOptions = { pixelEnabled: true };
- });
-
- it('pixelEnabled on', function () {
- const result = spec.getUserSyncs(syncOptions, [], gdprConsent, null);
- expect(result).to.have.length(1);
- expect(result[0].type).to.equal('image');
- expect(result[0].url).to.equal('https://px.ads.linkedin.com/setuid?partner=appNexus');
- });
-
- it('pixelEnabled off', function () {
- syncOptions.pixelEnabled = false;
- const result = spec.getUserSyncs(syncOptions, [], gdprConsent, null);
- expect(result).to.be.undefined;
- });
- });
-
- describe('iframe', function () {
- beforeEach(() => {
- syncOptions = { iframeEnabled: true };
- });
-
- it('iframeEnabled on with gdpr purpose 1 on', function () {
- const result = spec.getUserSyncs(syncOptions, [], gdprConsent, null);
- expect(result).to.have.length(1);
- expect(result[0].type).to.equal('iframe');
- expect(result[0].url).to.equal('https://acdn.adnxs.com/dmp/async_usersync.html');
- });
-
- it('iframeEnabled on with gdpr purpose1 off', function () {
- gdprConsent.vendorData.purpose.consents['1'] = false
-
- const result = spec.getUserSyncs(syncOptions, [], gdprConsent, null);
- expect(result).to.be.undefined;
- });
-
- it('iframeEnabled on without gdpr', function () {
- const result = spec.getUserSyncs(syncOptions, [], null, null);
- expect(result).to.have.length(1);
- expect(result[0].type).to.equal('iframe');
- expect(result[0].url).to.equal('https://acdn.adnxs.com/dmp/async_usersync.html');
- });
-
- it('iframeEnabled off', function () {
- syncOptions.iframeEnabled = false;
- const result = spec.getUserSyncs(syncOptions, [], gdprConsent, null);
- expect(result).to.be.undefined;
- });
- });
- });
-});
diff --git a/test/spec/modules/appushBidAdapter_spec.js b/test/spec/modules/appushBidAdapter_spec.js
deleted file mode 100644
index b6c535c46..000000000
--- a/test/spec/modules/appushBidAdapter_spec.js
+++ /dev/null
@@ -1,383 +0,0 @@
-import { expect } from 'chai';
-import { spec } from '../../../modules/appushBidAdapter.js';
-import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js';
-import { getUniqueIdentifierStr } from '../../../src/utils.js';
-
-const bidder = 'appush'
-
-describe('AppushBidAdapter', function () {
- const bids = [
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
- placementId: 'testBanner',
- }
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [VIDEO]: {
- playerSize: [[300, 300]],
- minduration: 5,
- maxduration: 60
- }
- },
- params: {
- placementId: 'testVideo',
- }
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [NATIVE]: {
- native: {
- title: {
- required: true
- },
- body: {
- required: true
- },
- icon: {
- required: true,
- size: [64, 64]
- }
- }
- }
- },
- params: {
- placementId: 'testNative',
- }
- }
- ];
-
- const invalidBid = {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
-
- }
- }
-
- const bidderRequest = {
- uspConsent: '1---',
- gdprConsent: {
- consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw',
- vendorData: {}
- },
- refererInfo: {
- referer: 'https://test.com'
- },
- timeout: 500
- };
-
- describe('isBidRequestValid', function () {
- it('Should return true if there are bidId, params and key parameters present', function () {
- expect(spec.isBidRequestValid(bids[0])).to.be.true;
- });
- it('Should return false if at least one of parameters is not present', function () {
- expect(spec.isBidRequestValid(invalidBid)).to.be.false;
- });
- });
-
- describe('buildRequests', function () {
- let serverRequest = spec.buildRequests(bids, bidderRequest);
-
- it('Creates a ServerRequest object with method, URL and data', function () {
- expect(serverRequest).to.exist;
- expect(serverRequest.method).to.exist;
- expect(serverRequest.url).to.exist;
- expect(serverRequest.data).to.exist;
- });
-
- it('Returns POST method', function () {
- expect(serverRequest.method).to.equal('POST');
- });
-
- it('Returns valid URL', function () {
- expect(serverRequest.url).to.equal('https://hb.appush.com/pbjs');
- });
-
- it('Returns general data valid', function () {
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.include.all.keys(
- 'deviceWidth',
- 'deviceHeight',
- 'language',
- 'secure',
- 'host',
- 'page',
- 'placements',
- 'coppa',
- 'ccpa',
- 'gdpr',
- 'tmax',
- 'bcat',
- 'badv',
- 'bapp',
- 'battr'
- );
- expect(data.deviceWidth).to.be.a('number');
- expect(data.deviceHeight).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');
- expect(data.page).to.be.a('string');
- expect(data.coppa).to.be.a('number');
- expect(data.gdpr).to.be.a('object');
- expect(data.ccpa).to.be.a('string');
- expect(data.tmax).to.be.a('number');
- expect(data.placements).to.have.lengthOf(3);
- });
-
- it('Returns valid placements', function () {
- const { placements } = serverRequest.data;
- for (let i = 0, len = placements.length; i < len; i++) {
- const placement = placements[i];
- expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']);
- expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]);
- expect(placement.bidId).to.be.a('string');
- expect(placement.schain).to.be.an('object');
- expect(placement.bidfloor).to.exist.and.to.equal(0);
- expect(placement.type).to.exist.and.to.equal('publisher');
-
- if (placement.adFormat === BANNER) {
- expect(placement.sizes).to.be.an('array');
- }
- switch (placement.adFormat) {
- case BANNER:
- expect(placement.sizes).to.be.an('array');
- break;
- case VIDEO:
- expect(placement.playerSize).to.be.an('array');
- expect(placement.minduration).to.be.an('number');
- expect(placement.maxduration).to.be.an('number');
- break;
- case NATIVE:
- expect(placement.native).to.be.an('object');
- break;
- }
- }
- });
-
- it('Returns data with gdprConsent and without uspConsent', function () {
- delete bidderRequest.uspConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.gdpr).to.exist;
- expect(data.gdpr).to.be.a('object');
- expect(data.gdpr).to.have.property('consentString');
- expect(data.gdpr).to.not.have.property('vendorData');
- expect(data.gdpr.consentString).to.equal(bidderRequest.gdprConsent.consentString);
- expect(data.ccpa).to.not.exist;
- delete bidderRequest.gdprConsent;
- });
-
- it('Returns data with uspConsent and without gdprConsent', function () {
- bidderRequest.uspConsent = '1---';
- delete bidderRequest.gdprConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.ccpa).to.exist;
- expect(data.ccpa).to.be.a('string');
- expect(data.ccpa).to.equal(bidderRequest.uspConsent);
- expect(data.gdpr).to.not.exist;
- });
-
- it('Returns empty data if no valid requests are passed', function () {
- serverRequest = spec.buildRequests([], bidderRequest);
- const data = serverRequest.data;
- expect(data.placements).to.be.an('array').that.is.empty;
- });
- });
-
- describe('interpretResponse', function () {
- it('Should interpret banner response', function () {
- const banner = {
- body: [{
- mediaType: 'banner',
- width: 300,
- height: 250,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const bannerResponses = spec.interpretResponse(banner);
- expect(bannerResponses).to.be.an('array').that.is.not.empty;
- const dataItem = bannerResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal(banner.body[0].requestId);
- expect(dataItem.cpm).to.equal(banner.body[0].cpm);
- expect(dataItem.width).to.equal(banner.body[0].width);
- expect(dataItem.height).to.equal(banner.body[0].height);
- expect(dataItem.ad).to.equal(banner.body[0].ad);
- expect(dataItem.ttl).to.equal(banner.body[0].ttl);
- expect(dataItem.creativeId).to.equal(banner.body[0].creativeId);
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal(banner.body[0].currency);
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should interpret video response', function () {
- const video = {
- body: [{
- vastUrl: 'test.com',
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const videoResponses = spec.interpretResponse(video);
- expect(videoResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = videoResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.5);
- expect(dataItem.vastUrl).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should interpret native response', function () {
- const native = {
- body: [{
- mediaType: 'native',
- native: {
- clickUrl: 'test.com',
- title: 'Test',
- image: 'test.com',
- impressionTrackers: ['test.com'],
- },
- ttl: 120,
- cpm: 0.4,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const nativeResponses = spec.interpretResponse(native);
- expect(nativeResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = nativeResponses[0];
- expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta');
- expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image')
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.4);
- expect(dataItem.native.clickUrl).to.equal('test.com');
- expect(dataItem.native.title).to.equal('Test');
- expect(dataItem.native.image).to.equal('test.com');
- expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty;
- expect(dataItem.native.impressionTrackers[0]).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should return an empty array if invalid banner response is passed', function () {
- const invBanner = {
- body: [{
- width: 300,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
-
- const serverResponses = spec.interpretResponse(invBanner);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid video response is passed', function () {
- const invVideo = {
- body: [{
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invVideo);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid native response is passed', function () {
- const invNative = {
- body: [{
- mediaType: 'native',
- clickUrl: 'test.com',
- title: 'Test',
- impressionTrackers: ['test.com'],
- ttl: 120,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- }]
- };
- const serverResponses = spec.interpretResponse(invNative);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid response is passed', function () {
- const invalid = {
- body: [{
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invalid);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- });
-});
diff --git a/test/spec/modules/apstreamBidAdapter_spec.js b/test/spec/modules/apstreamBidAdapter_spec.js
deleted file mode 100644
index de13e45b6..000000000
--- a/test/spec/modules/apstreamBidAdapter_spec.js
+++ /dev/null
@@ -1,327 +0,0 @@
-// jshint esversion: 6, es3: false, node: true
-import {assert, expect} from 'chai';
-import {config} from 'src/config.js';
-import {spec} from 'modules/apstreamBidAdapter.js';
-import * as utils from 'src/utils.js';
-import {getGlobal} from '../../../src/prebidGlobal.js';
-
-const validBidRequests = [{
- bidId: 'bidId',
- adUnitCode: '/id/site1/header-ad',
- sizes: [[980, 120], [980, 180]],
- mediaTypes: {
- banner: {
- sizes: [[980, 120], [980, 180]]
- }
- },
- params: {
- publisherId: '1234'
- }
-}];
-
-describe('AP Stream adapter', function() {
- describe('isBidRequestValid', function() {
- const bid = {
- bidder: 'apstream',
- mediaTypes: {
- banner: {
- sizes: [300, 250]
- }
- },
- params: {
- }
- };
-
- let mockConfig;
- beforeEach(function () {
- getGlobal().bidderSettings = {
- apstream: {
- storageAllowed: true
- }
- };
- mockConfig = {
- apstream: {
- publisherId: '4321'
- }
- };
- sinon.stub(config, 'getConfig').callsFake((key) => {
- return utils.deepAccess(mockConfig, key);
- });
- });
-
- afterEach(function () {
- getGlobal().bidderSettings = {};
- config.getConfig.restore();
- });
-
- it('should return true when publisherId is configured and one media type', function() {
- bid.params.publisherId = '1234';
- assert(spec.isBidRequestValid(bid))
- });
-
- it('should return false when publisherId is configured and two media types', function() {
- bid.mediaTypes.video = {sizes: [300, 250]};
- assert.isFalse(spec.isBidRequestValid(bid))
- });
-
- it('should return true when publisherId is configured via config', function() {
- delete bid.mediaTypes.video;
- delete bid.params.publisherId;
- assert.isTrue(spec.isBidRequestValid(bid))
- });
- });
-
- describe('buildRequests', function() {
- it('should send request with correct structure', function() {
- const request = spec.buildRequests(validBidRequests, { })[0];
-
- assert.equal(request.method, 'GET');
- assert.deepEqual(request.options, {withCredentials: false});
- assert.ok(request.data);
- });
-
- it('should send request with different endpoints', function() {
- const validTwoBidRequests = [
- ...validBidRequests,
- ...[{
- bidId: 'bidId2',
- adUnitCode: '/id/site1/header-ad',
- sizes: [[980, 980], [980, 900]],
- mediaTypes: {
- banner: {
- sizes: [[980, 980], [980, 900]]
- }
- },
- params: {
- publisherId: '1234',
- endpoint: 'site2.com'
- }
- }]
- ];
-
- const request = spec.buildRequests(validTwoBidRequests, {});
- assert.isArray(request);
- assert.lengthOf(request, 2);
- assert.equal(request[1].data.bids, 'bidId2:t=b,s=980x980_980x900,c=/id/site1/header-ad');
- });
-
- it('should send request with adUnit code', function() {
- const adunitCodeValidBidRequests = [
- {
- ...validBidRequests[0],
- ...{
- params: {
- code: 'Site1_Leaderboard'
- }
- }
- }
- ];
-
- const request = spec.buildRequests(adunitCodeValidBidRequests, { })[0];
- assert.equal(request.data.bids, 'bidId:t=b,s=980x120_980x180,c=Site1_Leaderboard');
- });
-
- it('should send request with adUnit id', function() {
- const adunitIdValidBidRequests = [
- {
- ...validBidRequests[0],
- ...{
- params: {
- adunitId: '12345'
- }
- }
- }
- ];
-
- const request = spec.buildRequests(adunitIdValidBidRequests, { })[0];
- assert.equal(request.data.bids, 'bidId:t=b,s=980x120_980x180,u=12345');
- });
-
- it('should send request with different media type', function() {
- const types = {
- 'audio': 'a',
- 'banner': 'b',
- 'native': 'n',
- 'video': 'v'
- }
- Object.keys(types).forEach(key => {
- const adunitIdValidBidRequests = [
- {
- ...validBidRequests[0],
- ...{
- mediaTypes: {
- [key]: {
- sizes: [300, 250]
- }
- }
- }
- }
- ];
-
- const request = spec.buildRequests(adunitIdValidBidRequests, { })[0];
- assert.equal(request.data.bids, `bidId:t=${types[key]},s=980x120_980x180,c=/id/site1/header-ad`);
- })
- });
-
- describe('gdpr', function() {
- let mockConfig;
-
- beforeEach(function () {
- mockConfig = {
- consentManagement: {
- cmpApi: 'iab'
- }
- };
- sinon.stub(config, 'getConfig').callsFake((key) => {
- return utils.deepAccess(mockConfig, key);
- });
- });
-
- afterEach(function () {
- config.getConfig.restore();
- });
-
- it('should send GDPR Consent data', function() {
- const bidderRequest = {
- gdprConsent: {
- gdprApplies: true,
- consentString: 'consentDataString',
- vendorData: {
- vendorConsents: {
- '394': true
- }
- }
- }
- };
-
- const request = spec.buildRequests(validBidRequests, bidderRequest)[0].data;
- assert.equal(request.iab_consent, bidderRequest.gdprConsent.consentString);
- });
- });
-
- describe('dsu', function() {
- it('should pass DSU from local storage if set', function() {
- const bidderRequest = {
- gdprConsent: {
- gdprApplies: true,
- consentString: 'consentDataString',
- vendorData: {
- vendorConsents: {
- '394': true
- }
- }
- }
- };
-
- const request = spec.buildRequests(validBidRequests, bidderRequest)[0].data;
- assert.isNotEmpty(request.dsu);
- });
- });
- });
-
- describe('dsu config', function() {
- let mockConfig;
- beforeEach(function () {
- mockConfig = {
- apstream: {
- noDsu: true
- }
- };
- sinon.stub(config, 'getConfig').callsFake((key) => {
- return utils.deepAccess(mockConfig, key);
- });
- });
-
- afterEach(function () {
- config.getConfig.restore();
- });
-
- it('should not send DSU if it is disabled in config', function() {
- const request = spec.buildRequests(validBidRequests, { })[0];
-
- assert.equal(request.data.dsu, '');
- });
- });
-
- describe('interpretResponse', function () {
- it('should return empty array if no body in response', function () {
- const serverResponse = {};
- const bidRequest = {};
-
- assert.isEmpty(spec.interpretResponse(serverResponse, bidRequest));
- });
-
- it('should map server response', function () {
- const serverResponse = {
- body: [
- {
- bidId: 123,
- bidDetails: {
- cpm: 1.23,
- width: 980,
- height: 300,
- currency: 'DKK',
- netRevenue: 'true',
- creativeId: '1234',
- dealId: '99008',
- ad: '
Buy our something!
',
- ttl: 360
- }
- }
- ]
- };
- const bidRequest = {};
-
- const response = spec.interpretResponse(serverResponse, bidRequest);
-
- const expected = {
- requestId: 123,
- cpm: 1.23,
- width: 980,
- height: 300,
- currency: 'DKK',
- creativeId: '1234',
- netRevenue: 'true',
- dealId: '99008',
- ad: '
Buy our something!
',
- ttl: 360
- };
-
- assert.deepEqual(response[0], expected);
- });
-
- it('should add pixels to ad', function () {
- const serverResponse = {
- body: [
- {
- bidId: 123,
- bidDetails: {
- cpm: 1.23,
- width: 980,
- height: 300,
- currency: 'DKK',
- creativeId: '1234',
- netRevenue: 'true',
- dealId: '99008',
- ad: '
Buy our something!
',
- ttl: 360,
- noticeUrls: [
- 'site1',
- 'site2'
- ],
- impressionScripts: [
- 'url_to_script'
- ]
- }
- }
- ]
- };
- const bidRequest = {};
-
- const response = spec.interpretResponse(serverResponse, bidRequest);
-
- assert.match(response[0].ad, /site1/);
- assert.match(response[0].ad, /site2/);
- });
- });
-});
diff --git a/test/spec/modules/arcspanRtdProvider_spec.js b/test/spec/modules/arcspanRtdProvider_spec.js
deleted file mode 100644
index 9c2b35985..000000000
--- a/test/spec/modules/arcspanRtdProvider_spec.js
+++ /dev/null
@@ -1,187 +0,0 @@
-import { arcspanSubmodule } from 'modules/arcspanRtdProvider.js';
-import { expect } from 'chai';
-import { loadExternalScriptStub } from 'test/mocks/adloaderStub.js';
-
-describe('arcspanRtdProvider', function () {
- describe('init', function () {
- afterEach(function () {
- window.arcobj1 = undefined;
- window.arcobj2 = undefined;
- });
-
- it('successfully initializes with a valid silo ID', function () {
- expect(arcspanSubmodule.init(getGoodConfig())).to.equal(true);
- expect(loadExternalScriptStub.called).to.be.ok;
- expect(loadExternalScriptStub.args[0][0]).to.deep.equal('https://silo13.p7cloud.net/as.js');
- loadExternalScriptStub.resetHistory();
- });
-
- it('fails to initialize with a missing silo ID', function () {
- expect(arcspanSubmodule.init(getBadConfig())).to.equal(false);
- expect(loadExternalScriptStub.called).to.be.not.ok;
- loadExternalScriptStub.resetHistory();
- });
-
- it('drops localhost script for test silo', function () {
- expect(arcspanSubmodule.init(getTestConfig())).to.equal(true);
- expect(loadExternalScriptStub.called).to.be.ok;
- expect(loadExternalScriptStub.args[0][0]).to.deep.equal('https://localhost:8080/as.js');
- loadExternalScriptStub.resetHistory();
- });
- });
-
- describe('alterBidRequests', function () {
- afterEach(function () {
- window.arcobj1 = undefined;
- window.arcobj2 = undefined;
- });
-
- it('alters the bid request 1', function () {
- setIAB({
- raw: {
- images: [
- 'Religion & Spirituality',
- 'Medical Health>Substance Abuse',
- 'Religion & Spirituality>Astrology',
- 'Medical Health',
- 'Events & Attractions',
- ],
- },
- codes: {
- images: ['IAB23-10', 'IAB7', 'IAB7-42', 'IAB15-1'],
- },
- newcodes: {
- images: ['150', '453', '311', '456', '286'],
- },
- });
-
- var reqBidsConfigObj = {};
- reqBidsConfigObj.ortb2Fragments = {};
- reqBidsConfigObj.ortb2Fragments.global = {};
- arcspanSubmodule.getBidRequestData(reqBidsConfigObj, function () {
- expect(reqBidsConfigObj.ortb2Fragments.global.site.name).to.equal(
- 'arcspan'
- );
- expect(reqBidsConfigObj.ortb2Fragments.global.site.keywords).to.equal(
- 'Religion & Spirituality,Medical Health>Substance Abuse,Religion & Spirituality>Astrology,Medical Health,Events & Attractions'
- );
- expect(reqBidsConfigObj.ortb2Fragments.global.site.content.data[0].ext.segtax).to.equal(6);
- expect(reqBidsConfigObj.ortb2Fragments.global.site.cat).to.eql([
- 'IAB23_10',
- 'IAB7',
- 'IAB7_42',
- 'IAB15_1',
- ]);
- expect(reqBidsConfigObj.ortb2Fragments.global.site.sectioncat).to.eql([
- 'IAB23_10',
- 'IAB7',
- 'IAB7_42',
- 'IAB15_1'
- ]);
- expect(reqBidsConfigObj.ortb2Fragments.global.site.pagecat).to.eql([
- 'IAB23_10',
- 'IAB7',
- 'IAB7_42',
- 'IAB15_1',
- ]);
- expect(reqBidsConfigObj.ortb2Fragments.global.site.content.data[0].segment).to.eql([
- { id: '150' },
- { id: '453' },
- { id: '311' },
- { id: '456' },
- { id: '286' }
- ]);
- });
- });
-
- it('alters the bid request 2', function () {
- setIAB({
- raw: { text: ['Sports', 'Sports>Soccer'] },
- codes: { text: ['IAB17', 'IAB17-44'] },
- newcodes: { text: ['483', '533'] },
- });
-
- var reqBidsConfigObj = {};
- reqBidsConfigObj.ortb2Fragments = {};
- reqBidsConfigObj.ortb2Fragments.global = {};
- arcspanSubmodule.getBidRequestData(reqBidsConfigObj, function () {
- expect(reqBidsConfigObj.ortb2Fragments.global.site.name).to.equal(
- 'arcspan'
- );
- expect(reqBidsConfigObj.ortb2Fragments.global.site.keywords).to.equal(
- 'Sports,Sports>Soccer'
- );
- expect(reqBidsConfigObj.ortb2Fragments.global.site.content.data[0].ext.segtax).to.equal(6);
- expect(reqBidsConfigObj.ortb2Fragments.global.site.cat).to.eql([
- 'IAB17',
- 'IAB17_44',
- ]);
- expect(reqBidsConfigObj.ortb2Fragments.global.site.sectioncat).to.eql([
- 'IAB17',
- 'IAB17_44'
- ]);
- expect(reqBidsConfigObj.ortb2Fragments.global.site.pagecat).to.eql([
- 'IAB17',
- 'IAB17_44',
- ]);
- expect(reqBidsConfigObj.ortb2Fragments.global.site.content.data[0].segment).to.eql([
- { id: '483' },
- { id: '533' }
- ]);
- });
- });
- });
-});
-
-function getGoodConfig() {
- return {
- name: 'arcspan',
- waitForIt: true,
- params: {
- silo: 13,
- },
- };
-}
-
-function getBadConfig() {
- return {
- name: 'arcspan',
- waitForIt: true,
- params: {
- notasilo: 1,
- },
- };
-}
-
-function getTestConfig() {
- return {
- name: 'arcspan',
- waitForIt: true,
- params: {
- silo: 'test',
- },
- };
-}
-
-function setIAB(vjson) {
- window.arcobj2 = {};
- window.arcobj2.cat = 0;
- if (typeof vjson.codes !== 'undefined') {
- window.arcobj2.cat = 1;
- if (typeof vjson.codes.images !== 'undefined') {
- vjson.codes.images.forEach(function f(e, i) {
- vjson.codes.images[i] = e.replace('-', '_');
- });
- }
- if (typeof vjson.codes.text !== 'undefined') {
- vjson.codes.text.forEach(function f(e, i) {
- vjson.codes.text[i] = e.replace('-', '_');
- });
- }
- window.arcobj2.sampled = 1;
- window.arcobj1 = {};
- window.arcobj1.page_iab_codes = vjson.codes;
- window.arcobj1.page_iab = vjson.raw;
- window.arcobj1.page_iab_newcodes = vjson.newcodes;
- }
-}
diff --git a/test/spec/modules/asealBidAdapter_spec.js b/test/spec/modules/asealBidAdapter_spec.js
deleted file mode 100644
index 07e8f30e1..000000000
--- a/test/spec/modules/asealBidAdapter_spec.js
+++ /dev/null
@@ -1,212 +0,0 @@
-import { expect } from 'chai';
-import {
- spec,
- BIDDER_CODE,
- API_ENDPOINT,
- HEADER_AOTTER_VERSION,
- WEB_SESSION_ID_KEY, storage
-} from 'modules/asealBidAdapter.js';
-import { getRefererInfo } from 'src/refererDetection.js';
-import { newBidder } from 'src/adapters/bidderFactory.js';
-import { config } from 'src/config.js';
-import * as utils from 'src/utils.js';
-
-const TEST_CLIENT_ID = 'TEST_CLIENT_ID';
-const TEST_WEB_SESSION_ID = 'TEST_WEB_SESSION_ID';
-
-describe('asealBidAdapter', () => {
- const adapter = newBidder(spec);
-
- let localStorageIsEnabledStub;
- let getDataFromLocalStorageStub;
- let sandbox;
- let w;
-
- beforeEach((done) => {
- localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled');
- getDataFromLocalStorageStub = sinon.stub(
- storage,
- 'getDataFromLocalStorage'
- );
-
- w = {
- document: {
- title: 'Aseal',
- referrer: 'https://aseal.in/',
- href: 'https://aseal.in/',
- },
- location: {
- href: 'https://aseal.in/',
- },
- };
-
- sandbox = sinon.createSandbox();
- sandbox.stub(utils, 'getWindowTop').returns(w);
- sandbox.stub(utils, 'getWindowSelf').returns(w);
- done();
- });
-
- afterEach(() => {
- localStorageIsEnabledStub.restore();
- getDataFromLocalStorageStub.restore();
- sandbox.restore();
- config.resetConfig();
- });
-
- describe('inherited functions', () => {
- it('exists and is a function', () => {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('isBidRequestValid', () => {
- const bid = {
- bidder: 'aseal',
- params: {
- placeUid: '123',
- },
- };
-
- it('should return true when required params found', () => {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should return false when required param placeUid is not passed', () => {
- bid.params = {
- placeUid: '',
- };
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return false when required param placeUid is wrong type', () => {
- bid.params = {
- placeUid: null,
- };
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return false when required params are not passed', () => {
- const invalidBid = Object.assign({}, bid);
- delete invalidBid.params;
- invalidBid.params = {};
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
- });
-
- describe('buildRequests', () => {
- it('should return an empty array when there are no bid requests', () => {
- const bidRequests = [];
- const request = spec.buildRequests(bidRequests);
-
- expect(request).to.be.an('array').that.is.empty;
- });
-
- it('should send `x-aotter-clientid` header as empty string when user not set config `clientId`', () => {
- const bidRequests = [
- {
- bidder: BIDDER_CODE,
- params: {
- placeUid: '123',
- },
- },
- ];
-
- const bidderRequest = {};
- const request = spec.buildRequests(bidRequests, bidderRequest)[0];
-
- expect(request.options.customHeaders['x-aotter-clientid']).equal('');
- });
-
- it('should send bid requests to ENDPOINT via POST', () => {
- const bidRequests = [
- {
- bidder: BIDDER_CODE,
- params: {
- placeUid: '123',
- },
- },
- ];
-
- const bidderRequest = {
- refererInfo: getRefererInfo(),
- };
-
- config.setConfig({
- aseal: {
- clientId: TEST_CLIENT_ID,
- },
- });
-
- localStorageIsEnabledStub.returns(true);
- getDataFromLocalStorageStub
- .withArgs(WEB_SESSION_ID_KEY)
- .returns(TEST_WEB_SESSION_ID);
-
- const request = spec.buildRequests(bidRequests, bidderRequest)[0];
-
- utils.getWindowTop.restore();
- utils.getWindowSelf.restore();
-
- sandbox.stub(utils, 'getWindowTop').returns(w);
- sandbox.stub(utils, 'getWindowSelf').returns(w);
-
- const payload = {
- meta: {
- dr: w.document.referrer,
- drs: w.document.referrer,
- drt: w.document.referrer,
- dt: w.document.title,
- dl: w.location.href,
- },
- };
-
- expect(request.url).to.equal(API_ENDPOINT);
- expect(request.method).to.equal('POST');
- expect(request.options).deep.equal({
- contentType: 'application/json',
- withCredentials: true,
- customHeaders: {
- 'x-aotter-clientid': TEST_CLIENT_ID,
- 'x-aotter-version': HEADER_AOTTER_VERSION,
- },
- });
- expect(request.data.bids).deep.equal(bidRequests);
- expect(request.data.payload).deep.equal(payload);
- expect(request.data.device).deep.equal({
- webSessionId: TEST_WEB_SESSION_ID,
- });
- });
- });
-
- describe('interpretResponse', () => {
- it('should return an empty array when there are no bids', () => {
- const serverResponse = {};
- const response = spec.interpretResponse(serverResponse);
-
- expect(response).is.an('array').that.is.empty;
- });
-
- it('should get correct bid response', () => {
- const serverResponse = {
- body: [
- {
- requestId: '2ef08f145b7a4f',
- cpm: 3,
- width: 300,
- height: 250,
- creativeId: '123abc',
- dealId: '123abc',
- currency: 'USD',
- netRevenue: false,
- mediaType: 'banner',
- ttl: 300,
- ad: '',
- },
- ],
- };
- const response = spec.interpretResponse(serverResponse);
-
- expect(response).deep.equal(serverResponse.body);
- });
- });
-});
diff --git a/test/spec/modules/asoBidAdapter_spec.js b/test/spec/modules/asoBidAdapter_spec.js
deleted file mode 100644
index e0fffee68..000000000
--- a/test/spec/modules/asoBidAdapter_spec.js
+++ /dev/null
@@ -1,493 +0,0 @@
-import {expect} from 'chai';
-import {spec} from 'modules/asoBidAdapter.js';
-import {BANNER, NATIVE, VIDEO} from 'src/mediaTypes.js';
-import {OUTSTREAM} from 'src/video.js';
-import {addFPDToBidderRequest} from '../../helpers/fpd.js';
-import {parseUrl} from '../../../src/utils.js';
-
-import 'modules/priceFloors.js';
-import 'modules/consentManagementTcf.js';
-import 'modules/consentManagementUsp.js';
-
-describe('Adserver.Online bidding adapter', function () {
- const bannerRequest = {
- bidder: 'aso',
- params: {
- zone: 1
- },
- adUnitCode: 'adunit-banner',
- bidId: 'bid-banner',
- mediaTypes: {
- [BANNER]: {
- sizes: [
- [300, 250],
- [240, 400],
- ]
- }
- },
- userIdAsEids: [{
- source: 'src1',
- uids: [
- {
- id: 'id123...'
- }
- ]
- }]
- };
-
- const videoRequest = {
- bidder: 'aso',
- params: {
- zone: 2
- },
- adUnitCode: 'adunit-video',
- bidId: 'bid-video',
- mediaTypes: {
- [VIDEO]: {
- context: OUTSTREAM,
- playerSize: [[640, 480]],
- protocols: [1, 2],
- mimes: ['video/mp4'],
- }
- }
- };
-
- const nativeOrtbRequest = {
- assets: [
- {
- id: 0,
- required: 1,
- title: {
- len: 140
- }
- },
- {
- id: 1,
- required: 1,
- img: {
- type: 3,
- w: 300,
- h: 600
- }
- }]
- };
-
- const nativeRequest = {
- bidder: 'aso',
- params: {
- zone: 3
- },
- adUnitCode: 'adunit-native',
- bidId: 'bid-native',
- mediaTypes: {
- [NATIVE]: {
- ortb: {
- ...nativeOrtbRequest
- }
- }
- },
- nativeOrtbRequest
- };
-
- const gdprConsent = {
- gdprApplies: true,
- consentString: 'consentString',
- vendorData: {
- purpose: {
- consents: {
- 1: true,
- 2: true,
- 3: false
- }
- }
- }
- };
-
- const gdprNotApplies = {
- gdprApplies: false,
- consentString: '',
- vendorData: {
- purpose: {}
- }
- };
-
- let bidderRequest;
-
- beforeEach(() => {
- return addFPDToBidderRequest({
- refererInfo: {
- page: 'https://example.com/page.html',
- topmostLocation: 'https://example.com/page.html',
- reachedTop: true,
- numIframes: 1,
- stack: [
- 'https://example.com/page.html',
- 'https://example.com/iframe1.html'
- ]
- }
- }).then(br => { bidderRequest = br });
- })
-
- const uspConsent = 'usp_consent';
-
- describe('isBidRequestValid', function () {
- it('should return true when required params found in bidVideo', function () {
- expect(spec.isBidRequestValid(videoRequest)).to.be.true
- });
-
- it('should return true when required params found in bidBanner', function () {
- expect(spec.isBidRequestValid(bannerRequest)).to.be.true
- });
-
- it('should return false when required params not found', function () {
- expect(spec.isBidRequestValid({})).to.be.false;
- });
-
- it('should return false when required params are not passed', function () {
- const bid = Object.assign({}, bannerRequest);
- delete bid.params;
- bid.params = {};
- expect(spec.isBidRequestValid(bid)).to.be.false
- });
-
- it('should return false when required zone param not found', function () {
- const bid = JSON.parse(JSON.stringify(videoRequest));
- delete bid.params.zone;
- expect(spec.isBidRequestValid(bid)).to.be.false;
- });
- });
-
- describe('requests builder', function () {
- it('should add bid floor', function () {
- const bidRequest = Object.assign({}, bannerRequest);
-
- bidRequest.getFloor = () => {
- return {
- currency: 'USD',
- floor: 0.5
- }
- };
-
- const payload = spec.buildRequests([bidRequest], bidderRequest)[0].data;
-
- expect(payload.imp[0].bidfloor).to.equal(0.5);
- expect(payload.imp[0].bidfloorcur).to.equal('USD');
- });
-
- it('endpoint is valid', function () {
- const requests = spec.buildRequests([bannerRequest], bidderRequest);
- expect(requests).to.have.lengthOf(1);
- const request = requests[0];
-
- expect(request).to.exist;
- expect(request.method).to.equal('POST');
- const parsedUrl = parseUrl(request.url);
- expect(parsedUrl.hostname).to.equal('srv.aso1.net');
- expect(parsedUrl.pathname).to.equal('/prebid/bidder');
-
- const query = parsedUrl.search;
- expect(query.pbjs).to.contain('$prebid.version$');
- expect(query.zid).to.equal('1');
- });
-
- it('creates a valid banner request', function () {
- const requests = spec.buildRequests([bannerRequest], bidderRequest);
- expect(requests).to.have.lengthOf(1);
- const request = requests[0];
-
- expect(request).to.exist;
- expect(request.data).to.exist;
-
- const payload = request.data;
-
- expect(payload.site).to.exist;
- expect(payload.site.page).to.equal('https://example.com/page.html');
-
- expect(payload.device).to.exist;
- expect(payload.device.w).to.equal(window.screen.width);
- expect(payload.device.h).to.equal(window.screen.height);
-
- expect(payload.imp).to.have.lengthOf(1);
-
- expect(payload.imp[0].tagid).to.equal('adunit-banner');
- expect(payload.imp[0].banner).to.not.null;
- expect(payload.imp[0].banner.format).to.have.lengthOf(2);
- expect(payload.imp[0].banner.format[0].w).to.equal(300);
- expect(payload.imp[0].banner.format[0].h).to.equal(250);
- expect(payload.imp[0].banner.format[1].w).to.equal(240);
- expect(payload.imp[0].banner.format[1].h).to.equal(400);
- });
-
- if (FEATURES.VIDEO) {
- it('creates a valid video request', function () {
- const requests = spec.buildRequests([videoRequest], bidderRequest);
- expect(requests).to.have.lengthOf(1);
- const request = requests[0];
-
- expect(request).to.exist;
- expect(request.data).to.not.be.empty;
-
- const payload = request.data;
-
- expect(payload.site).to.exist;
- expect(payload.site.page).to.equal('https://example.com/page.html');
-
- expect(payload.device).to.exist;
- expect(payload.device.w).to.equal(window.screen.width);
- expect(payload.device.h).to.equal(window.screen.height);
-
- expect(payload.imp).to.have.lengthOf(1);
-
- expect(payload.imp[0].tagid).to.equal('adunit-video');
- expect(payload.imp[0].video).to.exist;
-
- expect(payload.imp[0].video.w).to.equal(640);
- expect(payload.imp[0].video.h).to.equal(480);
- expect(payload.imp[0].banner).to.not.exist;
- });
- }
-
- if (FEATURES.NATIVE) {
- it('creates a valid native request', function () {
- const requests = spec.buildRequests([nativeRequest], bidderRequest);
- expect(requests).to.have.lengthOf(1);
- const request = requests[0];
-
- expect(request).to.exist;
- expect(request.data).to.not.be.empty;
-
- const payload = request.data;
-
- expect(payload.site).to.exist;
- expect(payload.site.page).to.equal('https://example.com/page.html');
-
- expect(payload.device).to.exist;
- expect(payload.device.w).to.equal(window.screen.width);
- expect(payload.device.h).to.equal(window.screen.height);
-
- expect(payload.imp).to.have.lengthOf(1);
-
- expect(payload.imp[0].tagid).to.equal('adunit-native');
- expect(payload.imp[0].native).to.exist;
- expect(payload.imp[0].native.request).to.exist;
- });
- }
- });
-
- describe('GDPR/USP compliance', function () {
- it('should send GDPR/USP consent data if it applies', function () {
- bidderRequest.gdprConsent = gdprConsent;
- bidderRequest.uspConsent = uspConsent;
-
- return addFPDToBidderRequest(bidderRequest).then(bidderRequest => {
- const requests = spec.buildRequests([bannerRequest], bidderRequest);
- expect(requests).to.have.lengthOf(1);
- const request = requests[0];
-
- expect(request.data).to.not.be.empty;
-
- const payload = request.data;
-
- expect(payload.user.ext.consent).to.equal('consentString');
- expect(payload.regs.ext.us_privacy).to.equal(uspConsent);
- expect(payload.regs.ext.gdpr).to.equal(1);
- })
- });
-
- it('should not send GDPR/USP consent data if it does not apply', function () {
- bidderRequest.gdprConsent = null;
- bidderRequest.uspConsent = null;
-
- return addFPDToBidderRequest(bidderRequest).then(bidderRequest => {
- const requests = spec.buildRequests([bannerRequest], bidderRequest);
- expect(requests).to.have.lengthOf(1);
- const request = requests[0];
-
- expect(request.data).to.not.be.empty;
-
- const payload = request.data;
-
- expect(payload).to.not.have.nested.property('regs.ext.gdpr');
- expect(payload).to.not.have.nested.property('user.ext.consent');
- expect(payload).to.not.have.nested.property('regs.ext.us_privacy');
- });
- });
- });
-
- describe('response handler', function () {
- const bannerResponse = {
- body: {
- seatbid: [{
- bid: [
- {
- impid: 'bid-banner',
- price: 0.3,
- crid: 321,
- adm: '',
- w: 300,
- h: 250,
- adomain: ['example.com'],
- ext: {
- prebid: {
- type: 'banner'
- }
- }
- }
- ]
- }],
- cur: 'USD',
- ext: {
- user_syncs: [
- {
- url: 'sync_url',
- type: 'iframe'
- }
- ]
- }
- },
- };
-
- const videoResponse = {
- body: {
- seatbid: [{
- bid: [
- {
- impid: 'bid-video',
- price: 0.5,
- crid: 123,
- adm: '',
- adomain: ['example.com'],
- w: 640,
- h: 480,
- ext: {
- prebid: {
- type: 'video'
- }
- }
- }
- ]
- }],
- cur: 'USD'
- },
- };
-
- const nativeResponse = {
- body: {
- seatbid: [{
- bid: [
- {
- impid: 'bid-native',
- price: 0.5,
- crid: 123,
- adm: JSON.stringify({
- assets: [
- {id: 0, title: {text: 'Title'}},
- {id: 1, img: {type: 3, url: 'https://img'}},
- ],
- }),
- adomain: ['example.com'],
- ext: {
- prebid: {
- type: 'native'
- }
- }
- }
- ]
- }],
- cur: 'USD'
- },
- };
-
- it('handles banner responses', function () {
- const request = spec.buildRequests([bannerRequest], bidderRequest)[0];
- const bids = spec.interpretResponse(bannerResponse, request);
-
- expect(bids).to.have.lengthOf(1);
-
- expect(bids[0]).to.exist;
- expect(bids[0].width).to.equal(300);
- expect(bids[0].height).to.equal(250);
- expect(bids[0].mediaType).to.equal(BANNER);
- expect(bids[0].creativeId).to.equal(321);
- expect(bids[0].cpm).to.be.within(0.1, 0.5);
- expect(bids[0].ad).to.equal('');
- expect(bids[0].currency).to.equal('USD');
- expect(bids[0].netRevenue).to.equal(true);
- expect(bids[0].ttl).to.equal(300);
- expect(bids[0].dealId).to.not.exist;
- expect(bids[0].meta.advertiserDomains[0]).to.equal('example.com');
- });
-
- if (FEATURES.VIDEO) {
- it('handles video responses', function () {
- const request = spec.buildRequests([videoRequest], bidderRequest)[0];
- const bids = spec.interpretResponse(videoResponse, request);
- expect(bids).to.have.lengthOf(1);
-
- expect(bids[0].width).to.equal(640);
- expect(bids[0].height).to.equal(480);
- expect(bids[0].mediaType).to.equal(VIDEO);
- expect(bids[0].creativeId).to.equal(123);
- expect(bids[0].cpm).to.equal(0.5);
- expect(bids[0].vastXml).to.equal('');
- expect(bids[0].currency).to.equal('USD');
- expect(bids[0].netRevenue).to.equal(true);
- expect(bids[0].ttl).to.equal(300);
- });
- }
-
- if (FEATURES.NATIVE) {
- it('handles native responses', function () {
- const request = spec.buildRequests([nativeRequest], bidderRequest)[0];
- const bids = spec.interpretResponse(nativeResponse, request);
- expect(bids).to.have.lengthOf(1);
-
- expect(bids[0].mediaType).to.equal(NATIVE);
- expect(bids[0].creativeId).to.equal(123);
- expect(bids[0].cpm).to.equal(0.5);
- expect(bids[0].currency).to.equal('USD');
- expect(bids[0].netRevenue).to.equal(true);
- expect(bids[0].ttl).to.equal(300);
-
- expect(bids[0].native.ortb.assets).to.have.lengthOf(2);
- });
- }
-
- it('handles empty responses', function () {
- const response = [];
- const bidderRequest = {};
-
- const result = spec.interpretResponse(response, bidderRequest);
- expect(result.length).to.equal(0);
- });
-
- describe('getUserSyncs', function () {
- const syncOptions = {
- iframeEnabled: true
- };
-
- it('should return iframe sync option', function () {
- const syncs = spec.getUserSyncs(syncOptions, [bannerResponse], gdprConsent, uspConsent);
- expect(syncs).to.have.lengthOf(1);
- expect(syncs[0].type).to.equal('iframe');
- expect(syncs[0].url).to.equal(
- 'sync_url?gdpr=1&consents_str=consentString&consents=1%2C2&us_privacy=usp_consent'
- );
- });
-
- it('should return iframe sync option - gdpr not applies', function () {
- const syncs = spec.getUserSyncs(syncOptions, [bannerResponse], gdprNotApplies, uspConsent);
- expect(syncs).to.have.lengthOf(1);
-
- expect(syncs[0].url).to.equal(
- 'sync_url?us_privacy=usp_consent'
- );
- });
-
- it('should return no sync option', function () {
- const syncs = spec.getUserSyncs(syncOptions, [videoResponse], gdprNotApplies, uspConsent);
- expect(syncs).to.have.lengthOf(0);
- });
- });
- });
-});
diff --git a/test/spec/modules/asteriobidAnalyticsAdapter_spec.js b/test/spec/modules/asteriobidAnalyticsAdapter_spec.js
deleted file mode 100644
index e8a1cca53..000000000
--- a/test/spec/modules/asteriobidAnalyticsAdapter_spec.js
+++ /dev/null
@@ -1,151 +0,0 @@
-import asteriobidAnalytics, {storage} from 'modules/asteriobidAnalyticsAdapter.js';
-import {expect} from 'chai';
-import {server} from 'test/mocks/xhr.js';
-import * as utils from 'src/utils.js';
-import {expectEvents} from '../../helpers/analytics.js';
-import { EVENTS } from 'src/constants.js';
-
-const events = require('src/events');
-
-describe('AsterioBid Analytics Adapter', function () {
- const bidWonEvent = {
- 'bidderCode': 'appnexus',
- 'width': 300,
- 'height': 250,
- 'adId': '1ebb82ec35375e',
- 'mediaType': 'banner',
- 'cpm': 0.5,
- 'requestId': '1582271863760569973',
- 'creative_id': '96846035',
- 'creativeId': '96846035',
- 'ttl': 60,
- 'currency': 'USD',
- 'netRevenue': true,
- 'auctionId': '9c7b70b9-b6ab-4439-9e71-b7b382797c18',
- 'responseTimestamp': 1537521629657,
- 'requestTimestamp': 1537521629331,
- 'bidder': 'appnexus',
- 'adUnitCode': 'div-gpt-ad-1460505748561-0',
- 'timeToRespond': 326,
- 'size': '300x250',
- 'status': 'rendered',
- 'eventType': 'bidWon',
- 'ad': 'some ad',
- 'adUrl': 'ad url'
- };
-
- describe('AsterioBid Analytic tests', function () {
- beforeEach(function () {
- sinon.stub(events, 'getEvents').returns([]);
- });
-
- afterEach(function () {
- asteriobidAnalytics.disableAnalytics();
- events.getEvents.restore();
- });
-
- it('support custom endpoint', function () {
- const custom_url = 'custom url';
- asteriobidAnalytics.enableAnalytics({
- provider: 'asteriobid',
- options: {
- url: custom_url,
- bundleId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
- }
- });
-
- expect(asteriobidAnalytics.getOptions().url).to.equal(custom_url);
- });
-
- it('bid won event', function() {
- const bundleId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
- asteriobidAnalytics.enableAnalytics({
- provider: 'asteriobid',
- options: {
- bundleId: bundleId
- }
- });
-
- events.emit(EVENTS.BID_WON, bidWonEvent);
- asteriobidAnalytics.flush();
-
- expect(server.requests.length).to.equal(1);
- expect(server.requests[0].url).to.equal('https://endpt.asteriobid.com/endpoint');
- expect(server.requests[0].requestBody.substring(0, 2)).to.equal('1:');
-
- const pmEvents = JSON.parse(server.requests[0].requestBody.substring(2));
- expect(pmEvents.pageViewId).to.exist;
- expect(pmEvents.bundleId).to.equal(bundleId);
- expect(pmEvents.ver).to.equal(1);
- expect(pmEvents.events.length).to.equal(1);
- expect(pmEvents.events[0].eventType).to.equal('bidWon');
- expect(pmEvents.events[0].ad).to.be.undefined;
- expect(pmEvents.events[0].adUrl).to.be.undefined;
- });
-
- it('track event without errors', function () {
- sinon.spy(asteriobidAnalytics, 'track');
-
- asteriobidAnalytics.enableAnalytics({
- provider: 'asteriobid',
- options: {
- bundleId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
- }
- });
-
- expectEvents().to.beTrackedBy(asteriobidAnalytics.track);
- });
- });
-
- describe('build utm tag data', function () {
- let getDataFromLocalStorageStub;
- this.timeout(4000)
- beforeEach(function () {
- getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage');
- getDataFromLocalStorageStub.withArgs('pm_utm_source').returns('utm_source');
- getDataFromLocalStorageStub.withArgs('pm_utm_medium').returns('utm_medium');
- getDataFromLocalStorageStub.withArgs('pm_utm_campaign').returns('utm_camp');
- getDataFromLocalStorageStub.withArgs('pm_utm_term').returns('');
- getDataFromLocalStorageStub.withArgs('pm_utm_content').returns('');
- });
- afterEach(function () {
- getDataFromLocalStorageStub.restore();
- asteriobidAnalytics.disableAnalytics()
- });
- it('should build utm data from local storage', function () {
- asteriobidAnalytics.enableAnalytics({
- provider: 'asteriobid',
- options: {
- bundleId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
- }
- });
-
- const pmEvents = JSON.parse(server.requests[0].requestBody.substring(2));
-
- expect(pmEvents.utmTags.utm_source).to.equal('utm_source');
- expect(pmEvents.utmTags.utm_medium).to.equal('utm_medium');
- expect(pmEvents.utmTags.utm_campaign).to.equal('utm_camp');
- expect(pmEvents.utmTags.utm_term).to.equal('');
- expect(pmEvents.utmTags.utm_content).to.equal('');
- });
- });
-
- describe('build page info', function () {
- afterEach(function () {
- asteriobidAnalytics.disableAnalytics()
- });
- it('should build page info', function () {
- asteriobidAnalytics.enableAnalytics({
- provider: 'asteriobid',
- options: {
- bundleId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
- }
- });
-
- const pmEvents = JSON.parse(server.requests[0].requestBody.substring(2));
-
- expect(pmEvents.pageInfo.domain).to.equal(window.location.hostname);
- expect(pmEvents.pageInfo.referrerDomain).to.equal(utils.parseUrl(document.referrer).hostname);
- });
- });
-});
diff --git a/test/spec/modules/astraoneBidAdapter_spec.js b/test/spec/modules/astraoneBidAdapter_spec.js
deleted file mode 100644
index 80d6dcdf6..000000000
--- a/test/spec/modules/astraoneBidAdapter_spec.js
+++ /dev/null
@@ -1,216 +0,0 @@
-import { expect } from 'chai'
-import { spec } from 'modules/astraoneBidAdapter.js'
-
-function getSlotConfigs(mediaTypes, params) {
- return {
- params: params,
- sizes: [],
- bidId: '2df8c0733f284e',
- bidder: 'astraone',
- mediaTypes: mediaTypes,
- ortb2Imp: {
- ext: {
- tid: '31a58515-3634-4e90-9c96-f86196db1459'
- }
- }
- }
-}
-
-describe('AstraOne Adapter', function() {
- describe('isBidRequestValid method', function() {
- const PLACE_ID = '5f477bf94d506ebe2c4240f3';
- const IMAGE_URL = 'https://creative.astraone.io/files/default_image-1-600x400.jpg';
-
- describe('returns true', function() {
- describe('when banner slot config has all mandatory params', () => {
- describe('and placement has the correct value', function() {
- const createBannerSlotConfig = placement => {
- return getSlotConfigs(
- { banner: {} },
- {
- placeId: PLACE_ID,
- imageUrl: IMAGE_URL,
- placement
- }
- )
- }
- const placements = ['inImage'];
- placements.forEach(placement => {
- it('should be ' + placement, function() {
- const isBidRequestValid = spec.isBidRequestValid(
- createBannerSlotConfig(placement)
- )
- expect(isBidRequestValid).to.equal(true)
- })
- })
- })
- })
- })
- describe('returns false', function() {
- describe('when params are not correct', function() {
- function createSlotconfig(params) {
- return getSlotConfigs({ banner: {} }, params)
- }
- it('does not have the placeId.', function() {
- const isBidRequestValid = spec.isBidRequestValid(
- createSlotconfig({
- imageUrl: IMAGE_URL,
- placement: 'inImage'
- })
- )
- expect(isBidRequestValid).to.equal(false)
- })
- it('does not have the imageUrl.', function() {
- const isBidRequestValid = spec.isBidRequestValid(
- createSlotconfig({
- placeId: PLACE_ID,
- placement: 'inImage'
- })
- )
- expect(isBidRequestValid).to.equal(false)
- })
- it('does not have the placement.', function() {
- const isBidRequestValid = spec.isBidRequestValid(
- createSlotconfig({
- placeId: PLACE_ID,
- imageUrl: IMAGE_URL,
- })
- )
- expect(isBidRequestValid).to.equal(false)
- })
- it('does not have a the correct placement.', function() {
- const isBidRequestValid = spec.isBidRequestValid(
- createSlotconfig({
- placeId: PLACE_ID,
- imageUrl: IMAGE_URL,
- placement: 'something'
- })
- )
- expect(isBidRequestValid).to.equal(false)
- })
- })
- })
- })
-
- describe('buildRequests method', function() {
- const bidderRequest = {
- refererInfo: { referer: 'referer' }
- }
- const mandatoryParams = {
- placeId: '5af45ad34d506ee7acad0c26',
- imageUrl: 'https://creative.astraone.io/files/default_image-1-600x400.jpg',
- placement: 'inImage'
- }
- const validBidRequests = [
- getSlotConfigs({ banner: {} }, mandatoryParams)
- ]
- it('Url params should be correct ', function() {
- const request = spec.buildRequests(validBidRequests, bidderRequest)
- expect(request.method).to.equal('POST')
- expect(request.url).to.equal('https://ssp.astraone.io/auction/prebid')
- })
-
- it('Common data request should be correct', function() {
- const request = spec.buildRequests(validBidRequests, bidderRequest)
- const data = JSON.parse(request.data)
- expect(Array.isArray(data.bidRequests)).to.equal(true)
- data.bidRequests.forEach(bid => {
- expect(bid.placeId).to.equal('5af45ad34d506ee7acad0c26')
- expect(typeof bid.imageUrl).to.equal('string')
- })
- })
-
- describe('GDPR params', function() {
- describe('when there are not consent management platform', function() {
- it('cmp should be false', function() {
- const request = spec.buildRequests(validBidRequests, bidderRequest)
- const data = JSON.parse(request.data)
- expect(data.cmp).to.equal(false)
- })
- })
- describe('when there are consent management platform', function() {
- it('cmps should be true and ga should not sended, when gdprApplies is undefined', function() {
- bidderRequest['gdprConsent'] = {
- gdprApplies: undefined,
- consentString: 'consentString'
- }
- const request = spec.buildRequests(validBidRequests, bidderRequest)
- const data = JSON.parse(request.data)
- expect(data.cmp).to.equal(true)
- expect(Object.keys(data).indexOf('data')).to.equal(-1)
- expect(data.cs).to.equal('consentString')
- })
- it('cmps should be true and all gdpr parameters should be sended, when there are gdprApplies', function() {
- bidderRequest['gdprConsent'] = {
- gdprApplies: true,
- consentString: 'consentString'
- }
- const request = spec.buildRequests(validBidRequests, bidderRequest)
- const data = JSON.parse(request.data)
- expect(data.cmp).to.equal(true)
- expect(data.ga).to.equal(true)
- expect(data.cs).to.equal('consentString')
- })
- })
- })
-
- describe('BidRequests params', function() {
- const request = spec.buildRequests(validBidRequests, bidderRequest)
- const data = JSON.parse(request.data)
- const bidRequests = data.bidRequests
- it('should request a Banner', function() {
- const bannerBid = bidRequests[0]
- expect(bannerBid.bidId).to.equal('2df8c0733f284e')
- expect(bannerBid.transactionId).to.equal('31a58515-3634-4e90-9c96-f86196db1459')
- expect(bannerBid.placeId).to.equal('5af45ad34d506ee7acad0c26')
- })
- })
- })
-
- describe('interpret response method', function() {
- it('should return a void array, when the server response have not got bids.', function() {
- const serverResponse = {
- body: []
- }
- const bids = spec.interpretResponse(serverResponse)
- expect(Array.isArray(bids)).to.equal(true)
- expect(bids.length).to.equal(0)
- })
- describe('when the server response return a bid', function() {
- describe('the bid is a banner', function() {
- it('should return a banner bid', function() {
- const serverResponse = {
- body: {
- bids: [
- {
- bidId: '2df8c0733f284e',
- price: 0.5,
- currency: 'USD',
- content: {
- content: 'html',
- actionUrls: {},
- seanceId: '123123'
- },
- width: 100,
- height: 100,
- ttl: 360
- }
- ]
- }
- }
- const bids = spec.interpretResponse(serverResponse)
- expect(bids.length).to.equal(1)
- expect(bids[0].requestId).to.equal('2df8c0733f284e')
- expect(bids[0].creativeId).to.equal('123123')
- expect(bids[0].cpm).to.equal(0.5)
- expect(bids[0].width).to.equal(100)
- expect(bids[0].height).to.equal(100)
- expect(bids[0].currency).to.equal('USD')
- expect(bids[0].netRevenue).to.equal(true)
- expect(typeof bids[0].ad).to.equal('string')
- expect(typeof bids[0].content).to.equal('object')
- })
- })
- })
- })
-})
diff --git a/test/spec/modules/atsAnalyticsAdapter_spec.js b/test/spec/modules/atsAnalyticsAdapter_spec.js
deleted file mode 100644
index 4b8b908a7..000000000
--- a/test/spec/modules/atsAnalyticsAdapter_spec.js
+++ /dev/null
@@ -1,278 +0,0 @@
-import atsAnalyticsAdapter, {parseBrowser, analyticsUrl} from '../../../modules/atsAnalyticsAdapter.js';
-import { expect } from 'chai';
-import adapterManager from 'src/adapterManager.js';
-import {server} from '../../mocks/xhr.js';
-
-import {getCoreStorageManager, getStorageManager} from '../../../src/storageManager.js';
-
-import {EVENTS} from 'src/constants.js';
-import {getGlobal} from '../../../src/prebidGlobal.js';
-
-const utils = require('src/utils');
-const events = require('src/events');
-
-const storage = getCoreStorageManager();
-let sandbox;
-let clock;
-const now = new Date();
-
-describe('ats analytics adapter', function () {
- beforeEach(function () {
- sinon.stub(events, 'getEvents').returns([]);
- storage.setCookie('_lr_env_src_ats', 'true', 'Thu, 01 Jan 1970 00:00:01 GMT');
- sandbox = sinon.createSandbox();
- clock = sandbox.useFakeTimers(now.getTime());
- });
-
- afterEach(function () {
- events.getEvents.restore();
- atsAnalyticsAdapter.getUserAgent.restore();
- atsAnalyticsAdapter.disableAnalytics();
- Math.random.restore();
- sandbox.restore();
- clock.restore();
- });
-
- describe('track', function () {
- it('builds and sends request and response data', function () {
- sinon.stub(Math, 'random').returns(0.99);
- sinon.stub(atsAnalyticsAdapter, 'getUserAgent').returns('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.25 (KHTML, like Gecko) Version/6.0 Safari/536.25');
-
- now.setTime(now.getTime() + 3600000);
- storage.setCookie('_lr_env_src_ats', 'true', now.toUTCString());
- storage.setCookie('_lr_sampling_rate', '10', now.toUTCString());
-
- this.timeout(2100);
-
- const initOptions = {
- pid: '10433394'
- };
- const auctionTimestamp = 1496510254326;
-
- // prepare general auction - request
- const bidRequest = {
- 'bidderCode': 'appnexus',
- 'auctionStart': 1580739265161,
- 'bids': [{
- 'bidder': 'appnexus',
- 'params': {
- 'placementId': '10433394'
- },
- 'userId': {
- 'idl_env': 'AmThEbO1ssIWjrNdU4noT4ZFBILSVBBYHbipOYt_JP40e5nZdXns2g'
- },
- 'adUnitCode': 'div-gpt-ad-1438287399331-0',
- 'transactionId': '2f481ff1-8d20-4c28-8e36-e384e9e3eec6',
- 'sizes': '300x250,300x600',
- 'bidId': '30c77d079cdf17'
- }],
- 'refererInfo': {
- 'referer': 'https://example.com/dev'
- },
- 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7'
- };
- // prepare general auction - response
- const bidResponse = {
- 'height': 250,
- 'statusMessage': 'Bid available',
- 'adId': '2eddfdc0c791dc',
- 'mediaType': 'banner',
- 'source': 'client',
- 'requestId': '30c77d079cdf17',
- 'cpm': 0.5,
- 'creativeId': 29681110,
- 'currency': 'USD',
- 'netRevenue': true,
- 'ttl': 300,
- 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7',
- 'responseTimestamp': 1580739791978,
- 'requestTimestamp': 1580739265164,
- 'bidder': 'appnexus',
- 'adUnitCode': 'div-gpt-ad-1438287399331-0',
- 'timeToRespond': 2510,
- 'size': '300x250'
- };
-
- // what we expect after general auction
- const expectedAfterBid = {
- 'Data': [{
- 'has_envelope': true,
- 'adapter_version': 3,
- 'bidder': 'appnexus',
- 'bid_id': '30c77d079cdf17',
- 'auction_id': 'a5b849e5-87d7-4205-8300-d063084fcfb7',
- 'user_browser': parseBrowser(),
- 'user_platform': navigator.platform,
- 'auction_start': '2020-02-03T14:14:25.161Z',
- 'domain': window.location.hostname,
- 'envelope_source': true,
- 'pid': '10433394',
- 'response_time_stamp': '2020-02-03T14:23:11.978Z',
- 'currency': 'USD',
- 'cpm': 0.5,
- 'net_revenue': true,
- 'bid_won': true
- }]
- };
-
- const wonRequest = {
- 'adId': '2eddfdc0c791dc',
- 'mediaType': 'banner',
- 'requestId': '30c77d079cdf17',
- 'cpm': 0.5,
- 'creativeId': 29681110,
- 'currency': 'USD',
- 'netRevenue': true,
- 'ttl': 300,
- 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7',
- 'statusMessage': 'Bid available',
- 'responseTimestamp': 1633525319061,
- 'requestTimestamp': 1633525319258,
- 'bidder': 'appnexus',
- 'adUnitCode': 'div-gpt-ad-1438287399331-0',
- 'size': '300x250',
- 'status': 'rendered'
- };
-
- // lets simulate that some bidders timeout
- const bidTimeoutArgsV1 = [
- {
- bidId: '2baa51527bd015',
- bidder: 'bidderOne',
- adUnitCode: '/19968336/header-bid-tag-0',
- auctionId: '66529d4c-8998-47c2-ab3e-5b953490b98f'
- },
- {
- bidId: '6fe3b4c2c23092',
- bidder: 'bidderTwo',
- adUnitCode: '/19968336/header-bid-tag-0',
- auctionId: '66529d4c-8998-47c2-ab3e-5b953490b98f'
- }
- ];
-
- adapterManager.registerAnalyticsAdapter({
- code: 'atsAnalytics',
- adapter: atsAnalyticsAdapter
- });
-
- adapterManager.enableAnalytics({
- provider: 'atsAnalytics',
- options: initOptions
- });
-
- // Step 1: Send auction init event
- events.emit(EVENTS.AUCTION_INIT, {
- timestamp: auctionTimestamp
- });
- // Step 2: Send bid requested event
- events.emit(EVENTS.BID_REQUESTED, bidRequest);
-
- // Step 3: Send bid response event
- events.emit(EVENTS.BID_RESPONSE, bidResponse);
-
- // Step 4: Send bid time out event
- events.emit(EVENTS.BID_TIMEOUT, bidTimeoutArgsV1);
-
- // Step 5: Send auction end event
- events.emit(EVENTS.AUCTION_END, {});
- // Step 6: Send bid won event
- events.emit(EVENTS.BID_WON, wonRequest);
-
- sandbox.stub(getGlobal(), 'getAllWinningBids').callsFake((key) => {
- return [wonRequest]
- });
-
- clock.tick(2000);
-
- const requests = server.requests.filter(req => {
- return req.url.indexOf(analyticsUrl) > -1;
- });
-
- expect(requests.length).to.equal(1);
-
- const realAfterBid = JSON.parse(requests[0].requestBody);
-
- // Step 7: assert real data after bid and expected data
- expect(realAfterBid['Data']).to.deep.equal(expectedAfterBid['Data']);
-
- // check that the publisher ID is configured via options
- expect(atsAnalyticsAdapter.context.pid).to.equal(initOptions.pid);
- })
- it('check browser is safari', function () {
- sinon.stub(atsAnalyticsAdapter, 'getUserAgent').returns('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.25 (KHTML, like Gecko) Version/6.0 Safari/536.25');
- sinon.stub(Math, 'random').returns(0.99);
- const browser = parseBrowser();
- expect(browser).to.equal('Safari');
- })
- it('check browser is chrome', function () {
- sinon.stub(atsAnalyticsAdapter, 'getUserAgent').returns('Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/80.0.3987.95 Mobile/15E148 Safari/604.1');
- sinon.stub(Math, 'random').returns(0.99);
- const browser = parseBrowser();
- expect(browser).to.equal('Chrome');
- })
- it('check browser is edge', function () {
- sinon.stub(atsAnalyticsAdapter, 'getUserAgent').returns('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.74 Safari/537.36 Edg/79.0.309.43');
- sinon.stub(Math, 'random').returns(0.99);
- const browser = parseBrowser();
- expect(browser).to.equal('Microsoft Edge');
- })
- it('check browser is firefox', function () {
- sinon.stub(atsAnalyticsAdapter, 'getUserAgent').returns('Mozilla/5.0 (iPhone; CPU OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/23.0 Mobile/15E148 Safari/605.1.15');
- sinon.stub(Math, 'random').returns(0.99);
- const browser = parseBrowser();
- expect(browser).to.equal('Firefox');
- })
- it('check browser is unknown', function () {
- sinon.stub(atsAnalyticsAdapter, 'getUserAgent').returns(undefined);
- sinon.stub(Math, 'random').returns(0.99);
- const browser = parseBrowser();
- expect(browser).to.equal('Unknown');
- })
- it('should not fire analytics request if sampling rate is 0', function () {
- sinon.stub(atsAnalyticsAdapter, 'getUserAgent').returns('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.25 (KHTML, like Gecko) Version/6.0 Safari/536.25');
- sinon.stub(Math, 'random').returns(0.99);
- const result = atsAnalyticsAdapter.shouldFireRequest(0);
- expect(result).to.equal(false);
- })
- it('should fire analytics request', function () {
- sinon.stub(atsAnalyticsAdapter, 'getUserAgent').returns('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.25 (KHTML, like Gecko) Version/6.0 Safari/536.25');
- sinon.stub(Math, 'random').returns(0.99);
- // publisher can try to pass anything they want but we will set sampling rate to 100, which means we will have 1% of requests
- const result = atsAnalyticsAdapter.shouldFireRequest(8);
- expect(result).to.equal(true);
- })
- it('should not fire analytics request if math random is something other then 0.99', function () {
- sinon.stub(atsAnalyticsAdapter, 'getUserAgent').returns('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.25 (KHTML, like Gecko) Version/6.0 Safari/536.25');
- sinon.stub(Math, 'random').returns(0.98);
- // publisher can try to pass anything they want but we will set sampling rate to 100, which means we will have 1% of requests
- const result = atsAnalyticsAdapter.shouldFireRequest(10);
- expect(result).to.equal(false);
- })
-
- it('should set cookie value to 10 for _lr_sampling_rate', function () {
- sinon.stub(atsAnalyticsAdapter, 'getUserAgent').returns('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.25 (KHTML, like Gecko) Version/6.0 Safari/536.25');
- sinon.stub(Math, 'random').returns(0.99);
- atsAnalyticsAdapter.setSamplingCookie(10);
- const samplingRate = storage.getCookie('_lr_sampling_rate');
- expect(samplingRate).to.equal('10');
- })
-
- it('should set cookie value to 0 for _lr_sampling_rate', function () {
- sinon.stub(atsAnalyticsAdapter, 'getUserAgent').returns('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.25 (KHTML, like Gecko) Version/6.0 Safari/536.25');
- sinon.stub(Math, 'random').returns(0.99);
- atsAnalyticsAdapter.setSamplingCookie(0);
- const samplingRate = storage.getCookie('_lr_sampling_rate');
- expect(samplingRate).to.equal('0');
- })
-
- it('enable analytics', function () {
- sandbox.stub(utils, 'logError');
- sinon.stub(atsAnalyticsAdapter, 'getUserAgent').returns('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.25 (KHTML, like Gecko) Version/6.0 Safari/536.25');
- sinon.stub(Math, 'random').returns(0.99);
- atsAnalyticsAdapter.enableAnalytics({
- options: {}
- });
- expect(utils.logError.called).to.equal(true);
- })
- })
-})
diff --git a/test/spec/modules/audiencerunBidAdapter_spec.js b/test/spec/modules/audiencerunBidAdapter_spec.js
deleted file mode 100644
index 56fdaef63..000000000
--- a/test/spec/modules/audiencerunBidAdapter_spec.js
+++ /dev/null
@@ -1,337 +0,0 @@
-import { expect } from 'chai';
-import { spec } from 'modules/audiencerunBidAdapter.js';
-import { newBidder } from 'src/adapters/bidderFactory.js';
-
-const ENDPOINT = 'https://d.audiencerun.com/prebid';
-
-const BID_SERVER_RESPONSE = {
- body: {
- bid: [
- {
- bidId: '51ef8751f9aead',
- zoneId: '12345abcde',
- crid: '5678',
- cpm: 8.0219519,
- currency: 'USD',
- w: 728,
- h: 90,
- isNet: false,
- buying_type: 'rtb',
- syncUrl: 'https://ac.audiencerun.com/f/sync.html',
- adm: '',
- adomain: ['example.com'],
- },
- ],
- },
-};
-
-describe('AudienceRun bid adapter tests', function () {
- const adapter = newBidder(spec);
-
- describe('inherited functions', function () {
- it('exists and is a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('isBidRequestValid', function () {
- const bid = {
- bidder: 'audiencerun',
- params: {
- zoneId: '12345abcde',
- },
- adUnitCode: 'adunit-code',
- mediaTypes: {
- banner: {
- sizes: [
- [300, 250],
- [300, 600],
- ],
- },
- },
- bidId: '30b31c1838de1e',
- bidderRequestId: '22edbae2733bf6',
- auctionId: '1d1a030790a475',
- creativeId: 'er2ee',
- };
-
- it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should return true when zoneId is valid', function () {
- const invalidBid = Object.assign({}, bid);
- delete invalidBid.params;
- invalidBid.params = {
- zoneId: '12345abcde',
- };
-
- expect(spec.isBidRequestValid(invalidBid)).to.equal(true);
- });
-
- it('should return false when required params are not passed', function () {
- const invalidBid = Object.assign({}, bid);
- delete invalidBid.params;
-
- invalidBid.params = {};
-
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
- });
-
- describe('buildRequests', function () {
- const bidRequests = [
- {
- bidder: 'audiencerun',
- bidId: '51ef8751f9aead',
- params: {
- zoneId: '12345abcde',
- },
- adUnitCode: 'div-gpt-ad-1460505748561-0',
- transactionId: 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec',
- mediaTypes: {
- banner: {
- sizes: [
- [320, 50],
- [300, 250],
- [300, 600],
- ],
- },
- },
- bidderRequestId: '418b37f85e772c',
- auctionId: '18fd8b8b0bd757',
- bidRequestsCount: 1,
- },
- ];
- const bidRequest = bidRequests[0];
-
- it('sends a valid bid request to ENDPOINT via POST', function () {
- const request = spec.buildRequests(bidRequests, {
- gdprConsent: {
- consentString:
- 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA',
- gdprApplies: true,
- },
- refererInfo: {
- canonicalUrl: undefined,
- page: 'https://example.com',
- topmostLocation: 'https://example.com',
- numIframes: 0,
- reachedTop: true,
- },
- });
-
- expect(request.url).to.equal(ENDPOINT);
- expect(request.method).to.equal('POST');
-
- const payload = JSON.parse(request.data);
- expect(payload.gdpr).to.exist;
-
- expect(payload.bids)
- .to.exist.and.to.be.an('array')
- .and.to.have.lengthOf(1);
- expect(payload.referer).to.exist;
-
- const bid = payload.bids[0];
- expect(bid).to.exist;
- expect(bid).to.have.property('bidId');
- expect(bid).to.have.property('zoneId');
- expect(bid).to.have.property('sizes');
- expect(bid.sizes[0].w).to.be.a('number');
- expect(bid.sizes[0].h).to.be.a('number');
- });
-
- it('should send GDPR to endpoint and honor gdprApplies value', function () {
- const consentString = 'bogusConsent';
- const bidderRequest = {
- gdprConsent: {
- consentString: consentString,
- gdprApplies: true,
- },
- };
-
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const payload = JSON.parse(request.data);
- expect(payload.gdpr).to.exist;
- expect(payload.gdpr.consent).to.equal(consentString);
- expect(payload.gdpr.applies).to.equal(true);
-
- const bidderRequest2 = {
- gdprConsent: {
- consentString: consentString,
- gdprApplies: false,
- },
- };
-
- const request2 = spec.buildRequests(bidRequests, bidderRequest2);
- const payload2 = JSON.parse(request2.data);
-
- expect(payload2.gdpr).to.exist;
- expect(payload2.gdpr.consent).to.equal(consentString);
- expect(payload2.gdpr.applies).to.equal(false);
- });
-
- it('should use the auctionUrl passed from bid params', function () {
- const bid = Object.assign({}, bidRequest, {
- params: {
- zoneId: '12345abcde',
- auctionUrl: 'https://auction.url.audiencerun.com',
- },
- });
- const request = spec.buildRequests([bid]);
-
- expect(request.url).to.exist;
- expect(request.url).to.equal('https://auction.url.audiencerun.com');
- });
-
- it('should use a bidfloor with a 0 value', function () {
- const bid = Object.assign({}, bidRequest);
- const request = spec.buildRequests([bid]);
- const payload = JSON.parse(request.data);
- expect(payload.bids[0].bidfloor).to.exist.and.to.equal(0);
- });
-
- it('should use bidfloor param value', function () {
- const bid = Object.assign({}, bidRequest, {
- params: {
- bidfloor: 0.2,
- },
- });
- const request = spec.buildRequests([bid]);
- const payload = JSON.parse(request.data);
- expect(payload.bids[0].bidfloor).to.exist.and.to.equal(0.2);
- });
-
- it('should use floors module value', function () {
- const bid = Object.assign({}, bidRequest, {
- params: {
- bidfloor: 0.5,
- },
- });
- bid.getFloor = () => {
- return { floor: 1, currency: 'USD' };
- };
- const request = spec.buildRequests([bid]);
- const payload = JSON.parse(request.data);
- expect(payload.bids[0].bidfloor).to.exist.and.to.equal(1);
- });
-
- it('should add userid eids information to the request', function () {
- const bid = Object.assign({}, bidRequest);
- bid.userIdAsEids = [
- {
- source: 'pubcid.org',
- uids: [
- {
- atype: 1,
- id: '01EAJWWNEPN3CYMM5N8M5VXY22',
- },
- ],
- },
- ];
-
- const request = spec.buildRequests([bid]);
- const payload = JSON.parse(request.data);
-
- expect(payload.userId).to.exist;
- expect(payload.userId).to.deep.equal(bid.userIdAsEids);
- });
-
- it('should add schain object if available', function() {
- const bid = Object.assign({}, bidRequest)
- bid.ortb2 = {
- source: {
- ext: {
- schain: {
- ver: '1.0',
- complete: 1,
- nodes: [
- {
- asi: 'directseller.com',
- sid: '00001',
- rid: 'BidRequest1',
- hp: 1,
- },
- ],
- }
- }
- }
- };
-
- const request = spec.buildRequests([bid]);
- const payload = JSON.parse(request.data);
-
- expect(payload.schain).to.exist;
- expect(payload.schain).to.deep.equal({
- ver: '1.0',
- complete: 1,
- nodes: [
- {
- asi: 'directseller.com',
- sid: '00001',
- rid: 'BidRequest1',
- hp: 1,
- },
- ],
- });
- })
- });
-
- describe('interpretResponse', function () {
- const expectedResponse = [
- {
- requestId: '51ef8751f9aead',
- cpm: 8.0219519,
- width: '728',
- height: '90',
- creativeId: '5678',
- currency: 'USD',
- netRevenue: false,
- ttl: 300,
- ad: '',
- mediaType: 'banner',
- meta: {
- advertiserDomains: ['example.com'],
- },
- },
- ];
-
- it('should get the correct bid response by display ad', function () {
- const result = spec.interpretResponse(BID_SERVER_RESPONSE);
- expect(Object.keys(result[0])).to.have.members(
- Object.keys(expectedResponse[0])
- );
- });
-
- it('should handle empty bid response', function () {
- const response = {
- body: {},
- };
- const result = spec.interpretResponse(response);
- expect(result.length).to.equal(0);
- });
- });
-
- describe('getUserSyncs', function () {
- const serverResponses = [BID_SERVER_RESPONSE];
- const syncOptions = { iframeEnabled: true };
-
- it('should return empty if no server responses', function () {
- const syncs = spec.getUserSyncs(syncOptions, []);
- expect(syncs).to.deep.equal([]);
- });
-
- it('should return user syncs', function () {
- const syncs = spec.getUserSyncs(syncOptions, serverResponses);
- expect(syncs).to.deep.equal([
- { type: 'iframe', url: 'https://ac.audiencerun.com/f/sync.html' },
- ]);
- });
- });
-
- describe('onTimeout', function () {
- it('should exists and be a function', () => {
- expect(spec.onTimeout).to.exist.and.to.be.a('function');
- });
- });
-});
diff --git a/test/spec/modules/automatadAnalyticsAdapter_spec.js b/test/spec/modules/automatadAnalyticsAdapter_spec.js
deleted file mode 100644
index 9a7e6b13a..000000000
--- a/test/spec/modules/automatadAnalyticsAdapter_spec.js
+++ /dev/null
@@ -1,620 +0,0 @@
-import * as events from 'src/events';
-import * as utils from 'src/utils.js';
-
-import spec, {self as exports} from 'modules/automatadAnalyticsAdapter.js';
-
-import { EVENTS } from 'src/constants.js';
-import { expect } from 'chai';
-
-const obj = {
- auctionInitHandler: (args) => {},
- bidResponseHandler: (args) => {},
- bidderDoneHandler: (args) => {},
- bidWonHandler: (args) => {},
- noBidHandler: (args) => {},
- auctionDebugHandler: (args) => {},
- bidderTimeoutHandler: (args) => {},
- bidRequestedHandler: (args) => {},
- bidRejectedHandler: (args) => {}
-}
-
-const {
- AUCTION_DEBUG,
- BID_REQUESTED,
- BID_REJECTED,
- AUCTION_INIT,
- BIDDER_DONE,
- BID_RESPONSE,
- BID_TIMEOUT,
- BID_WON,
- NO_BID
-} = EVENTS
-
-const CONFIG_WITH_DEBUG = {
- provider: 'atmtdAnalyticsAdapter',
- options: {
- publisherID: '230',
- siteID: '421'
- },
- includeEvents: [AUCTION_DEBUG, AUCTION_INIT, BIDDER_DONE, BID_RESPONSE, BID_TIMEOUT, NO_BID, BID_WON, BID_REQUESTED, BID_REJECTED]
-}
-
-describe('Automatad Analytics Adapter', () => {
- var sandbox, clock;
-
- describe('Adapter Setup Configuration', () => {
- beforeEach(() => {
- sandbox = sinon.createSandbox();
- sandbox.stub(utils, 'logMessage')
- sandbox.stub(events, 'getEvents').returns([]);
- sandbox.stub(utils, 'logError');
- });
- afterEach(() => {
- sandbox.restore();
- });
-
- it('Should log error and return false if nothing is passed as the param in the enable analytics call', () => {
- spec.enableAnalytics()
-
- expect(utils.logError.called).to.equal(true)
- });
-
- it('Should log error and return false if object type is not passed as the param in the enable analytics call', () => {
- spec.enableAnalytics('hello world')
-
- expect(utils.logError.called).to.equal(true)
- });
-
- it('Should log error and return false if options is not defined in the enable analytics call', () => {
- spec.enableAnalytics({
- provider: 'atmtdAnalyticsAdapter'
- })
-
- expect(utils.logError.called).to.equal(true)
- });
- it('Should log error and return false if pub id is not defined in the enable analytics call', () => {
- spec.enableAnalytics({
- provider: 'atmtdAnalyticsAdapter',
- options: {
- siteID: '230'
- }
- })
-
- expect(utils.logError.called).to.equal(true)
- });
- it('Should log error and return false if pub id is not defined in the enable analytics call', () => {
- spec.enableAnalytics({
- provider: 'atmtdAnalyticsAdapter',
- options: {
- publisherID: '230'
- }
- })
-
- expect(utils.logError.called).to.equal(true)
- });
- it('Should successfully configure the adapter and set global log debug messages flag to false', () => {
- spec.enableAnalytics({
- provider: 'atmtdAnalyticsAdapter',
- options: {
- publisherID: '230',
- siteID: '421',
- logDebug: false
- }
- });
- expect(utils.logError.called).to.equal(false)
- expect(utils.logMessage.called).to.equal(true)
- spec.disableAnalytics();
- });
- it('Should successfully configure the adapter and set global log debug messages flag to true', () => {
- sandbox.stub(exports, 'initializeQueue').callsFake(() => {});
- sandbox.stub(exports, 'addGPTHandlers').callsFake(() => {});
- const config = {
- provider: 'atmtdAnalyticsAdapter',
- options: {
- publisherID: '230',
- siteID: '410',
- logDebug: true
- }
- }
-
- spec.enableAnalytics(config)
- expect(utils.logError.called).to.equal(false)
- expect(exports.initializeQueue.called).to.equal(true)
- expect(exports.addGPTHandlers.called).to.equal(true)
- expect(utils.logMessage.called).to.equal(true)
- spec.disableAnalytics();
- });
- });
-
- describe('Behaviour of the adapter when the sdk has loaded', () => {
- before(() => {
- spec.enableAnalytics(CONFIG_WITH_DEBUG);
-
- global.window.atmtdAnalytics = obj
- exports.qBeingUsed = false
- exports.qTraversalComplete = undefined
- Object.keys(obj).forEach((fn) => sandbox.spy(global.window.atmtdAnalytics, fn))
- })
- beforeEach(() => {
- sandbox = sinon.createSandbox();
- sandbox.stub(events, 'getEvents').returns([]);
- sandbox.stub(utils, 'logMessage');
- sandbox.stub(utils, 'logError');
- });
- afterEach(() => {
- sandbox.restore();
- });
- after(() => {
- const handlers = global.window.atmtdAnalytics
- Object.keys(handlers).forEach((handler) => global.window.atmtdAnalytics[handler].resetHistory())
- global.window.atmtdAnalytics = undefined;
- spec.disableAnalytics();
- exports.qBeingUsed = false
- exports.qTraversalComplete = undefined
- })
-
- it('Should call the auctionInitHandler when the auction init event is fired', () => {
- events.emit(AUCTION_INIT, {type: AUCTION_INIT})
- expect(global.window.atmtdAnalytics.auctionInitHandler.called).to.equal(true)
- });
-
- it('Should call the bidRequested when the bidRequested event is fired', () => {
- events.emit(BID_REQUESTED, {type: BID_REQUESTED})
- expect(global.window.atmtdAnalytics.bidRequestedHandler.called).to.equal(true)
- });
-
- it('Should call the bidRejected when the bidRejected event is fired', () => {
- events.emit(BID_REJECTED, {type: BID_REJECTED})
- expect(global.window.atmtdAnalytics.bidRejectedHandler.called).to.equal(true)
- });
-
- it('Should call the bidResponseHandler when the bidResponse event is fired', () => {
- events.emit(BID_RESPONSE, {type: BID_RESPONSE})
- expect(global.window.atmtdAnalytics.bidResponseHandler.called).to.equal(true)
- });
-
- it('Should call the bidderDoneHandler when the bidderDone event is fired', () => {
- events.emit(BIDDER_DONE, {type: BIDDER_DONE})
- expect(global.window.atmtdAnalytics.bidderDoneHandler.called).to.equal(true)
- });
-
- it('Should call the bidWonHandler when the bidWon event is fired', () => {
- events.emit(BID_WON, {type: BID_WON})
- expect(global.window.atmtdAnalytics.bidWonHandler.called).to.equal(true)
- });
-
- it('Should call the noBidHandler when the noBid event is fired', () => {
- events.emit(NO_BID, {type: NO_BID})
- expect(global.window.atmtdAnalytics.noBidHandler.called).to.equal(true)
- });
-
- it('Should call the bidTimeoutHandler when the bidTimeout event is fired', () => {
- events.emit(BID_TIMEOUT, {type: BID_TIMEOUT})
- expect(global.window.atmtdAnalytics.bidderTimeoutHandler.called).to.equal(true)
- });
-
- it('Should call the auctionDebugHandler when the auctionDebug event is fired', () => {
- events.emit(AUCTION_DEBUG, {type: AUCTION_DEBUG})
- expect(global.window.atmtdAnalytics.auctionDebugHandler.called).to.equal(true)
- });
- });
-
- describe('Behaviour of the adapter when the SDK has not loaded', () => {
- before(() => {
- spec.enableAnalytics(CONFIG_WITH_DEBUG);
- })
- beforeEach(() => {
- sandbox = sinon.createSandbox();
- sandbox.stub(events, 'getEvents').returns([]);
- sandbox.stub(utils, 'logMessage');
- sandbox.stub(utils, 'logError');
-
- global.window.atmtdAnalytics = undefined
- exports.__atmtdAnalyticsQueue.length = 0
- sandbox.stub(exports.__atmtdAnalyticsQueue, 'push').callsFake((args) => {
- Array.prototype.push.apply(exports.__atmtdAnalyticsQueue, [args]);
- })
- });
- afterEach(() => {
- sandbox.restore();
- });
- after(() => {
- spec.disableAnalytics();
- })
-
- it('Should push to the que when the auctionInit event is fired', () => {
- events.emit(AUCTION_INIT, {type: AUCTION_INIT})
- expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true)
- expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1)
- expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2)
- expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(AUCTION_INIT)
- expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(AUCTION_INIT)
- });
-
- it('Should push to the que when the bidResponse event is fired', () => {
- events.emit(BID_RESPONSE, {type: BID_RESPONSE})
- expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true)
- expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1)
- expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2)
- expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(BID_RESPONSE)
- expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(BID_RESPONSE)
- });
-
- it('Should push to the que when the bidRequested event is fired', () => {
- events.emit(BID_REQUESTED, {type: BID_REQUESTED})
- expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true)
- expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1)
- expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2)
- expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(BID_REQUESTED)
- expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(BID_REQUESTED)
- });
-
- it('Should push to the que when the bidRejected event is fired', () => {
- events.emit(BID_REJECTED, {type: BID_REJECTED})
- expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true)
- expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1)
- expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2)
- expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(BID_REJECTED)
- expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(BID_REJECTED)
- });
-
- it('Should push to the que when the bidderDone event is fired', () => {
- events.emit(BIDDER_DONE, {type: BIDDER_DONE})
- expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true)
- expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1)
- expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2)
- expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(BIDDER_DONE)
- expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(BIDDER_DONE)
- });
-
- it('Should push to the que when the bidWon event is fired', () => {
- events.emit(BID_WON, {type: BID_WON})
- expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true)
- expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1)
- expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2)
- expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(BID_WON)
- expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(BID_WON)
- });
-
- it('Should push to the que when the noBid event is fired', () => {
- events.emit(NO_BID, {type: NO_BID})
- expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true)
- expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1)
- expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2)
- expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(NO_BID)
- expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(NO_BID)
- });
-
- it('Should push to the que when the auctionDebug is fired', () => {
- events.emit(AUCTION_DEBUG, {type: AUCTION_DEBUG})
- expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true)
- expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1)
- expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2)
- expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(AUCTION_DEBUG)
- expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(AUCTION_DEBUG)
- });
-
- it('Should push to the que when the bidderTimeout event is fired', () => {
- events.emit(BID_TIMEOUT, {type: BID_TIMEOUT})
- expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true)
- expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1)
- expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2)
- expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(BID_TIMEOUT)
- expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(BID_TIMEOUT)
- });
- });
-
- describe('Behaviour of the adapter when the SDK has loaded midway', () => {
- before(() => {
- spec.enableAnalytics(CONFIG_WITH_DEBUG);
- })
- beforeEach(() => {
- sandbox = sinon.createSandbox();
-
- global.window.atmtdAnalytics = undefined
-
- exports.qBeingUsed = undefined
- exports.qTraversalComplete = undefined
- exports.queuePointer = 0
- exports.retryCount = 0
- exports.__atmtdAnalyticsQueue.length = 0
-
- clock = sandbox.useFakeTimers();
-
- sandbox.spy(exports.__atmtdAnalyticsQueue, 'push')
- });
- afterEach(() => {
- sandbox.restore();
- });
- after(() => {
- spec.disableAnalytics();
- })
-
- it('Should push to the que when the auctionInit event is fired and push to the que even after SDK has loaded after auctionInit event', () => {
- events.emit(BID_RESPONSE, {type: BID_RESPONSE})
- expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true)
- expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1)
- expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2)
- expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(BID_RESPONSE)
- expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(BID_RESPONSE)
- expect(exports.qBeingUsed).to.equal(true)
- expect(exports.qTraversalComplete).to.equal(undefined)
- global.window.atmtdAnalytics = obj
- events.emit(BID_RESPONSE, {type: BID_RESPONSE})
- expect(exports.__atmtdAnalyticsQueue.push.calledTwice).to.equal(true)
- expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(2)
- expect(exports.__atmtdAnalyticsQueue[1]).to.have.lengthOf(2)
- expect(exports.__atmtdAnalyticsQueue[1][0]).to.equal(BID_RESPONSE)
- expect(exports.__atmtdAnalyticsQueue[1][1].type).to.equal(BID_RESPONSE)
- expect(exports.qBeingUsed).to.equal(true)
- expect(exports.qTraversalComplete).to.equal(undefined)
- });
-
- it('Should push to the que when the auctionInit event is fired and push to the analytics adapter handler after the que is processed', () => {
- expect(exports.qBeingUsed).to.equal(undefined)
- events.emit(AUCTION_INIT, {type: AUCTION_INIT})
- global.window.atmtdAnalytics = {...obj}
- const handlers = global.window.atmtdAnalytics
- Object.keys(handlers).forEach((handler) => global.window.atmtdAnalytics[handler].resetHistory())
- expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true)
- expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1)
- expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2)
- expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(AUCTION_INIT)
- expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(AUCTION_INIT)
- expect(exports.qBeingUsed).to.equal(true)
- expect(exports.qTraversalComplete).to.equal(undefined)
- expect(global.window.atmtdAnalytics.auctionInitHandler.callCount).to.equal(0)
- clock.tick(2000)
- expect(exports.qBeingUsed).to.equal(true)
- expect(exports.qTraversalComplete).to.equal(undefined)
- events.emit(NO_BID, {type: NO_BID})
- expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(2)
- expect(exports.__atmtdAnalyticsQueue.push.calledTwice).to.equal(true)
- clock.tick(1500)
- expect(exports.qBeingUsed).to.equal(false)
- expect(exports.qTraversalComplete).to.equal(true)
- events.emit(BID_RESPONSE, {type: BID_RESPONSE})
- expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(2)
- expect(exports.__atmtdAnalyticsQueue.push.calledTwice).to.equal(true)
- expect(exports.__atmtdAnalyticsQueue.push.calledThrice).to.equal(false)
- expect(global.window.atmtdAnalytics.auctionInitHandler.calledOnce).to.equal(true)
- expect(global.window.atmtdAnalytics.noBidHandler.calledOnce).to.equal(true)
- expect(global.window.atmtdAnalytics.bidResponseHandler.calledOnce).to.equal(true)
- });
- });
-
- describe('Process Events from Que when SDK still has not loaded', () => {
- before(() => {
- spec.enableAnalytics({
- provider: 'atmtdAnalyticsAdapter',
- options: {
- publisherID: '230',
- siteID: '421'
- }
- });
- global.window.atmtdAnalytics = undefined
-
- sandbox.stub(exports.__atmtdAnalyticsQueue, 'push').callsFake((args) => {
- Array.prototype.push.apply(exports.__atmtdAnalyticsQueue, [args]);
- })
- exports.queuePointer = 0;
- exports.retryCount = 0;
- })
- beforeEach(() => {
- sandbox = sinon.createSandbox();
- sandbox.stub(events, 'getEvents').returns([]);
- sandbox.spy(exports, 'prettyLog')
- sandbox.spy(exports, 'processEvents')
-
- clock = sandbox.useFakeTimers();
- exports.__atmtdAnalyticsQueue.length = 0
- });
- afterEach(() => {
- sandbox.restore();
- exports.queuePointer = 0;
- exports.retryCount = 0;
- spec.disableAnalytics();
- })
-
- it('Should retry processing auctionInit in certain intervals', () => {
- expect(exports.queuePointer).to.equal(0)
- expect(exports.retryCount).to.equal(0)
- const que = [[AUCTION_INIT, {type: AUCTION_INIT}]]
- exports.__atmtdAnalyticsQueue.push(que[0])
- exports.processEvents()
- expect(exports.prettyLog.getCall(0).args[0]).to.equal('status')
- expect(exports.prettyLog.getCall(0).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 1`)
- expect(exports.prettyLog.getCall(1).args[0]).to.equal('warn')
- expect(exports.prettyLog.getCall(1).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 1500ms ...`)
- clock.tick(1510)
- expect(exports.prettyLog.getCall(2).args[0]).to.equal('status')
- expect(exports.prettyLog.getCall(2).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 2`)
- expect(exports.prettyLog.getCall(3).args[0]).to.equal('warn')
- expect(exports.prettyLog.getCall(3).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 3000ms ...`)
- clock.tick(3010)
- expect(exports.prettyLog.getCall(4).args[0]).to.equal('status')
- expect(exports.prettyLog.getCall(4).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 3`)
- expect(exports.prettyLog.getCall(5).args[0]).to.equal('warn')
- expect(exports.prettyLog.getCall(5).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 5000ms ...`)
- clock.tick(5010)
- expect(exports.prettyLog.getCall(6).args[0]).to.equal('status')
- expect(exports.prettyLog.getCall(6).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 4`)
- expect(exports.prettyLog.getCall(7).args[0]).to.equal('warn')
- expect(exports.prettyLog.getCall(7).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 10000ms ...`)
- clock.tick(10010)
- expect(exports.prettyLog.getCall(8).args[0]).to.equal('error')
- expect(exports.prettyLog.getCall(8).args[1]).to.equal(`Aggregator still hasn't loaded. Processing que stopped`)
- expect(exports.queuePointer).to.equal(0)
- expect(exports.processEvents.callCount).to.equal(5)
- })
-
- it('Should retry processing slotRenderEnded in certain intervals', () => {
- expect(exports.queuePointer).to.equal(0)
- expect(exports.retryCount).to.equal(0)
- const que = [['slotRenderEnded', {type: 'slotRenderEnded'}]]
- exports.__atmtdAnalyticsQueue.push(que[0])
- exports.processEvents()
- expect(exports.prettyLog.getCall(0).args[0]).to.equal('status')
- expect(exports.prettyLog.getCall(0).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 1`)
- expect(exports.prettyLog.getCall(1).args[0]).to.equal('warn')
- expect(exports.prettyLog.getCall(1).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 1500ms ...`)
- clock.tick(1510)
- expect(exports.prettyLog.getCall(2).args[0]).to.equal('status')
- expect(exports.prettyLog.getCall(2).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 2`)
- expect(exports.prettyLog.getCall(3).args[0]).to.equal('warn')
- expect(exports.prettyLog.getCall(3).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 3000ms ...`)
- clock.tick(3010)
- expect(exports.prettyLog.getCall(4).args[0]).to.equal('status')
- expect(exports.prettyLog.getCall(4).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 3`)
- expect(exports.prettyLog.getCall(5).args[0]).to.equal('warn')
- expect(exports.prettyLog.getCall(5).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 5000ms ...`)
- clock.tick(5010)
- expect(exports.prettyLog.getCall(6).args[0]).to.equal('status')
- expect(exports.prettyLog.getCall(6).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 4`)
- expect(exports.prettyLog.getCall(7).args[0]).to.equal('warn')
- expect(exports.prettyLog.getCall(7).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 10000ms ...`)
- clock.tick(10010)
- expect(exports.prettyLog.getCall(8).args[0]).to.equal('error')
- expect(exports.prettyLog.getCall(8).args[1]).to.equal(`Aggregator still hasn't loaded. Processing que stopped`)
- expect(exports.queuePointer).to.equal(0)
- expect(exports.processEvents.callCount).to.equal(5)
- })
-
- it('Should retry processing impressionViewable in certain intervals', () => {
- expect(exports.queuePointer).to.equal(0)
- expect(exports.retryCount).to.equal(0)
- const que = [['impressionViewable', {type: 'impressionViewable'}]]
- exports.__atmtdAnalyticsQueue.push(que[0])
- exports.processEvents()
- expect(exports.prettyLog.getCall(0).args[0]).to.equal('status')
- expect(exports.prettyLog.getCall(0).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 1`)
- expect(exports.prettyLog.getCall(1).args[0]).to.equal('warn')
- expect(exports.prettyLog.getCall(1).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 1500ms ...`)
- clock.tick(1510)
- expect(exports.prettyLog.getCall(2).args[0]).to.equal('status')
- expect(exports.prettyLog.getCall(2).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 2`)
- expect(exports.prettyLog.getCall(3).args[0]).to.equal('warn')
- expect(exports.prettyLog.getCall(3).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 3000ms ...`)
- clock.tick(3010)
- expect(exports.prettyLog.getCall(4).args[0]).to.equal('status')
- expect(exports.prettyLog.getCall(4).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 3`)
- expect(exports.prettyLog.getCall(5).args[0]).to.equal('warn')
- expect(exports.prettyLog.getCall(5).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 5000ms ...`)
- clock.tick(5010)
- expect(exports.prettyLog.getCall(6).args[0]).to.equal('status')
- expect(exports.prettyLog.getCall(6).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 4`)
- expect(exports.prettyLog.getCall(7).args[0]).to.equal('warn')
- expect(exports.prettyLog.getCall(7).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 10000ms ...`)
- clock.tick(10010)
- expect(exports.prettyLog.getCall(8).args[0]).to.equal('error')
- expect(exports.prettyLog.getCall(8).args[1]).to.equal(`Aggregator still hasn't loaded. Processing que stopped`)
- expect(exports.queuePointer).to.equal(0)
- expect(exports.processEvents.callCount).to.equal(5)
- })
- });
-
- describe('Process Events from Que when SDK has loaded', () => {
- before(() => {
- spec.enableAnalytics({
- provider: 'atmtdAnalyticsAdapter',
- options: {
- publisherID: '230',
- siteID: '421'
- }
- });
- sandbox = sinon.createSandbox();
- const obj = {
- auctionInitHandler: (args) => {},
- bidResponseHandler: (args) => {},
- bidderDoneHandler: (args) => {},
- bidWonHandler: (args) => {},
- noBidHandler: (args) => {},
- auctionDebugHandler: (args) => {},
- bidderTimeoutHandler: (args) => {},
- impressionViewableHandler: (args) => {},
- slotRenderEndedGPTHandler: (args) => {},
- bidRequestedHandler: (args) => {},
- bidRejectedHandler: (args) => {}
- }
-
- global.window.atmtdAnalytics = obj;
-
- Object.keys(obj).forEach((fn) => sandbox.spy(global.window.atmtdAnalytics, fn))
- sandbox.stub(events, 'getEvents').returns([]);
- sandbox.spy(exports, 'prettyLog')
- exports.retryCount = 0;
- exports.queuePointer = 0;
- exports.__atmtdAnalyticsQueue = [
- [AUCTION_INIT, {type: AUCTION_INIT}],
- [BID_RESPONSE, {type: BID_RESPONSE}],
- [BID_REQUESTED, {type: BID_REQUESTED}],
- [BID_REJECTED, {type: BID_REJECTED}],
- [NO_BID, {type: NO_BID}],
- [BID_WON, {type: BID_WON}],
- [BIDDER_DONE, {type: BIDDER_DONE}],
- [AUCTION_DEBUG, {type: AUCTION_DEBUG}],
- [BID_TIMEOUT, {type: BID_TIMEOUT}],
- ['slotRenderEnded', {type: 'slotRenderEnded'}],
- ['impressionViewable', {type: 'impressionViewable'}]
- ]
- });
- afterEach(() => {
- sandbox.restore();
- })
- after(() => {
- spec.disableAnalytics();
- })
-
- it('Should make calls to appropriate SDK event handlers', () => {
- exports.processEvents()
- expect(exports.prettyLog.getCall(0).args[0]).to.equal('status')
- expect(exports.prettyLog.getCall(0).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 1`)
- expect(exports.retryCount).to.equal(0)
- expect(exports.prettyLog.callCount).to.equal(1)
- expect(exports.queuePointer).to.equal(exports.__atmtdAnalyticsQueue.length)
- expect(global.window.atmtdAnalytics.auctionInitHandler.calledOnce).to.equal(true)
- expect(global.window.atmtdAnalytics.bidResponseHandler.calledOnce).to.equal(true)
- expect(global.window.atmtdAnalytics.bidRejectedHandler.calledOnce).to.equal(true)
- expect(global.window.atmtdAnalytics.bidRequestedHandler.calledOnce).to.equal(true)
- expect(global.window.atmtdAnalytics.noBidHandler.calledOnce).to.equal(true)
- expect(global.window.atmtdAnalytics.bidWonHandler.calledOnce).to.equal(true)
- expect(global.window.atmtdAnalytics.auctionDebugHandler.calledOnce).to.equal(true)
- expect(global.window.atmtdAnalytics.bidderTimeoutHandler.calledOnce).to.equal(true)
- expect(global.window.atmtdAnalytics.bidderDoneHandler.calledOnce).to.equal(true)
- expect(global.window.atmtdAnalytics.slotRenderEndedGPTHandler.calledOnce).to.equal(true)
- expect(global.window.atmtdAnalytics.impressionViewableHandler.calledOnce).to.equal(true)
- })
- });
-
- describe('Prettylog fn tests', () => {
- beforeEach(() => {
- sandbox = sinon.createSandbox()
- sandbox.spy(utils, 'logInfo')
- sandbox.spy(utils, 'logError')
- exports.isLoggingEnabled = true
- })
-
- afterEach(() => {
- sandbox.restore()
- })
-
- it('Should call logMessage once in normal mode', () => {
- exports.prettyLog('status', 'Hello world')
- expect(utils.logInfo.callCount).to.equal(1)
- })
-
- it('Should call logMessage twice in group mode and have the cb called', () => {
- const spy = sandbox.spy()
- exports.prettyLog('status', 'Hello world', true, spy)
- expect(utils.logInfo.callCount).to.equal(2)
- expect(spy.called).to.equal(true)
- })
-
- it('Should call logMessage twice in group mode and have the cb which throws an error', () => {
- const spy = sandbox.stub().throws()
- exports.prettyLog('status', 'Hello world', true, spy)
- expect(utils.logInfo.callCount).to.equal(2)
- expect(utils.logError.called).to.equal(true)
- })
- });
-});
diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js
deleted file mode 100644
index 050563d72..000000000
--- a/test/spec/modules/automatadBidAdapter_spec.js
+++ /dev/null
@@ -1,242 +0,0 @@
-import { expect } from 'chai'
-import { spec } from 'modules/automatadBidAdapter.js'
-import { newBidder } from 'src/adapters/bidderFactory.js'
-
-describe('automatadBidAdapter', function () {
- const adapter = newBidder(spec)
-
- const bidRequestRequiredParams = {
- bidder: 'automatad',
- params: {siteId: '123ad'},
- mediaTypes: {
- banner: {
- sizes: [[300, 600]],
- }
- },
- adUnitCode: 'some-ad-unit-code',
- transactionId: '1465569e-52cc-4c36-88a1-7174cfef4b44',
- sizes: [[300, 600]],
- bidId: '123abc',
- bidderRequestId: '3213887463c059',
- auctionId: 'abc-123',
- src: 'client',
- bidRequestsCount: 1
- }
-
- const bidRequestAllParams = {
- bidder: 'automatad',
- params: {siteId: '123ad', placementId: '123abc345'},
- mediaTypes: {
- banner: {
- sizes: [[300, 600]],
- }
- },
- adUnitCode: 'some-ad-unit-code',
- transactionId: '1465569e-52cc-4c36-88a1-7174cfef4b44',
- sizes: [[300, 600]],
- bidId: '123abc',
- bidderRequestId: '3213887463c059',
- auctionId: 'abc-123',
- src: 'client',
- bidRequestsCount: 1
- }
-
- const expectedResponse = [{
- 'body': {
- 'id': 'abc-123',
- 'seatbid': [
- {
- 'bid': [
- {
- 'bidId': '123',
- 'adm': '',
- 'adomain': [
- 'someAdDomain'
- ],
- 'crid': 123,
- 'h': 600,
- 'id': 'bid1',
- 'impid': '1',
- 'nurl': 'https://example/win',
- 'price': 0.5,
- 'w': 300
- }
- ]
- }
- ]
- }
- }]
-
- describe('codes', function () {
- it('should return a bidder code of automatad', function () {
- expect(spec.code).to.equal('automatad')
- })
- it('should alias atd', function () {
- expect(spec.aliases.length > 0 && spec.aliases[0] === 'atd').to.be.true
- })
- })
-
- describe('isBidRequestValid', function () {
- const inValidBid = Object.assign({}, bidRequestRequiredParams)
- delete inValidBid.params
- it('should return true if all params present', function () {
- expect(spec.isBidRequestValid(bidRequestAllParams)).to.equal(true)
- })
-
- it('should return true if only required params present', function() {
- expect(spec.isBidRequestValid(bidRequestRequiredParams)).to.equal(true)
- })
-
- it('should return false if any parameter missing', function () {
- expect(spec.isBidRequestValid(inValidBid)).to.be.false
- })
- })
-
- describe('buildRequests', function () {
- const req = spec.buildRequests([ bidRequestRequiredParams ], { refererInfo: { } })
- let rdata
-
- it('should have withCredentials option as true', function() {
- expect(req.options.withCredentials).to.equal(true)
- })
-
- it('should return request object', function () {
- expect(req).to.not.be.null
- })
-
- it('should build request data', function () {
- expect(req.data).to.not.be.null
- })
-
- it('should include one request', function () {
- rdata = JSON.parse(req.data)
- expect(rdata.imp.length).to.equal(1)
- })
-
- it('should include siteId', function () {
- const r = rdata.imp[0]
- expect(r.siteId !== null).to.be.true
- })
-
- it('should include media types', function () {
- const r = rdata.imp[0]
- expect(r.media_types !== null).to.be.true
- })
-
- it('should include adunit code', function () {
- const r = rdata.imp[0]
- expect(r.adUnitCode !== null).to.be.true
- })
- })
-
- describe('interpretResponse', function () {
- it('should get the correct bid response', function () {
- const result = spec.interpretResponse(expectedResponse[0])
- expect(result).to.be.an('array').that.is.not.empty
- expect(result[0].meta.advertiserDomains[0]).to.equal('someAdDomain');
- })
-
- it('should interpret multiple bids in seatbid', function () {
- const multipleBidResponse = [{
- 'body': {
- 'id': 'abc-321',
- 'seatbid': [
- {
- 'bid': [
- {
- 'adm': '',
- 'adomain': [
- 'someAdDomain'
- ],
- 'crid': 123,
- 'h': 600,
- 'id': 'bid1',
- 'impid': 'imp1',
- 'nurl': 'https://example/win',
- 'price': 0.5,
- 'w': 300
- }
- ]
- }, {
- 'bid': [
- {
- 'adm': '',
- 'adomain': [
- 'someAdDomain'
- ],
- 'crid': 321,
- 'h': 600,
- 'id': 'bid1',
- 'impid': 'imp2',
- 'nurl': 'https://example/win',
- 'price': 0.5,
- 'w': 300
- }
- ]
- }
- ]
- }
- }]
- const result = spec.interpretResponse(multipleBidResponse[0]).map(bid => {
- const {requestId} = bid;
- return [ requestId ];
- });
-
- assert.equal(result.length, 2);
- assert.deepEqual(result, [[ 'imp1' ], [ 'imp2' ]]);
- })
-
- it('handles empty bid response', function () {
- const response = {
- body: ''
- }
- const result = spec.interpretResponse(response)
- expect(result.length).to.equal(0)
- })
- })
-
- describe('onTimeout', function () {
- const timeoutData = {
- 'bidId': '123',
- 'bidder': 'automatad',
- 'adUnitCode': 'div-13',
- 'auctionId': '1232',
- 'params': [
- {
- 'siteId': 'test',
- 'placementId': 'test123'
- }
- ],
- 'timeout': 1000
- }
-
- it('should exists and be a function', function () {
- expect(spec.onTimeout).to.exist.and.to.be.a('function');
- });
-
- it('should include timeoutData', function () {
- expect(spec.onTimeout(timeoutData)).to.be.undefined;
- })
- });
-
- describe('onBidWon', function () {
- const serverResponses = spec.interpretResponse(expectedResponse[0])
- const wonbid = serverResponses[0]
- let ajaxStub
-
- beforeEach(() => {
- ajaxStub = sinon.stub(spec, 'ajaxCall')
- })
-
- afterEach(() => {
- ajaxStub.restore()
- })
-
- it('Returns true is nurl is good/not blank', function () {
- expect(wonbid.nurl).to.not.equal('')
- expect(spec.onBidWon(wonbid)).to.be.true
- expect(ajaxStub.calledOnce).to.equal(true)
- expect(ajaxStub.firstCall.args[0].indexOf('https://')).to.equal(0)
- })
- })
-})
diff --git a/test/spec/modules/axisBidAdapter_spec.js b/test/spec/modules/axisBidAdapter_spec.js
deleted file mode 100644
index 069e18340..000000000
--- a/test/spec/modules/axisBidAdapter_spec.js
+++ /dev/null
@@ -1,481 +0,0 @@
-import { expect } from 'chai';
-import { spec } from '../../../modules/axisBidAdapter.js';
-import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js';
-import { getUniqueIdentifierStr } from '../../../src/utils.js';
-
-const bidder = 'axis';
-
-describe('AxisBidAdapter', function () {
- const userIdAsEids = [{
- source: 'test.org',
- uids: [{
- id: '01**********',
- atype: 1,
- ext: {
- third: '01***********'
- }
- }]
- }];
- const bids = [
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]],
- pos: 1
- }
- },
- params: {
- integration: '000000',
- token: '000000'
- },
- userIdAsEids
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [VIDEO]: {
- playerSize: [[300, 300]],
- minduration: 5,
- maxduration: 60,
- pos: 1
- }
- },
- params: {
- integration: '000000',
- token: '000000'
- },
- userIdAsEids
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [NATIVE]: {
- native: {
- title: {
- required: true
- },
- body: {
- required: true
- },
- icon: {
- required: true,
- size: [64, 64]
- }
- }
- }
- },
- params: {
- integration: '000000',
- token: '000000'
- },
- userIdAsEids
- }
- ];
-
- const invalidBid = {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
-
- }
- }
-
- const bidderRequest = {
- uspConsent: '1---',
- gdprConsent: {
- consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw',
- vendorData: {}
- },
- refererInfo: {
- referer: 'https://test.com',
- page: 'https://test.com'
- },
- ortb2: {
- site: {
- cat: ['IAB24']
- },
- device: {
- w: 1512,
- h: 982,
- language: 'en-UK'
- }
- },
- timeout: 500
- };
-
- describe('isBidRequestValid', function () {
- it('Should return true if there are bidId, params and key parameters present', function () {
- expect(spec.isBidRequestValid(bids[0])).to.be.true;
- });
- it('Should return false if at least one of parameters is not present', function () {
- expect(spec.isBidRequestValid(invalidBid)).to.be.false;
- });
- });
-
- describe('buildRequests', function () {
- let serverRequest = spec.buildRequests(bids, bidderRequest);
-
- it('Creates a ServerRequest object with method, URL and data', function () {
- expect(serverRequest).to.exist;
- expect(serverRequest.method).to.exist;
- expect(serverRequest.url).to.exist;
- expect(serverRequest.data).to.exist;
- });
-
- it('Returns POST method', function () {
- expect(serverRequest.method).to.equal('POST');
- });
-
- it('Returns valid URL', function () {
- expect(serverRequest.url).to.equal('https://prebid.axis-marketplace.com/pbjs');
- });
-
- it('Returns general data valid', function () {
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.all.keys('deviceWidth',
- 'deviceHeight',
- 'device',
- 'language',
- 'secure',
- 'host',
- 'page',
- 'placements',
- 'iabCat',
- 'coppa',
- 'ccpa',
- 'gdpr',
- 'tmax',
- 'bcat',
- 'badv',
- 'bapp',
- 'battr'
- );
- expect(data.deviceWidth).to.be.a('number');
- expect(data.deviceHeight).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');
- expect(data.page).to.be.a('string');
- expect(data.coppa).to.be.a('number');
- expect(data.gdpr).to.be.a('object');
- expect(data.ccpa).to.be.a('string');
- expect(data.tmax).to.be.a('number');
- expect(data.iabCat).to.have.lengthOf(1);
- expect(data.placements).to.have.lengthOf(3);
- });
-
- it('Returns valid placements', function () {
- const { placements } = serverRequest.data;
- for (let i = 0, len = placements.length; i < len; i++) {
- const placement = placements[i];
- expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]);
- expect(placement.bidId).to.be.a('string');
- expect(placement.integration).to.be.a('string');
- expect(placement.token).to.be.a('string');
- expect(placement.schain).to.be.an('object');
- expect(placement.bidfloor).to.exist.and.to.equal(0);
- expect(placement.eids).to.exist.and.to.be.deep.equal(userIdAsEids);
-
- if (placement.adFormat === BANNER) {
- expect(placement.sizes).to.be.an('array');
- }
- switch (placement.adFormat) {
- case BANNER:
- expect(placement.sizes).to.be.an('array');
- expect(placement.pos).to.be.within(0, 7);
- break;
- case VIDEO:
- expect(placement.playerSize).to.be.an('array');
- expect(placement.minduration).to.be.an('number');
- expect(placement.maxduration).to.be.an('number');
- expect(placement.pos).to.be.within(0, 7);
- break;
- case NATIVE:
- expect(placement.native).to.be.an('object');
- break;
- }
- }
- });
-
- it('Returns data with gdprConsent and without uspConsent', function () {
- delete bidderRequest.uspConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.gdpr).to.exist;
- expect(data.gdpr).to.be.a('object');
- expect(data.gdpr).to.have.property('consentString');
- expect(data.gdpr).to.not.have.property('vendorData');
- expect(data.gdpr.consentString).to.equal(bidderRequest.gdprConsent.consentString);
- expect(data.ccpa).to.not.exist;
- delete bidderRequest.gdprConsent;
- });
-
- it('Returns data with uspConsent and without gdprConsent', function () {
- bidderRequest.uspConsent = '1---';
- delete bidderRequest.gdprConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.ccpa).to.exist;
- expect(data.ccpa).to.be.a('string');
- expect(data.ccpa).to.equal(bidderRequest.uspConsent);
- expect(data.gdpr).to.not.exist;
- });
- });
-
- describe('gpp consent', function () {
- it('bidderRequest.gppConsent', () => {
- bidderRequest.gppConsent = {
- gppString: 'abc123',
- applicableSections: [8]
- };
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
-
- delete bidderRequest.gppConsent;
- })
-
- it('bidderRequest.ortb2.regs.gpp', () => {
- bidderRequest.ortb2 = bidderRequest.ortb2 || {};
- bidderRequest.ortb2.regs = bidderRequest.ortb2.regs || {};
- bidderRequest.ortb2.regs.gpp = 'abc123';
- bidderRequest.ortb2.regs.gpp_sid = [8];
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
- })
- });
-
- describe('interpretResponse', function () {
- it('Should interpret banner response', function () {
- const banner = {
- body: [{
- mediaType: 'banner',
- width: 300,
- height: 250,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const bannerResponses = spec.interpretResponse(banner);
- expect(bannerResponses).to.be.an('array').that.is.not.empty;
- const dataItem = bannerResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal(banner.body[0].requestId);
- expect(dataItem.cpm).to.equal(banner.body[0].cpm);
- expect(dataItem.width).to.equal(banner.body[0].width);
- expect(dataItem.height).to.equal(banner.body[0].height);
- expect(dataItem.ad).to.equal(banner.body[0].ad);
- expect(dataItem.ttl).to.equal(banner.body[0].ttl);
- expect(dataItem.creativeId).to.equal(banner.body[0].creativeId);
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal(banner.body[0].currency);
- expect(dataItem.meta).to.be.an('object').that.has.property('advertiserDomains');
- });
- it('Should interpret video response', function () {
- const video = {
- body: [{
- vastUrl: 'test.com',
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- width: 300,
- height: 250,
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const videoResponses = spec.interpretResponse(video);
- expect(videoResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = videoResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta', 'width', 'height');
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.5);
- expect(dataItem.vastUrl).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.property('advertiserDomains');
- });
- it('Should interpret native response', function () {
- const native = {
- body: [{
- mediaType: 'native',
- native: {
- clickUrl: 'test.com',
- title: 'Test',
- image: 'test.com',
- impressionTrackers: ['test.com'],
- },
- ttl: 120,
- cpm: 0.4,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const nativeResponses = spec.interpretResponse(native);
- expect(nativeResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = nativeResponses[0];
- expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta');
- expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image')
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.4);
- expect(dataItem.native.clickUrl).to.equal('test.com');
- expect(dataItem.native.title).to.equal('Test');
- expect(dataItem.native.image).to.equal('test.com');
- expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty;
- expect(dataItem.native.impressionTrackers[0]).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.property('advertiserDomains');
- });
- it('Should return an empty array if invalid banner response is passed', function () {
- const invBanner = {
- body: [{
- width: 300,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
-
- const serverResponses = spec.interpretResponse(invBanner);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid video response is passed', function () {
- const invVideo = {
- body: [{
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invVideo);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid native response is passed', function () {
- const invNative = {
- body: [{
- mediaType: 'native',
- clickUrl: 'test.com',
- title: 'Test',
- impressionTrackers: ['test.com'],
- ttl: 120,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- }]
- };
- const serverResponses = spec.interpretResponse(invNative);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid response is passed', function () {
- const invalid = {
- body: [{
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invalid);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- });
-
- describe('getUserSyncs', function() {
- it('Should return array of objects with proper sync config , include GDPR', function() {
- const syncData = spec.getUserSyncs({}, {}, {
- consentString: 'ALL',
- gdprApplies: true,
- }, {});
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://cs.axis-marketplace.com/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0')
- });
- it('Should return array of objects with proper sync config , include CCPA', function() {
- const syncData = spec.getUserSyncs({}, {}, {}, {
- consentString: '1---'
- });
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://cs.axis-marketplace.com/image?pbjs=1&ccpa=1---&coppa=0')
- });
- it('Should return array of objects with proper sync config , include GPP', function() {
- const syncData = spec.getUserSyncs({}, {}, {}, {}, {
- gppString: 'abc123',
- applicableSections: [8]
- });
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://cs.axis-marketplace.com/image?pbjs=1&gpp=abc123&gpp_sid=8&coppa=0')
- });
- });
-});
diff --git a/test/spec/modules/axonixBidAdapter_spec.js b/test/spec/modules/axonixBidAdapter_spec.js
deleted file mode 100644
index 5fd28204d..000000000
--- a/test/spec/modules/axonixBidAdapter_spec.js
+++ /dev/null
@@ -1,351 +0,0 @@
-import { expect } from 'chai';
-import { spec } from 'modules/axonixBidAdapter';
-import { newBidder } from 'src/adapters/bidderFactory';
-import * as utils from 'src/utils';
-
-describe('AxonixBidAdapter', function () {
- const adapter = newBidder(spec);
-
- const SUPPLY_ID_1 = '91fd110a-5685-11eb-8db6-a7e0eeefbbc7';
- const SUPPLY_ID_2 = '22de2092-568b-11eb-bae3-cfa975dc72aa';
- const REGION_1 = 'us-east-1';
- const REGION_2 = 'eu-west-1';
-
- const BANNER_REQUEST = {
- adUnitCode: 'ad_code',
- bidId: 'abcd1234',
- mediaTypes: {
- banner: {
- sizes: [
- [300, 250],
- [300, 200]
- ]
- }
- },
- bidder: 'axonix',
- params: {
- supplyId: SUPPLY_ID_1,
- region: REGION_1
- },
- requestId: 'q4owht8ofqi3ulwsd',
- transactionId: 'fvpq3oireansdwo'
- };
-
- const VIDEO_REQUEST = {
- adUnitCode: 'ad_code',
- bidId: 'abcd1234',
- mediaTypes: {
- video: {
- context: 'outstream',
- mimes: ['video/mp4'],
- playerSize: [400, 300],
- renderer: {
- url: 'https://url.com',
- backupOnly: true,
- render: () => true
- },
- }
- },
- bidder: 'axonix',
- params: {
- supplyId: SUPPLY_ID_1,
- region: REGION_1
- },
- requestId: 'q4owht8ofqi3ulwsd',
- transactionId: 'fvpq3oireansdwo'
- };
-
- const BIDDER_REQUEST = {
- bidderCode: 'axonix',
- auctionId: '18fd8b8b0bd757',
- bidderRequestId: '418b37f85e772c',
- timeout: 3000,
- gdprConsent: {
- consentString: 'BOKAVy4OKAVy4ABAB8AAAAAZ+A==',
- gdprApplies: true
- },
- refererInfo: {
- page: 'https://www.prebid.org',
- canonicalUrl: 'https://www.prebid.org/the/link/to/the/page'
- }
- };
-
- const BANNER_RESPONSE = {
- body: [{
- requestId: 'f08b3a8dcff747eabada295dcf94eee0',
- cpm: 6,
- currency: 'USD',
- width: 300,
- height: 250,
- ad: '',
- creativeId: 'abc',
- netRevenue: false,
- meta: {
- networkId: 'nid',
- advertiserDomains: [
- 'https://the.url'
- ],
- secondaryCatIds: [
- 'IAB1'
- ],
- mediaType: 'banner'
- },
- nurl: 'https://win.url'
- }]
- };
-
- const VIDEO_RESPONSE = {
- body: [{
- requestId: 'f08b3a8dcff747eabada295dcf94eee0',
- cpm: 6,
- currency: 'USD',
- width: 300,
- height: 250,
- ad: '
',
- creativeId: 'abc',
- netRevenue: false,
- meta: {
- networkId: 'nid',
- advertiserDomains: [
- 'https://the.url'
- ],
- secondaryCatIds: [
- 'IAB1'
- ],
- mediaType: 'video'
- },
- nurl: 'https://win.url'
- }]
- };
-
- describe('inherited functions', function () {
- it('exists and is a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('isBidRequestValid', function () {
- const validBids = [
- {
- bidder: 'axonix',
- params: {
- supplyId: SUPPLY_ID_1,
- region: REGION_1
- },
- },
- {
- bidder: 'axonix',
- params: {
- supplyId: SUPPLY_ID_2,
- region: REGION_2
- },
- future_parameter: {
- future: 'ididid'
- }
- },
- ];
-
- const invalidBids = [
- {
- bidder: 'axonix',
- params: {},
- },
- {
- bidder: 'axonix',
- },
- ];
-
- it('should accept valid bids', function () {
- for (const bid of validBids) {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- }
- });
-
- it('should reject invalid bids', function () {
- for (const bid of invalidBids) {
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- }
- });
- });
-
- describe('buildRequests: can handle banner ad requests', function () {
- it('creates ServerRequests with the correct data', function () {
- const [request] = spec.buildRequests([BANNER_REQUEST], BIDDER_REQUEST);
-
- expect(request).to.have.property('url', `https://openrtb-${REGION_1}.axonix.com/supply/prebid/${SUPPLY_ID_1}`);
- expect(request).to.have.property('method', 'POST');
- expect(request).to.have.property('data');
-
- const { data } = request;
- expect(data.app).to.be.undefined;
-
- expect(data).to.have.property('site');
- expect(data.site).to.have.property('page', 'https://www.prebid.org');
-
- expect(data).to.have.property('validBidRequest', BANNER_REQUEST);
- expect(data).to.have.property('connectionType').to.exist;
- expect(data).to.have.property('effectiveType').to.exist;
- expect(data).to.have.property('devicetype', 2);
- expect(data).to.have.property('bidfloor', 0);
- expect(data).to.have.property('dnt', 0);
- expect(data).to.have.property('language').to.be.a('string');
- expect(data).to.have.property('prebidVersion').to.be.a('string');
- expect(data).to.have.property('screenHeight').to.be.a('number');
- expect(data).to.have.property('screenWidth').to.be.a('number');
- expect(data).to.have.property('tmax').to.be.a('number');
- expect(data).to.have.property('ua').to.be.a('string');
- });
-
- it('creates ServerRequests pointing to the correct region and endpoint if it changes', function () {
- const bannerRequests = [utils.deepClone(BANNER_REQUEST), utils.deepClone(BANNER_REQUEST)];
- bannerRequests[0].params.endpoint = 'https://the.url';
- bannerRequests[1].params.endpoint = 'https://the.other.url';
-
- const requests = spec.buildRequests(bannerRequests, BIDDER_REQUEST);
-
- requests.forEach((request, index) => {
- expect(request).to.have.property('url', bannerRequests[index].params.endpoint);
- });
- });
-
- it('creates ServerRequests pointing to default endpoint if missing', function () {
- const bannerRequests = [utils.deepClone(BANNER_REQUEST), utils.deepClone(BANNER_REQUEST)];
- bannerRequests[1].params.supplyId = SUPPLY_ID_2;
- bannerRequests[1].params.region = REGION_2;
-
- const requests = spec.buildRequests(bannerRequests, BIDDER_REQUEST);
- expect(requests[0]).to.have.property('url', `https://openrtb-${REGION_1}.axonix.com/supply/prebid/${SUPPLY_ID_1}`);
- expect(requests[1]).to.have.property('url', `https://openrtb-${REGION_2}.axonix.com/supply/prebid/${SUPPLY_ID_2}`);
- });
-
- it('creates ServerRequests pointing to default region if missing', function () {
- const bannerRequest = utils.deepClone(BANNER_REQUEST);
- delete bannerRequest.params.region;
-
- const requests = spec.buildRequests([bannerRequest], BIDDER_REQUEST);
- expect(requests[0]).to.have.property('url', `https://openrtb-${REGION_1}.axonix.com/supply/prebid/${SUPPLY_ID_1}`);
- });
- });
-
- describe('buildRequests: can handle video ad requests', function () {
- it('creates ServerRequests with the correct data', function () {
- const [request] = spec.buildRequests([VIDEO_REQUEST], BIDDER_REQUEST);
-
- expect(request).to.have.property('url', `https://openrtb-${REGION_1}.axonix.com/supply/prebid/${SUPPLY_ID_1}`);
- expect(request).to.have.property('method', 'POST');
- expect(request).to.have.property('data');
-
- const { data } = request;
- expect(data.app).to.be.undefined;
-
- expect(data).to.have.property('site');
- expect(data.site).to.have.property('page', 'https://www.prebid.org');
-
- expect(data).to.have.property('validBidRequest', VIDEO_REQUEST);
- expect(data).to.have.property('connectionType').to.exist;
- expect(data).to.have.property('effectiveType').to.exist;
- expect(data).to.have.property('devicetype', 2);
- expect(data).to.have.property('bidfloor', 0);
- expect(data).to.have.property('dnt', 0);
- expect(data).to.have.property('language').to.be.a('string');
- expect(data).to.have.property('prebidVersion').to.be.a('string');
- expect(data).to.have.property('screenHeight').to.be.a('number');
- expect(data).to.have.property('screenWidth').to.be.a('number');
- expect(data).to.have.property('tmax').to.be.a('number');
- expect(data).to.have.property('ua').to.be.a('string');
- });
-
- it('creates ServerRequests pointing to the correct region and endpoint if it changes', function () {
- const videoRequests = [utils.deepClone(VIDEO_REQUEST), utils.deepClone(VIDEO_REQUEST)];
- videoRequests[0].params.endpoint = 'https://the.url';
- videoRequests[1].params.endpoint = 'https://the.other.url';
-
- const requests = spec.buildRequests(videoRequests, BIDDER_REQUEST);
-
- requests.forEach((request, index) => {
- expect(request).to.have.property('url', videoRequests[index].params.endpoint);
- });
- });
-
- it('creates ServerRequests pointing to default endpoint if missing', function () {
- const videoRequests = [utils.deepClone(VIDEO_REQUEST), utils.deepClone(VIDEO_REQUEST)];
- videoRequests[1].params.supplyId = SUPPLY_ID_2;
- videoRequests[1].params.region = REGION_2;
-
- const requests = spec.buildRequests(videoRequests, BIDDER_REQUEST);
- expect(requests[0]).to.have.property('url', `https://openrtb-${REGION_1}.axonix.com/supply/prebid/${SUPPLY_ID_1}`);
- expect(requests[1]).to.have.property('url', `https://openrtb-${REGION_2}.axonix.com/supply/prebid/${SUPPLY_ID_2}`);
- });
-
- it('creates ServerRequests pointing to default region if missing', function () {
- const videoRequest = utils.deepClone(VIDEO_REQUEST);
- delete videoRequest.params.region;
-
- const requests = spec.buildRequests([videoRequest], BIDDER_REQUEST);
- expect(requests[0]).to.have.property('url', `https://openrtb-${REGION_1}.axonix.com/supply/prebid/${SUPPLY_ID_1}`);
- });
- });
-
- describe('interpretResponse', function () {
- it('considers corner cases', function() {
- expect(spec.interpretResponse(null)).to.be.an('array').that.is.empty;
- expect(spec.interpretResponse()).to.be.an('array').that.is.empty;
- });
-
- it('ignores unparseable responses', function() {
- expect(spec.interpretResponse('invalid')).to.be.an('array').that.is.empty;
- expect(spec.interpretResponse(['invalid'])).to.be.an('array').that.is.empty;
- expect(spec.interpretResponse({ body: [{ invalid: 'object' }] })).to.be.an('array').that.is.empty;
- });
-
- it('parses banner responses', function () {
- const response = spec.interpretResponse(BANNER_RESPONSE);
-
- expect(response).to.be.an('array').that.is.not.empty;
- expect(response[0]).to.equal(BANNER_RESPONSE.body[0]);
- });
-
- it('parses 1 video responses', function () {
- const response = spec.interpretResponse(VIDEO_RESPONSE);
-
- expect(response).to.be.an('array').that.is.not.empty;
- expect(response[0]).to.equal(VIDEO_RESPONSE.body[0]);
- });
- });
-
- describe('onBidWon', function () {
- beforeEach(function () {
- sinon.stub(utils, 'triggerPixel');
- });
-
- afterEach(function () {
- utils.triggerPixel.restore();
- });
-
- it('called once', function () {
- spec.onBidWon(BANNER_RESPONSE.body[0]);
- expect(utils.triggerPixel.calledOnce).to.equal(true);
- });
-
- it('called false', function () {
- spec.onBidWon({ cpm: '2.21' });
- expect(utils.triggerPixel.called).to.equal(false);
- });
-
- it('when there is no notification expected server side, none is called', function () {
- var response = spec.onBidWon({});
- expect(utils.triggerPixel.called).to.equal(false);
- expect(response).to.be.an('undefined')
- });
- });
-
- describe('onTimeout', function () {
- it('banner response', () => {
- spec.onTimeout(spec.interpretResponse(BANNER_RESPONSE));
- });
-
- it('video response', () => {
- spec.onTimeout(spec.interpretResponse(VIDEO_RESPONSE));
- });
- });
-});
diff --git a/test/spec/modules/azerionedgeRtdProvider_spec.js b/test/spec/modules/azerionedgeRtdProvider_spec.js
deleted file mode 100644
index 82f4bb46c..000000000
--- a/test/spec/modules/azerionedgeRtdProvider_spec.js
+++ /dev/null
@@ -1,198 +0,0 @@
-import { config } from 'src/config.js';
-import * as azerionedgeRTD from 'modules/azerionedgeRtdProvider.js';
-import { loadExternalScriptStub } from 'test/mocks/adloaderStub.js';
-
-describe('Azerion Edge RTD submodule', function () {
- const STORAGE_KEY = 'ht-pa-v1-a';
- const USER_AUDIENCES = [
- { id: '1', visits: 123 },
- { id: '2', visits: 456 },
- ];
- const IMPROVEDIGITAL_GVLID = '253';
- const key = 'publisher123';
- const bidders = ['appnexus', 'improvedigital'];
- const process = { key: 'value' };
- const dataProvider = { name: 'azerionedge', waitForIt: true };
- const userConsent = {gdpr: {gdprApplies: 'gdpr-applies', consentString: 'consent-string'}, usp: 'usp'};
-
- const resetAll = () => {
- window.azerionPublisherAudiences.resetHistory();
- loadExternalScriptStub.resetHistory();
- }
-
- let reqBidsConfigObj;
- let storageStub;
-
- beforeEach(function () {
- config.resetConfig();
- reqBidsConfigObj = { ortb2Fragments: { bidder: {} } };
- window.azerionPublisherAudiences = sinon.spy();
- storageStub = sinon.stub(azerionedgeRTD.storage, 'getDataFromLocalStorage');
- });
-
- afterEach(function () {
- delete window.azerionPublisherAudiences;
- storageStub.restore();
- });
-
- describe('initialisation', function () {
- let returned;
-
- beforeEach(function () {
- returned = azerionedgeRTD.azerionedgeSubmodule.init(dataProvider, userConsent);
- });
-
- it('should have the correct gvlid', () => {
- expect(azerionedgeRTD.azerionedgeSubmodule.gvlid).to.equal(IMPROVEDIGITAL_GVLID);
- });
-
- it('should return true', function () {
- expect(returned).to.equal(true);
- });
-
- it('should load external script', function () {
- expect(loadExternalScriptStub.called).to.be.true;
- });
-
- it('should load external script with default versioned url', function () {
- const expected = 'https://edge.hyth.io/js/v1/azerion-edge.min.js';
- expect(loadExternalScriptStub.args[0][0]).to.deep.equal(expected);
- });
-
- [
- ['gdprApplies', userConsent.gdpr.gdprApplies],
- ['gdprConsent', userConsent.gdpr.consentString],
- ['uspConsent', userConsent.usp],
- ].forEach(([key, value]) => {
- it(`should call azerionPublisherAudiencesStub with ${key}:${value}`, function () {
- expect(window.azerionPublisherAudiences.args[0][0]).to.include({[key]: value});
- });
- });
-
- describe('with key', function () {
- beforeEach(function () {
- resetAll();
- const config = { ...dataProvider, params: { key } };
- returned = azerionedgeRTD.azerionedgeSubmodule.init(config, userConsent);
- });
-
- it('should return true', function () {
- expect(returned).to.equal(true);
- });
-
- it('should load external script with publisher id url', function () {
- const expected = `https://edge.hyth.io/js/v1/${key}/azerion-edge.min.js`;
- expect(loadExternalScriptStub.args[0][0]).to.deep.equal(expected);
- });
- });
-
- describe('with process configuration', function () {
- beforeEach(function () {
- resetAll();
- const config = { ...dataProvider, params: { process } };
- returned = azerionedgeRTD.azerionedgeSubmodule.init(config, userConsent);
- });
-
- it('should return true', function () {
- expect(returned).to.equal(true);
- });
-
- [
- ['gdprApplies', userConsent.gdpr.gdprApplies],
- ['gdprConsent', userConsent.gdpr.consentString],
- ['uspConsent', userConsent.usp],
- ...Object.entries(process),
- ].forEach(([key, value]) => {
- it(`should call azerionPublisherAudiencesStub with ${key}:${value}`, function () {
- expect(window.azerionPublisherAudiences.args[0][0]).to.include({[key]: value});
- });
- });
- });
- });
-
- describe('gets audiences', function () {
- let callbackStub;
-
- beforeEach(function () {
- callbackStub = sinon.mock();
- });
-
- describe('with empty storage', function () {
- beforeEach(function () {
- azerionedgeRTD.azerionedgeSubmodule.getBidRequestData(
- reqBidsConfigObj,
- callbackStub,
- dataProvider
- );
- });
-
- it('does not apply audiences to bidders', function () {
- expect(reqBidsConfigObj.ortb2Fragments.bidder).to.deep.equal({});
- });
-
- it('calls callback anyway', function () {
- expect(callbackStub.called).to.be.true;
- });
- });
-
- describe('with populate storage', function () {
- beforeEach(function () {
- storageStub
- .withArgs(STORAGE_KEY)
- .returns(JSON.stringify(USER_AUDIENCES));
- azerionedgeRTD.azerionedgeSubmodule.getBidRequestData(
- reqBidsConfigObj,
- callbackStub,
- dataProvider
- );
- });
-
- it('does apply audiences to bidder', function () {
- const segments =
- reqBidsConfigObj.ortb2Fragments.bidder['improvedigital'].user.data[0]
- .segment;
- expect(segments).to.deep.equal([{ id: '1' }, { id: '2' }]);
- });
-
- it('calls callback always', function () {
- expect(callbackStub.called).to.be.true;
- });
- });
- });
-
- describe('sets audiences in bidder', function () {
- const audiences = USER_AUDIENCES.map(({ id }) => id);
- const expected = {
- user: {
- data: [
- {
- ext: { segtax: 4 },
- name: 'azerionedge',
- segment: [{ id: '1' }, { id: '2' }],
- },
- ],
- },
- };
-
- it('for improvedigital by default', function () {
- azerionedgeRTD.setAudiencesToBidders(
- reqBidsConfigObj,
- dataProvider,
- audiences
- );
- expect(
- reqBidsConfigObj.ortb2Fragments.bidder['improvedigital']
- ).to.deep.equal(expected);
- });
-
- bidders.forEach((bidder) => {
- it(`for ${bidder}`, function () {
- const config = { ...dataProvider, params: { bidders } };
- azerionedgeRTD.setAudiencesToBidders(reqBidsConfigObj, config, audiences);
- expect(reqBidsConfigObj.ortb2Fragments.bidder[bidder]).to.deep.equal(
- expected
- );
- });
- });
- });
-});
diff --git a/test/spec/modules/beachfrontBidAdapter_spec.js b/test/spec/modules/beachfrontBidAdapter_spec.js
deleted file mode 100644
index a881928a0..000000000
--- a/test/spec/modules/beachfrontBidAdapter_spec.js
+++ /dev/null
@@ -1,1037 +0,0 @@
-import { expect } from 'chai';
-import { spec, VIDEO_ENDPOINT, BANNER_ENDPOINT, OUTSTREAM_SRC, DEFAULT_MIMES } from 'modules/beachfrontBidAdapter.js';
-import { parseUrl } from 'src/utils.js';
-
-describe('BeachfrontAdapter', function () {
- let bidRequests;
-
- beforeEach(function () {
- bidRequests = [
- {
- bidder: 'beachfront',
- params: {
- bidfloor: 2.00,
- appId: '3b16770b-17af-4d22-daff-9606bdf2c9c3'
- },
- adUnitCode: 'div-gpt-ad-1460505748561-0',
- bidId: '25186806a41eab',
- bidderRequestId: '15bdd8d4a0ebaf',
- auctionId: 'f17d62d0-e3e3-48d0-9f73-cb4ea358a309'
- }, {
- bidder: 'beachfront',
- params: {
- bidfloor: 1.00,
- appId: '11bc5dd5-7421-4dd8-c926-40fa653bec76'
- },
- adUnitCode: 'div-gpt-ad-1460505748561-1',
- bidId: '365088ee6d649d',
- bidderRequestId: '15bdd8d4a0ebaf',
- auctionId: 'f17d62d0-e3e3-48d0-9f73-cb4ea358a309'
- }
- ];
- });
-
- describe('spec.isBidRequestValid', function () {
- it('should return true when the required params are passed', function () {
- const bidRequest = bidRequests[0];
- expect(spec.isBidRequestValid(bidRequest)).to.equal(true);
- });
-
- it('should return false when the "bidfloor" param is missing', function () {
- const bidRequest = bidRequests[0];
- bidRequest.params = {
- appId: '11bc5dd5-7421-4dd8-c926-40fa653bec76'
- };
- expect(spec.isBidRequestValid(bidRequest)).to.equal(false);
- });
-
- it('should return false when the "appId" param is missing', function () {
- const bidRequest = bidRequests[0];
- bidRequest.params = {
- bidfloor: 5.00
- };
- expect(spec.isBidRequestValid(bidRequest)).to.equal(false);
- });
-
- it('should return false when no bid params are passed', function () {
- const bidRequest = bidRequests[0];
- bidRequest.params = {};
- expect(spec.isBidRequestValid(bidRequest)).to.equal(false);
- });
-
- it('should return false when a bid request is not passed', function () {
- expect(spec.isBidRequestValid()).to.equal(false);
- expect(spec.isBidRequestValid({})).to.equal(false);
- });
-
- describe('for multi-format bids', function () {
- it('should return true when the required params are passed for video', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- video: {}
- };
- bidRequest.params = {
- video: {
- bidfloor: 1.00,
- appId: '3b16770b-17af-4d22-daff-9606bdf2c9c3'
- }
- };
- expect(spec.isBidRequestValid(bidRequest)).to.equal(true);
- });
-
- it('should return false when the required params are missing for video', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- video: {}
- };
- bidRequest.params = {
- banner: {
- bidfloor: 1.00,
- appId: '3b16770b-17af-4d22-daff-9606bdf2c9c3'
- }
- };
- expect(spec.isBidRequestValid(bidRequest)).to.equal(false);
- });
-
- it('should return true when the required params are passed for banner', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- banner: {}
- };
- bidRequest.params = {
- banner: {
- bidfloor: 1.00,
- appId: '3b16770b-17af-4d22-daff-9606bdf2c9c3'
- }
- };
- expect(spec.isBidRequestValid(bidRequest)).to.equal(true);
- });
-
- it('should return false when the required params are missing for banner', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- banner: {}
- };
- bidRequest.params = {
- video: {
- bidfloor: 1.00,
- appId: '3b16770b-17af-4d22-daff-9606bdf2c9c3'
- }
- };
- expect(spec.isBidRequestValid(bidRequest)).to.equal(false);
- });
- });
- });
-
- describe('spec.buildRequests', function () {
- describe('for video bids', function () {
- it('should attach the bid request object', function () {
- bidRequests[0].mediaTypes = { video: {} };
- bidRequests[1].mediaTypes = { video: {} };
- const requests = spec.buildRequests(bidRequests, {});
- expect(requests[0].bidRequest).to.equal(bidRequests[0]);
- expect(requests[1].bidRequest).to.equal(bidRequests[1]);
- });
-
- it('should create a POST request for each bid', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { video: {} };
- const requests = spec.buildRequests([ bidRequest ], {});
- expect(requests[0].method).to.equal('POST');
- expect(requests[0].url).to.equal(VIDEO_ENDPOINT + bidRequest.params.appId);
- });
-
- it('should attach request data', function () {
- const width = 640;
- const height = 480;
- const bidRequest = bidRequests[0];
- bidRequest.params.tagid = '7cd7a7b4-ef3f-4aeb-9565-3627f255fa10';
- bidRequest.mediaTypes = {
- video: {
- playerSize: [ width, height ]
- }
- };
- const topLocation = parseUrl('http://www.example.com?foo=bar', { decodeSearchAsString: true });
- const bidderRequest = {
- refererInfo: {
- page: topLocation.href
- }
- };
- const requests = spec.buildRequests([ bidRequest ], bidderRequest);
- const data = requests[0].data;
- expect(data.isPrebid).to.equal(true);
- expect(data.appId).to.equal(bidRequest.params.appId);
- expect(data.domain).to.equal(document.location.hostname);
- expect(data.id).to.be.a('string');
- expect(data.imp[0].video).to.deep.contain({ w: width, h: height, mimes: DEFAULT_MIMES });
- expect(data.imp[0].bidfloor).to.equal(bidRequest.params.bidfloor);
- expect(data.imp[0].tagid).to.equal(bidRequest.params.tagid);
- expect(data.site).to.deep.equal({ page: topLocation.href, domain: topLocation.hostname });
- expect(data.device).to.deep.contain({ ua: navigator.userAgent, language: navigator.language, js: 1 });
- expect(data.cur).to.deep.equal(['USD']);
- });
-
- it('must read from the floors module if available', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { video: {} };
- bidRequest.getFloor = () => ({ currency: 'USD', floor: 1.16 });
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.imp[0].bidfloor).to.equal(1.16);
- });
-
- it('must use the bid floor param if no value is returned from the floors module', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { video: {} };
- bidRequest.getFloor = () => ({});
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.imp[0].bidfloor).to.equal(bidRequest.params.bidfloor);
- });
-
- it('must parse bid size from a nested array', function () {
- const width = 640;
- const height = 480;
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- video: {
- playerSize: [[ width, height ]]
- }
- };
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.imp[0].video).to.deep.contain({ w: width, h: height });
- });
-
- it('must parse bid size from a string', function () {
- const width = 640;
- const height = 480;
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- video: {
- playerSize: `${width}x${height}`
- }
- };
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.imp[0].video).to.deep.contain({ w: width, h: height });
- });
-
- it('must handle an empty bid size', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- video: {
- playerSize: []
- }
- };
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.imp[0].video).to.deep.contain({ w: undefined, h: undefined });
- });
-
- it('must fall back to the size on the bid object', function () {
- const width = 640;
- const height = 480;
- const bidRequest = bidRequests[0];
- bidRequest.sizes = [ width, height ];
- bidRequest.mediaTypes = { video: {} };
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.imp[0].video).to.deep.contain({ w: width, h: height });
- });
-
- it('must set video params from the standard object', function () {
- const bidRequest = bidRequests[0];
- const mimes = ['video/webm'];
- const playbackmethod = 2;
- const maxduration = 30;
- const plcmt = 4;
- const skip = 1;
- bidRequest.mediaTypes = {
- video: { mimes, playbackmethod, maxduration, plcmt, skip }
- };
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.imp[0].video).to.deep.contain({ mimes, playbackmethod, maxduration, plcmt, skip });
- });
-
- it('must override video params from the bidder object', function () {
- const bidRequest = bidRequests[0];
- const mimes = ['video/webm'];
- const playbackmethod = 2;
- const maxduration = 30;
- const plcmt = 4;
- const skip = 1;
- bidRequest.mediaTypes = { video: { plcmt: 3, skip: 0 } };
- bidRequest.params.video = { mimes, playbackmethod, maxduration, plcmt, skip };
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.imp[0].video).to.deep.contain({ mimes, playbackmethod, maxduration, plcmt, skip });
- });
-
- it('must add US privacy data to the request', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { video: {} };
- const uspConsent = '2112YYZ';
- const bidderRequest = { uspConsent };
- const requests = spec.buildRequests([ bidRequest ], bidderRequest);
- const data = requests[0].data;
- expect(data.regs.ext.us_privacy).to.equal(uspConsent);
- });
-
- it('must add GDPR consent data to the request', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { video: {} };
- const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==';
- const bidderRequest = {
- gdprConsent: {
- gdprApplies: true,
- consentString
- }
- };
- const requests = spec.buildRequests([ bidRequest ], bidderRequest);
- const data = requests[0].data;
- expect(data.regs.ext.gdpr).to.equal(1);
- expect(data.user.ext.consent).to.equal(consentString);
- });
-
- it('must add GPP consent data to the request', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { video: {} };
- const gppString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==';
- const applicableSections = [1, 2, 3];
- const bidderRequest = {
- gppConsent: {
- gppString,
- applicableSections
- }
- };
- const requests = spec.buildRequests([ bidRequest ], bidderRequest);
- const data = requests[0].data;
- expect(data.regs.gpp).to.equal(gppString);
- expect(data.regs.gpp_sid).to.deep.equal(applicableSections);
- });
-
- it('must add schain data to the request', () => {
- const schain = {
- ver: '1.0',
- complete: 1,
- nodes: [
- {
- asi: 'directseller.com',
- sid: '00001',
- rid: 'BidRequest1',
- hp: 1
- }
- ]
- };
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { video: {} };
- bidRequest.ortb2 = { source: { ext: { schain: schain } } };
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.source.ext.schain).to.deep.equal(schain);
- });
-
- it('must add supported user IDs to the request', () => {
- const userId = {
- tdid: '54017816',
- idl_env: '13024996',
- uid2: { id: '45843401' },
- hadronId: { hadronId: '60314917', auSeg: ['segment1', 'segment2'] }
- };
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { video: {} };
- bidRequest.userId = userId;
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.user.ext.eids).to.deep.equal([
- {
- source: 'adserver.org',
- uids: [{
- id: userId.tdid,
- ext: {
- rtiPartner: 'TDID'
- }
- }]
- },
- {
- source: 'liveramp.com',
- uids: [{
- id: userId.idl_env,
- ext: {
- rtiPartner: 'idl'
- }
- }]
- },
- {
- source: 'uidapi.com',
- uids: [{
- id: userId.uid2.id,
- ext: {
- rtiPartner: 'UID2'
- }
- }]
- },
- {
- source: 'audigent.com',
- uids: [{
- id: userId.hadronId,
- atype: 1,
- }]
- }
- ]);
- });
- });
-
- describe('for banner bids', function () {
- it('should attach the bid requests array', function () {
- bidRequests[0].mediaTypes = { banner: {} };
- bidRequests[1].mediaTypes = { banner: {} };
- const requests = spec.buildRequests(bidRequests, {});
- expect(requests[0].bidRequest).to.deep.equal(bidRequests);
- });
-
- it('should create a single POST request for all bids', function () {
- bidRequests[0].mediaTypes = { banner: {} };
- bidRequests[1].mediaTypes = { banner: {} };
- const requests = spec.buildRequests(bidRequests, {});
- expect(requests.length).to.equal(1);
- expect(requests[0].method).to.equal('POST');
- expect(requests[0].url).to.equal(BANNER_ENDPOINT);
- });
-
- it('should attach request data', function () {
- const width = 300;
- const height = 250;
- const bidRequest = bidRequests[0];
- bidRequest.params.tagid = '7cd7a7b4-ef3f-4aeb-9565-3627f255fa10';
- bidRequest.mediaTypes = {
- banner: {
- sizes: [ width, height ]
- }
- };
- const topLocation = parseUrl('http://www.example.com?foo=bar', { decodeSearchAsString: true });
- const bidderRequest = {
- refererInfo: {
- page: topLocation.href
- }
- };
- const requests = spec.buildRequests([ bidRequest ], bidderRequest);
- const data = requests[0].data;
- expect(data.slots).to.deep.equal([
- {
- slot: bidRequest.adUnitCode,
- id: bidRequest.params.appId,
- bidfloor: bidRequest.params.bidfloor,
- tagid: bidRequest.params.tagid,
- sizes: [{ w: width, h: height }]
- }
- ]);
- expect(data.page).to.equal(topLocation.href);
- expect(data.domain).to.equal(topLocation.hostname);
- expect(data.search).to.equal(topLocation.search);
- expect(data.ua).to.equal(navigator.userAgent);
- });
-
- it('must read from the floors module if available', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { banner: {} };
- bidRequest.getFloor = () => ({ currency: 'USD', floor: 1.16 });
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.slots[0].bidfloor).to.equal(1.16);
- });
-
- it('must use the bid floor param if no value is returned from the floors module', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { banner: {} };
- bidRequest.getFloor = () => ({});
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.slots[0].bidfloor).to.equal(bidRequest.params.bidfloor);
- });
-
- it('must parse bid size from a nested array', function () {
- const width = 300;
- const height = 250;
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- banner: {
- sizes: [[ width, height ]]
- }
- };
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.slots[0].sizes).to.deep.equal([
- { w: width, h: height }
- ]);
- });
-
- it('must parse bid size from a string', function () {
- const width = 300;
- const height = 250;
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- banner: {
- sizes: `${width}x${height}`
- }
- };
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.slots[0].sizes).to.deep.equal([
- { w: width, h: height }
- ]);
- });
-
- it('must handle an empty bid size', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- banner: {
- sizes: []
- }
- };
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.slots[0].sizes).to.deep.equal([]);
- });
-
- it('must fall back to the size on the bid object', function () {
- const width = 300;
- const height = 250;
- const bidRequest = bidRequests[0];
- bidRequest.sizes = [ width, height ];
- bidRequest.mediaTypes = { banner: {} };
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.slots[0].sizes).to.deep.contain({ w: width, h: height });
- });
-
- it('must add US privacy data to the request', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { banner: {} };
- const uspConsent = '2112YYZ';
- const bidderRequest = { uspConsent };
- const requests = spec.buildRequests([ bidRequest ], bidderRequest);
- const data = requests[0].data;
- expect(data.usPrivacy).to.equal(uspConsent);
- });
-
- it('must add GDPR consent data to the request', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { banner: {} };
- const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==';
- const bidderRequest = {
- gdprConsent: {
- gdprApplies: true,
- consentString
- }
- };
- const requests = spec.buildRequests([ bidRequest ], bidderRequest);
- const data = requests[0].data;
- expect(data.gdpr).to.equal(1);
- expect(data.gdprConsent).to.equal(consentString);
- });
-
- it('must add GPP consent data to the request', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { banner: {} };
- const gppString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==';
- const applicableSections = [1, 2, 3];
- const bidderRequest = {
- gppConsent: {
- gppString,
- applicableSections
- }
- };
- const requests = spec.buildRequests([ bidRequest ], bidderRequest);
- const data = requests[0].data;
- expect(data.gpp).to.equal(gppString);
- expect(data.gppSid).to.deep.equal(applicableSections);
- });
-
- it('must add schain data to the request', () => {
- const schain = {
- ver: '1.0',
- complete: 1,
- nodes: [
- {
- asi: 'directseller.com',
- sid: '00001',
- rid: 'BidRequest1',
- hp: 1
- }
- ]
- };
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { banner: {} };
- bidRequest.ortb2 = { source: { ext: { schain: schain } } };
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.schain).to.deep.equal(schain);
- });
-
- it('must add supported user IDs to the request', () => {
- const userId = {
- tdid: '54017816',
- idl_env: '13024996',
- uid2: { id: '45843401' },
- hadronId: { hadronId: '60314917', auSeg: ['segment1', 'segment2'] }
- };
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { banner: {} };
- bidRequest.userId = userId;
- const requests = spec.buildRequests([ bidRequest ], {});
- const data = requests[0].data;
- expect(data.tdid).to.equal(userId.tdid);
- expect(data.idl).to.equal(userId.idl_env);
- expect(data.uid2).to.equal(userId.uid2.id);
- expect(data.hadronid).to.equal(userId.hadronId);
- });
- });
-
- describe('with first-party data', function () {
- it('must add first-party data to the video bid request', function () {
- const ortb2 = {
- site: {
- keywords: 'test keyword'
- },
- user: {
- data: 'some user data'
- }
- };
-
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { video: {} };
- const bidderRequest = {
- refererInfo: {
- page: 'http://example.com/page.html'
- },
- ortb2
- };
- const requests = spec.buildRequests([ bidRequest ], bidderRequest);
- const data = requests[0].data;
- expect(data.user.data).to.equal('some user data');
- expect(data.site.keywords).to.equal('test keyword');
- expect(data.site.page).to.equal('http://example.com/page.html');
- expect(data.site.domain).to.equal('example.com');
- });
-
- it('must add first-party data to the banner bid request', function () {
- const ortb2 = {
- site: {
- keywords: 'test keyword'
- },
- user: {
- data: 'some user data'
- }
- };
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { banner: {} };
- const requests = spec.buildRequests([ bidRequest ], {ortb2});
- const data = requests[0].data;
- expect(data.ortb2.user.data).to.equal('some user data');
- expect(data.ortb2.site.keywords).to.equal('test keyword');
- });
- });
-
- describe('for multi-format bids', function () {
- it('should create a POST request for each bid format', function () {
- const width = 300;
- const height = 250;
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- video: {
- playerSize: [ width, height ]
- },
- banner: {
- sizes: [ width, height ]
- }
- };
- bidRequest.params = {
- video: {
- bidfloor: 2.00,
- appId: '11bc5dd5-7421-4dd8-c926-40fa653bec76'
- },
- banner: {
- bidfloor: 1.00,
- appId: '3b16770b-17af-4d22-daff-9606bdf2c9c3'
- }
- };
- const requests = spec.buildRequests([ bidRequest ], {});
- expect(requests.length).to.equal(2);
- expect(requests[0].url).to.contain(VIDEO_ENDPOINT);
- expect(requests[1].url).to.contain(BANNER_ENDPOINT);
- });
-
- it('must parse bid sizes for each bid format', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- video: {
- playerSize: [ 640, 360 ]
- },
- banner: {
- sizes: [ 300, 250 ]
- }
- };
- bidRequest.params = {
- video: {
- bidfloor: 2.00,
- appId: '11bc5dd5-7421-4dd8-c926-40fa653bec76'
- },
- banner: {
- bidfloor: 1.00,
- appId: '3b16770b-17af-4d22-daff-9606bdf2c9c3'
- }
- };
- const requests = spec.buildRequests([ bidRequest ], {});
- expect(requests[0].data.imp[0].video).to.deep.contain({ w: 640, h: 360 });
- expect(requests[1].data.slots[0].sizes).to.deep.equal([{ w: 300, h: 250 }]);
- });
- });
- });
-
- describe('spec.interpretResponse', function () {
- describe('for video bids', function () {
- it('should return no bids if the response is not valid', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { video: {} };
- const bidResponse = spec.interpretResponse({ body: null }, { bidRequest });
- expect(bidResponse.length).to.equal(0);
- });
-
- it('should return no bids if the response "bidPrice" is missing', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { video: {} };
- const serverResponse = {
- url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da'
- };
- const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
- expect(bidResponse.length).to.equal(0);
- });
-
- it('should return a valid video bid response', function () {
- const width = 640;
- const height = 480;
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- video: {
- playerSize: [ width, height ]
- }
- };
- const serverResponse = {
- bidPrice: 5.00,
- url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
- vast: '
',
- crid: '123abc'
- };
- const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
- expect(bidResponse).to.deep.equal({
- requestId: bidRequest.bidId,
- cpm: serverResponse.bidPrice,
- creativeId: serverResponse.crid,
- vastUrl: serverResponse.url,
- vastXml: serverResponse.vast,
- width: width,
- height: height,
- renderer: null,
- meta: { mediaType: 'video', advertiserDomains: [] },
- mediaType: 'video',
- currency: 'USD',
- netRevenue: true,
- ttl: 300
- });
- });
-
- it('should return only vast url if the response type is "nurl"', () => {
- const width = 640;
- const height = 480;
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- video: {
- playerSize: [ width, height ]
- }
- };
- bidRequest.params.video = { responseType: 'nurl' };
- const serverResponse = {
- bidPrice: 5.00,
- url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
- vast: '
',
- crid: '123abc'
- };
- const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
- expect(bidResponse.vastUrl).to.equal(serverResponse.url);
- expect(bidResponse.vastXml).to.equal(undefined);
- });
-
- it('should return only vast xml if the response type is "adm"', () => {
- const width = 640;
- const height = 480;
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- video: {
- playerSize: [ width, height ]
- }
- };
- bidRequest.params.video = { responseType: 'adm' };
- const serverResponse = {
- bidPrice: 5.00,
- url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
- vast: '
',
- crid: '123abc'
- };
- const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
- expect(bidResponse.vastUrl).to.equal(undefined);
- expect(bidResponse.vastXml).to.equal(serverResponse.vast);
- });
-
- it('should return a renderer for outstream video bids', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- video: {
- context: 'outstream'
- }
- };
- const serverResponse = {
- bidPrice: 5.00,
- url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
- crid: '123abc'
- };
- const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
- expect(bidResponse.renderer).to.deep.contain({
- id: bidRequest.bidId,
- url: OUTSTREAM_SRC
- });
- expect(bidResponse.renderer.render).to.be.a('function');
- });
-
- it('should return meta data for the bid response', () => {
- const width = 640;
- const height = 480;
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = {
- video: {
- playerSize: [ width, height ]
- }
- };
- const serverResponse = {
- bidPrice: 5.00,
- url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
- meta: {
- advertiserDomains: ['example.com'],
- advertiserId: '123'
- }
- };
- const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
- expect(bidResponse.meta).to.deep.equal({
- mediaType: 'video',
- advertiserDomains: ['example.com'],
- advertiserId: '123'
- });
- });
- });
-
- describe('for banner bids', function () {
- it('should return no bids if the response is not valid', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { banner: {} };
- const bidResponse = spec.interpretResponse({ body: null }, { bidRequest });
- expect(bidResponse.length).to.equal(0);
- });
-
- it('should return no bids if the response is empty', function () {
- const bidRequest = bidRequests[0];
- bidRequest.mediaTypes = { banner: {} };
- const bidResponse = spec.interpretResponse({ body: [] }, { bidRequest });
- expect(bidResponse.length).to.equal(0);
- });
-
- it('should return valid banner bid responses', function () {
- bidRequests[0].mediaTypes = {
- banner: {
- sizes: [[ 300, 250 ], [ 728, 90 ]]
- }
- };
- bidRequests[1].mediaTypes = {
- banner: {
- sizes: [[ 300, 600 ], [ 200, 200 ]]
- }
- };
- const serverResponse = [{
- slot: bidRequests[0].adUnitCode,
- adm: '
',
- crid: 'crid_1',
- price: 3.02,
- w: 728,
- h: 90
- }, {
- slot: bidRequests[1].adUnitCode,
- adm: '
',
- crid: 'crid_2',
- price: 3.06,
- w: 300,
- h: 600
- }];
- const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest: bidRequests });
- expect(bidResponse.length).to.equal(2);
- for (let i = 0; i < bidRequests.length; i++) {
- expect(bidResponse[ i ]).to.deep.equal({
- requestId: bidRequests[ i ].bidId,
- bidderCode: spec.code,
- ad: serverResponse[ i ].adm,
- creativeId: serverResponse[ i ].crid,
- cpm: serverResponse[ i ].price,
- width: serverResponse[ i ].w,
- height: serverResponse[ i ].h,
- meta: { mediaType: 'banner', advertiserDomains: [] },
- mediaType: 'banner',
- currency: 'USD',
- netRevenue: true,
- ttl: 300
- });
- }
- });
-
- it('should return meta data for the bid response', () => {
- bidRequests[0].mediaTypes = {
- banner: {
- sizes: [[ 300, 250 ], [ 728, 90 ]]
- }
- };
- const serverResponse = [{
- slot: bidRequests[0].adUnitCode,
- adm: '
',
- crid: 'crid_1',
- price: 3.02,
- w: 728,
- h: 90,
- meta: {
- advertiserDomains: ['example.com'],
- advertiserId: '123'
- }
- }];
- const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest: bidRequests });
- expect(bidResponse[0].meta).to.deep.equal({
- mediaType: 'banner',
- advertiserDomains: ['example.com'],
- advertiserId: '123'
- });
- });
- });
- });
-
- describe('spec.getUserSyncs', function () {
- describe('for video bids', function () {
- let bidResponse;
-
- beforeEach(function () {
- bidResponse = {
- bidPrice: 5.00,
- url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
- crid: '123abc'
- };
- });
-
- it('should return an iframe user sync if iframes are enabled', function () {
- const syncOptions = {
- iframeEnabled: true,
- pixelEnabled: true
- };
- const serverResponses = [{
- body: bidResponse
- }];
- const userSyncs = spec.getUserSyncs(syncOptions, serverResponses);
- expect(userSyncs.length).to.equal(1);
- expect(userSyncs[0].type).to.equal('iframe');
- });
-
- it('should return an image user sync if iframes are disabled', function () {
- const syncOptions = {
- iframeEnabled: false,
- pixelEnabled: true
- };
- const serverResponses = [{
- body: bidResponse
- }];
- const userSyncs = spec.getUserSyncs(syncOptions, serverResponses);
- expect(userSyncs.length).to.equal(1);
- expect(userSyncs[0].type).to.equal('image');
- });
-
- it('should not return user syncs if none are enabled', function () {
- const syncOptions = {
- iframeEnabled: false,
- pixelEnabled: false
- };
- const serverResponses = [{
- body: bidResponse
- }];
- const userSyncs = spec.getUserSyncs(syncOptions, serverResponses);
- expect(userSyncs).to.deep.equal([]);
- });
- });
-
- describe('for banner bids', function () {
- let bidResponse;
-
- beforeEach(function () {
- bidResponse = {
- slot: bidRequests[0].adUnitCode,
- adm: '
',
- crid: 'crid_1',
- price: 3.02,
- w: 728,
- h: 90
- };
- });
-
- it('should return user syncs defined the bid response', function () {
- const syncUrl = 'https://sync.bfmio.com/sync_iframe?ifpl=5&ifg=1&id=test&gdpr=0&gc=&gce=0';
- const syncOptions = {
- iframeEnabled: true,
- pixelEnabled: true
- };
- const serverResponses = [{
- body: [
- { sync: syncUrl },
- bidResponse
- ]
- }];
- const userSyncs = spec.getUserSyncs(syncOptions, serverResponses);
- expect(userSyncs).to.deep.equal([
- { type: 'iframe', url: syncUrl }
- ]);
- });
-
- it('should not return user syncs if iframes are disabled', function () {
- const syncUrl = 'https://sync.bfmio.com/sync_iframe?ifpl=5&ifg=1&id=test&gdpr=0&gc=&gce=0';
- const syncOptions = {
- iframeEnabled: false,
- pixelEnabled: true
- };
- const serverResponses = [{
- body: [
- { sync: syncUrl },
- bidResponse
- ]
- }];
- const userSyncs = spec.getUserSyncs(syncOptions, serverResponses);
- expect(userSyncs).to.deep.equal([]);
- });
-
- it('should not return user syncs if there are none in the bid response', function () {
- const syncOptions = {
- iframeEnabled: true,
- pixelEnabled: true
- };
- const serverResponses = [{
- body: [
- bidResponse
- ]
- }];
- const userSyncs = spec.getUserSyncs(syncOptions, serverResponses);
- expect(userSyncs).to.deep.equal([]);
- });
- });
- });
-});
diff --git a/test/spec/modules/bedigitechBidAdapter_spec.js b/test/spec/modules/bedigitechBidAdapter_spec.js
deleted file mode 100644
index 2454efa63..000000000
--- a/test/spec/modules/bedigitechBidAdapter_spec.js
+++ /dev/null
@@ -1,136 +0,0 @@
-import { expect } from 'chai';
-import { spec } from 'modules/bedigitechBidAdapter.js';
-import { newBidder } from 'src/adapters/bidderFactory.js';
-import { BANNER } from 'src/mediaTypes.js';
-
-describe('BedigitechAdapter', function () {
- const adapter = newBidder(spec);
-
- describe('inherited functions', function () {
- it('exists and is a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('isBidRequestValid', function () {
- const bid = {
- bidder: 'bedigitech',
- adUnitCode: 'adunit-code',
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [300, 600]]
- }
- },
- bidId: '30b31c1838de1e',
- bidderRequestId: '22edbae2733bf6',
- auctionId: '1d1a030790a475',
- params: {
- placementId: 309,
- },
- };
-
- it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should return false when required params are not passed', function () {
- const invalidBid = Object.assign({}, bid);
- delete invalidBid.params;
- invalidBid.params = {
- 'masterId': 0
- };
-
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
- });
-
- describe('buildRequests', function () {
- const bidRequests = [{
- bidder: 'bedigitech',
- adUnitCode: 'adunit-code',
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [300, 600]]
- }
- },
- bidId: '30b31c1838de1e',
- bidderRequestId: '22edbae2733bf6',
- auctionId: '1d1a030790a475',
- params: {
- placementId: 309,
- },
- }];
-
- it('sends bid request to url via GET', function () {
- const request = spec.buildRequests(bidRequests)[0];
- expect(request.method).to.equal('GET');
- expect(request.url).to.equal('https://bid.bedigitech.com/bid/pub_bid.php');
- });
-
- it('should attach pid to url', function () {
- const request = spec.buildRequests(bidRequests)[0];
- expect(request.data.pid).to.equal(309);
- });
- });
-
- describe('interpretResponse', function () {
- const response = {
- 'body': [
- {
- 'ad': '%3C!--%20Creative%20--%3E',
- 'cpm': '5.0',
- 'crid': '0af345b42983cc4bc0',
- 'currency': 'USD',
- 'height': 250,
- 'id': 'bedigitechMyidfdfdf',
- 'netRevenue': true,
- 'requestTime': 1686306237,
- 'timeToRespond': 300,
- 'ttl': 300,
- 'width': 300
- }
- ],
- 'headers': {
- 'get': function() {}
- }
- };
-
- it('should get correct bid responseiiiiii', function () {
- const expectedResponse = [
- {
- 'ad': '%3C!--%20Creative%20--%3E',
- 'cpm': '5.0',
- 'creativeId': '0af345b42983cc4bc0',
- 'currency': 'USD',
- 'height': 250,
- 'id': 'bedigitechMyidfdfdf',
- 'meta': {
- 'mediaType': BANNER,
- },
- 'netRevenue': true,
- 'requestId': 'bedigitechMyidfdfdf',
- 'requestTimestamp': 1686306237,
- 'timeToRespond': 300,
- 'ttl': 300,
- 'width': 300,
- 'bidderCode': 'bedigitech',
- }
- ];
- const result = spec.interpretResponse(response);
- expect(result).to.have.lengthOf(1);
- const resultKeys = Object.keys(result[0]);
- expect(resultKeys.sort()).to.deep.equal(Object.keys(expectedResponse[0]).sort());
- resultKeys.forEach(function(k) {
- if (k === 'ad') {
- expect(result[0][k]).to.match(/$/);
- } else if (k === 'meta') {
- expect(result[0][k]).to.deep.equal(expectedResponse[0][k]);
- } else {
- if (k !== 'requestId') {
- expect(result[0][k]).to.equal(expectedResponse[0][k]);
- }
- }
- });
- });
- });
-});
diff --git a/test/spec/modules/beopBidAdapter_spec.js b/test/spec/modules/beopBidAdapter_spec.js
deleted file mode 100644
index 08e14b761..000000000
--- a/test/spec/modules/beopBidAdapter_spec.js
+++ /dev/null
@@ -1,452 +0,0 @@
-import { expect } from 'chai';
-import { spec } from 'modules/beopBidAdapter.js';
-import { newBidder } from 'src/adapters/bidderFactory.js';
-import { config } from 'src/config.js';
-import { setConfig as setCurrencyConfig } from '../../../modules/currency.js';
-import { addFPDToBidderRequest } from '../../helpers/fpd.js';
-const utils = require('src/utils');
-
-const ENDPOINT = 'https://hb.collectiveaudience.co/bid';
-
-const validBid = {
- 'bidder': 'beop',
- 'params': {
- 'accountId': '5a8af500c9e77c00017e4cad'
- },
- 'adUnitCode': 'bellow-article',
- 'mediaTypes': {
- 'banner': {
- 'sizes': [[1, 1]]
- }
- },
- 'getFloor': () => {
- return {
- currency: 'USD',
- floor: 10,
- }
- },
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- 'transactionId': '04f2659e-c005-4eb1-a57c-fa93145e3843',
- 'creativeId': 'er2ee'
-};
-
-describe('BeOp Bid Adapter tests', () => {
- afterEach(function () {
- config.setConfig({});
- });
-
- const adapter = newBidder(spec);
-
- describe('inherited functions', () => {
- it('exists and is a function', () => {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('isBidRequestValid', function() {
- it('should return true when accountId params found', function () {
- expect(spec.isBidRequestValid(validBid)).to.equal(true);
- });
-
- it('should return true if no accountId but networkId', function () {
- const bid = Object.assign({}, validBid);
- delete bid.params;
- bid.params = {
- 'networkId': '5a8af500c9e77c00017e4aaa'
- };
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should return false if neither account or network id param found', function () {
- const bid = Object.assign({}, validBid);
- delete bid.params;
- bid.params = {
- 'someId': '5a8af500c9e77c00017e4aaa'
- };
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return false if account Id param is not an ObjectId', function () {
- const bid = Object.assign({}, validBid);
- delete bid.params;
- bid.params = {
- 'someId': '12345'
- };
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return false if there is no banner media type', function () {
- const bid = Object.assign({}, validBid);
- delete bid.mediaTypes;
- bid.mediaTypes = {
- 'native': {
- 'sizes': [[1, 1]]
- }
- };
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
- });
-
- describe('buildRequests', function () {
- const bidRequests = [];
- bidRequests.push(validBid);
-
- it('should build the request', function () {
- const bidderRequest = {
- refererInfo: {
- page: 'https://example.com'
- }
- };
- setCurrencyConfig({ adServerCurrency: 'USD' })
-
- return addFPDToBidderRequest(bidderRequest).then(res => {
- const request = spec.buildRequests(bidRequests, res);
- const payload = JSON.parse(request.data);
- const url = request.url;
- expect(url).to.equal(ENDPOINT);
- expect(payload.pid).to.exist;
- expect(payload.pid).to.equal('5a8af500c9e77c00017e4cad');
- expect(payload.gdpr_applies).to.exist;
- expect(payload.gdpr_applies).to.equals(false);
- expect(payload.slts[0].name).to.exist;
- expect(payload.slts[0].name).to.equal('bellow-article');
- expect(payload.slts[0].flr).to.equal(10);
- setCurrencyConfig({});
- });
- });
-
- it('should call the endpoint with GDPR consent and pageURL info if found', function () {
- const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==';
- const bidderRequest =
- {
- 'gdprConsent':
- {
- 'gdprApplies': true,
- 'consentString': consentString
- },
- 'refererInfo':
- {
- 'canonicalUrl': 'test.te'
- }
- };
-
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const payload = JSON.parse(request.data);
- expect(payload.gdpr_applies).to.exist;
- expect(payload.gdpr_applies).to.equals(true);
- expect(payload.tc_string).to.exist;
- expect(payload.tc_string).to.equal('BOJ8RZsOJ8RZsABAB8AAAAAZ+A==');
- expect(payload.url).to.exist;
- // check that the protocol is added correctly
- expect(payload.url).to.equal('http://test.te');
- });
-
- it('should call the endpoint with bpsegs (stringified) data if any or [] if none', function () {
- const bidderRequest =
- {
- 'ortb2': {
- 'user': {
- 'ext': {
- 'bpsegs': ['axed', 'axec', 1234],
- 'data': {
- 'permutive': [1234, 5678, 910]
- }
- }
- }
- }
- };
-
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const payload = JSON.parse(request.data);
- expect(payload.bpsegs).to.exist;
- expect(payload.bpsegs).to.include('axed');
- expect(payload.bpsegs).to.include('axec');
- expect(payload.bpsegs).to.include('1234');
- expect(payload.bpsegs).to.include('1234');
- expect(payload.bpsegs).to.include('5678');
- expect(payload.bpsegs).to.include('910');
- expect(payload.bpsegs).to.not.include('1');
-
- const bidderRequest2 =
- {
- 'ortb2': {}
- };
-
- const request2 = spec.buildRequests(bidRequests, bidderRequest2);
- const payload2 = JSON.parse(request2.data);
- expect(payload2.bpsegs).to.exist;
- expect(payload2.bpsegs).to.be.empty;
- });
-
- it('should not prepend the protocol in page url if already present', function () {
- const bidderRequest = {
- 'refererInfo': {
- 'canonicalUrl': 'https://test.te'
- }
- };
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const payload = JSON.parse(request.data);
- expect(payload.url).to.exist;
- expect(payload.url).to.equal('https://test.te');
- });
- });
-
- describe('interpretResponse', function() {
- const serverResponse = {
- 'body': {
- 'bids': [
- {
- 'requestId': 'aaaa',
- 'cpm': 1.0,
- 'currency': 'EUR',
- 'creativeId': '60f691be1515670a2a09aea2',
- 'netRevenue': true,
- 'width': 1,
- 'height': 1,
- 'ad': '
',
- 'meta': {
- 'advertiserId': '60f691be1515670a2a09aea1'
- }
- }
- ]
- }
- }
- it('should interpret the response by pushing it in the bids elem', function () {
- const response = spec.interpretResponse(serverResponse, validBid);
-
- expect(response[0].ad).to.exist;
- expect(response[0].requestId).to.exist;
- expect(response[0].requestId).to.equal('aaaa');
- });
- });
-
- describe('timeout and bid won pixel trigger', function () {
- let triggerPixelStub;
-
- beforeEach(function () {
- triggerPixelStub = sinon.stub(utils, 'triggerPixel');
- });
-
- afterEach(function () {
- utils.triggerPixel.restore();
- });
-
- it('should call triggerPixel utils function when timed out is filled', function () {
- spec.onTimeout({});
- spec.onTimeout();
- spec.onTimeout(null);
- spec.onTimeout([]);
- expect(triggerPixelStub.getCall(0)).to.be.null;
- spec.onTimeout([{
- bidder: 'beop',
- bidId: 'abc123',
- params: { accountId: '5a8af500c9e77c00017e4cad' },
- adUnitCode: 'div-1',
- timeout: 2000,
- auctionId: 'some-auction-id'
- }]);
- expect(triggerPixelStub.getCall(0)).to.not.be.null;
- expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.include('https://t.collectiveaudience.co');
- expect(triggerPixelStub.getCall(0).args[0]).to.include('se_ca=bid');
- expect(triggerPixelStub.getCall(0).args[0]).to.include('se_ac=timeout');
- expect(triggerPixelStub.getCall(0).args[0]).to.include('pid=5a8af500c9e77c00017e4cad');
- });
-
- it('should call triggerPixel for each entry in the timeout array', function () {
- const timeoutData = [
- {
- bidder: 'beop',
- bidId: 'abc123',
- params: { accountId: '5a8af500c9e77c00017e4cad' },
- adUnitCode: 'div-1',
- timeout: 3000,
- auctionId: 'auction-1'
- },
- {
- bidder: 'beop',
- bidId: 'def456',
- params: { accountId: '5a8af500c9e77c00017e4cad' },
- adUnitCode: 'div-2',
- timeout: 3000,
- auctionId: 'auction-2'
- }
- ];
-
- spec.onTimeout(timeoutData);
-
- expect(triggerPixelStub.callCount).to.equal(2);
- const firstCall = triggerPixelStub.getCall(0).args[0];
- const secondCall = triggerPixelStub.getCall(1).args[0];
-
- expect(firstCall).to.include('se_ac=timeout');
- expect(firstCall).to.include('bid=abc123');
- expect(secondCall).to.include('bid=def456');
- });
- it('should call triggerPixel utils function on bid won', function () {
- spec.onBidWon({});
- spec.onBidWon();
- expect(triggerPixelStub.getCall(0)).to.be.null;
- spec.onBidWon({params: {accountId: '5a8af500c9e77c00017e4cad'}, cpm: 1.2});
- expect(triggerPixelStub.getCall(0)).to.not.be.null;
- expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.include('https://t.collectiveaudience.co');
- expect(triggerPixelStub.getCall(0).args[0]).to.include('se_ca=bid');
- expect(triggerPixelStub.getCall(0).args[0]).to.include('se_ac=won');
- expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.include('pid=5a8af500c9e77c00017e4cad');
- });
- it('should call triggerPixel utils function on bid won and work even if params is an array', function () {
- spec.onBidWon({});
- spec.onBidWon();
- expect(triggerPixelStub.getCall(0)).to.be.null;
- spec.onBidWon({params: [{accountId: '5a8af500c9e77c00017e4cad'}], cpm: 1.2});
- expect(triggerPixelStub.getCall(0)).to.not.be.null;
- expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.include('https://t.collectiveaudience.co');
- expect(triggerPixelStub.getCall(0).args[0]).to.include('se_ca=bid');
- expect(triggerPixelStub.getCall(0).args[0]).to.include('se_ac=won');
- expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.include('pid=5a8af500c9e77c00017e4cad');
- });
- });
-
- describe('Ensure keywords is always array of string', function () {
- let bidRequests = [];
- afterEach(function () {
- bidRequests = [];
- });
-
- it('should work with keywords as an array', function () {
- const bid = Object.assign({}, validBid);
- bid.params.keywords = ['a', 'b'];
- bidRequests.push(bid);
- config.setConfig({
- currency: { adServerCurrency: 'USD' }
- });
- const request = spec.buildRequests(bidRequests, {});
- const payload = JSON.parse(request.data);
- const url = request.url;
- expect(payload.kwds).to.exist;
- expect(payload.kwds).to.include('a');
- expect(payload.kwds).to.include('b');
- });
-
- it('should work with keywords as a string', function () {
- const bid = Object.assign({}, validBid);
- bid.params.keywords = 'list of keywords';
- bidRequests.push(bid);
- config.setConfig({
- currency: { adServerCurrency: 'USD' }
- });
- const request = spec.buildRequests(bidRequests, {});
- const payload = JSON.parse(request.data);
- const url = request.url;
- expect(payload.kwds).to.exist;
- expect(payload.kwds).to.include('list of keywords');
- });
-
- it('should work with keywords as a string containing a comma', function () {
- const bid = Object.assign({}, validBid);
- bid.params.keywords = 'list, of, keywords';
- bidRequests.push(bid);
- config.setConfig({
- currency: { adServerCurrency: 'USD' }
- });
- const request = spec.buildRequests(bidRequests, {});
- const payload = JSON.parse(request.data);
- const url = request.url;
- expect(payload.kwds).to.exist;
- expect(payload.kwds).to.include('list');
- expect(payload.kwds).to.include('of');
- expect(payload.kwds).to.include('keywords');
- })
- })
-
- describe('Ensure eids are get', function() {
- let bidRequests = [];
- afterEach(function () {
- bidRequests = [];
- });
-
- it(`should get eids from bid`, function () {
- const bid = Object.assign({}, validBid);
- bid.userIdAsEids = [{source: 'provider.com', uids: [{id: 'someid', atype: 1, ext: {whatever: true}}]}];
- bidRequests.push(bid);
-
- const request = spec.buildRequests(bidRequests, {});
- const payload = JSON.parse(request.data);
- expect(payload.eids).to.exist;
- expect(payload.eids[0].source).to.equal('provider.com');
- });
- })
-
- describe('Ensure first party cookie is well managed', function () {
- const bidRequests = [];
-
- it(`should generate a new uuid`, function () {
- const bid = Object.assign({}, validBid);
- bidRequests.push(bid);
- const request = spec.buildRequests(bidRequests, {});
- const payload = JSON.parse(request.data);
- expect(payload.fg).to.exist;
- })
- })
- describe('getUserSyncs', function () {
- it('should return iframe sync when iframeEnabled and syncFrame provided', function () {
- const syncOptions = { iframeEnabled: true, pixelEnabled: false };
- const serverResponses = [{ body: { sync_frames: ['https://example.com/sync_frame', 'https://example2.com/sync_second'] } }];
-
- const syncs = spec.getUserSyncs(syncOptions, serverResponses);
-
- expect(syncs).to.have.length(2);
- expect(syncs[0].type).to.equal('iframe');
- expect(syncs[0].url).to.equal('https://example.com/sync_frame');
- });
-
- it('should return pixel syncs when pixelEnabled and syncPixels provided', function () {
- const syncOptions = { iframeEnabled: false, pixelEnabled: true };
- const serverResponses = [{
- body: {
- sync_pixels: [
- 'https://example.com/pixel1',
- 'https://example.com/pixel2'
- ]
- }
- }];
-
- const syncs = spec.getUserSyncs(syncOptions, serverResponses);
-
- expect(syncs).to.have.length(2);
- expect(syncs[0].type).to.equal('image');
- expect(syncs[0].url).to.equal('https://example.com/pixel1');
- expect(syncs[1].url).to.equal('https://example.com/pixel2');
- });
-
- it('should return both iframe and pixel syncs when both options are enabled', function () {
- const syncOptions = { iframeEnabled: true, pixelEnabled: true };
- const serverResponses = [{
- body: {
- sync_frames: ['https://example.com/sync_frame'],
- sync_pixels: ['https://example.com/pixel1']
- }
- }];
-
- const syncs = spec.getUserSyncs(syncOptions, serverResponses);
-
- expect(syncs).to.have.length(2);
- expect(syncs[0].type).to.equal('iframe');
- expect(syncs[1].type).to.equal('image');
- });
-
- it('should return empty array when no serverResponses', function () {
- const syncOptions = { iframeEnabled: true, pixelEnabled: true };
- const syncs = spec.getUserSyncs(syncOptions, []);
- expect(syncs).to.be.an('array').that.is.empty;
- });
-
- it('should return empty array when no syncFrame or syncPixels provided', function () {
- const syncOptions = { iframeEnabled: true, pixelEnabled: true };
- const serverResponses = [{ body: {} }];
- const syncs = spec.getUserSyncs(syncOptions, serverResponses);
- expect(syncs).to.be.an('array').that.is.empty;
- });
- });
-});
diff --git a/test/spec/modules/betweenBidAdapter_spec.js b/test/spec/modules/betweenBidAdapter_spec.js
deleted file mode 100644
index 857779ca3..000000000
--- a/test/spec/modules/betweenBidAdapter_spec.js
+++ /dev/null
@@ -1,365 +0,0 @@
-import { expect } from 'chai';
-import { spec } from 'modules/betweenBidAdapter.js';
-
-describe('betweenBidAdapterTests', function () {
- it('validate_pub_params', function () {
- expect(spec.isBidRequestValid({
- bidder: 'between',
- params: {
- w: 240,
- h: 400,
- s: 1112
- }
- })).to.equal(true);
- });
- it('validate_generated_params', function () {
- const bidRequestData = [{
- bidId: 'bid1234',
- bidder: 'between',
- params: {w: 240, h: 400, s: 1112},
- sizes: [[240, 400]]
- }]
- const request = spec.buildRequests(bidRequestData);
- const req_data = JSON.parse(request.data)[0].data;
- expect(req_data.bidid).to.equal('bid1234');
- });
-
- it('validate_video_params', function () {
- const bidRequestData = [{
- bidId: 'bid1234',
- bidder: 'between',
- params: {w: 240, h: 400, s: 1112},
- mediaTypes: {
- video: {
- context: 'outstream',
- playerSize: [970, 250],
- maxd: 123,
- mind: 234,
- codeType: 'unknown code type'
- }
- },
- }];
- const request = spec.buildRequests(bidRequestData);
- const req_data = JSON.parse(request.data)[0].data;
-
- expect(req_data.mediaType).to.equal(2);
- expect(req_data.maxd).to.equal(123);
- expect(req_data.mind).to.equal(234);
- expect(req_data.pos).to.equal('atf');
- expect(req_data.codeType).to.equal('inpage');
- });
-
- it('validate itu param', function() {
- const bidRequestData = [{
- bidId: 'bid1234',
- bidder: 'between',
- params: {
- w: 240,
- h: 400,
- s: 1112,
- itu: 'https://something.url'
- },
- sizes: [[240, 400]]
- }];
-
- const request = spec.buildRequests(bidRequestData);
- const req_data = JSON.parse(request.data)[0].data;
-
- expect(req_data.itu).to.equal('https://something.url');
- });
- it('validate cur param', function() {
- const bidRequestData = [{
- bidId: 'bid1234',
- bidder: 'between',
- params: {
- w: 240,
- h: 400,
- s: 1112,
- cur: 'THX'
- },
- sizes: [[240, 400]]
- }];
-
- const request = spec.buildRequests(bidRequestData);
- const req_data = JSON.parse(request.data)[0].data;
-
- expect(req_data.cur).to.equal('THX');
- });
- it('validate default cur USD', function() {
- const bidRequestData = [{
- bidId: 'bid1234',
- bidder: 'between',
- params: {
- w: 240,
- h: 400,
- s: 1112
- },
- sizes: [[240, 400]]
- }];
-
- const request = spec.buildRequests(bidRequestData);
- const req_data = JSON.parse(request.data)[0].data;
-
- expect(req_data.cur).to.equal('USD');
- });
- it('validate subid param', function() {
- const bidRequestData = [{
- bidId: 'bid1234',
- bidder: 'between',
- params: {
- w: 240,
- h: 400,
- s: 1112,
- subid: 1138,
- },
- sizes: [[240, 400]]
- }];
-
- const request = spec.buildRequests(bidRequestData);
- const req_data = JSON.parse(request.data)[0].data;
-
- expect(req_data.subid).to.equal(1138);
- });
-
- it('validate eids parameter', function() {
- const USER_ID_DATA = [
- {
- source: 'admixer.net',
- uids: [
- { id: '5706411dc1c54268ac2ed668b27f92a3', atype: 3 }
- ]
- }
- ];
-
- const bidRequestData = [{
- bidId: 'bid1234',
- bidder: 'between',
- params: {
- w: 240,
- h: 400,
- s: 1112,
- },
- sizes: [[240, 400]],
- userIdAsEids: USER_ID_DATA,
- }];
-
- const request = spec.buildRequests(bidRequestData);
- const req_data = JSON.parse(request.data)[0].data;
-
- expect(req_data.eids).to.have.deep.members(USER_ID_DATA);
- });
-
- it('validate eids parameter, if userIdAsEids = undefined', function() {
- const bidRequestData = [{
- bidId: 'bid1234',
- bidder: 'between',
- params: {
- w: 240,
- h: 400,
- s: 1112,
- },
- sizes: [[240, 400]],
- userIdAsEids: undefined
- }];
-
- const request = spec.buildRequests(bidRequestData);
- const req_data = JSON.parse(request.data)[0].data;
-
- expect(req_data.eids).to.have.deep.members([]);
- });
-
- it('validate click3rd param', function() {
- const bidRequestData = [{
- bidId: 'bid1234',
- bidder: 'between',
- params: {
- w: 240,
- h: 400,
- s: 1112,
- click3rd: 'https://something.url',
- },
- sizes: [[240, 400]]
- }];
-
- const request = spec.buildRequests(bidRequestData);
- const req_data = JSON.parse(request.data)[0].data;
-
- expect(req_data.click3rd).to.equal('https://something.url');
- });
- it('validate pubdata param', function() {
- const bidRequestData = [{
- bidId: 'bid1234',
- bidder: 'between',
- params: {
- w: 240,
- h: 400,
- s: 1112,
- pubdata: {
- param: '&test=tset'
- },
- },
- sizes: [[240, 400]]
- }];
-
- const request = spec.buildRequests(bidRequestData);
- const req_data = JSON.parse(request.data)[0].data;
-
- expect(req_data['pubside_macro[param]']).to.equal('%26test%3Dtset');
- });
- it('validate gdprConsent', function() {
- const bidRequestData = [{
- bidId: 'bid1234',
- bidder: 'between',
- params: {
- w: 240,
- h: 400,
- s: 1112,
- },
- sizes: [[240, 400]]
- }];
- const bidderRequest = {
- gdprConsent: {
- consentString: 'BOtGbjbOtGbjbBQABBENC3-AAAAtR7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4u_1vf99yfm1-7etr3tp_87ues2_Xur__79__3z3_9pxP78k89r7337Ew_v-_v-b7JCON_IA',
- gdprApplies: true
- }
- }
-
- const request = spec.buildRequests(bidRequestData, bidderRequest);
- const req_data = JSON.parse(request.data)[0].data;
-
- expect(req_data.gdprApplies).to.equal(bidderRequest.gdprConsent.gdprApplies);
- expect(req_data.consentString).to.equal(bidderRequest.gdprConsent.consentString);
- });
- it('validate_response_params', function () {
- const serverResponse = {
- body: [{
- bidid: 'bid1234',
- cpm: 1.12,
- w: 240,
- h: 400,
- currency: 'USD',
- ad: 'Ad html'
- }]
- };
- const bids = spec.interpretResponse(serverResponse);
- expect(bids).to.have.lengthOf(1);
- const bid = bids[0];
- expect(bid.cpm).to.equal(1.12);
- 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 () {
- const serverResponse = {
- body: [{
- bidid: 'bid1234',
- w: 240,
- h: 400,
- currency: 'USD',
- ad: 'Ad html'
- }]
- };
- const bids = spec.interpretResponse(serverResponse);
- expect(bids).to.have.lengthOf(1);
- const 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');
- });
-
- it('validate_response_video_params', function () {
- const serverResponse = {
- body: [{
- mediaType: 2,
- vastXml: 'vastXml',
- }]
- };
- const bids = spec.interpretResponse(serverResponse);
- expect(bids).to.have.lengthOf(1);
- const bid = bids[0];
- expect(bid.mediaType).to.equal(2);
- expect(bid.vastXml).to.equal('vastXml');
- });
-
- it('validate response params without currency', function () {
- const serverResponse = {
- body: [{
- bidid: 'bid1234',
- w: 240,
- h: 400,
- ad: 'Ad html'
- }]
- };
- const bids = spec.interpretResponse(serverResponse);
- expect(bids).to.have.lengthOf(1);
- const bid = bids[0];
- expect(bid.currency).to.equal('USD');
- });
- it('check getUserSyncs', function() {
- const syncs = spec.getUserSyncs({}, {});
- expect(syncs).to.be.an('array').that.to.have.lengthOf(2);
- expect(syncs[0]).to.deep.equal({type: 'iframe', url: 'https://ads.betweendigital.com/sspmatch-iframe'});
- expect(syncs[1]).to.deep.equal({type: 'image', url: 'https://ads.betweendigital.com/sspmatch'});
- });
-
- it('check sizes', function() {
- const bidRequestData = [{
- bidId: 'bid1234',
- bidder: 'between',
- mediaTypes: {
- banner: {
- sizes: [[970, 250], [240, 400], [728, 90]]
- }
- },
- params: {
- s: 1112,
- },
- }];
-
- const request = spec.buildRequests(bidRequestData);
- const req_data = JSON.parse(request.data)[0].data;
-
- expect(req_data.sizes).to.deep.equal(['970x250', '240x400', '728x90'])
- });
-
- it('check adomain', function() {
- const serverResponse = {
- body: [{
- bidid: 'bid1234',
- cpm: 1.12,
- w: 240,
- h: 400,
- currency: 'USD',
- ad: 'Ad html',
- adomain: ['domain1.com', 'domain2.com']
- }]
- };
- const bids = spec.interpretResponse(serverResponse);
- expect(bids).to.have.lengthOf(1);
- const bid = bids[0];
- expect(bid.meta.advertiserDomains).to.deep.equal(['domain1.com', 'domain2.com']);
- });
- it('check server response without adomain', function() {
- const serverResponse = {
- body: [{
- bidid: 'bid1234',
- cpm: 1.12,
- w: 240,
- h: 400,
- currency: 'USD',
- ad: 'Ad html',
- }]
- };
- const bids = spec.interpretResponse(serverResponse);
- expect(bids).to.have.lengthOf(1);
- const bid = bids[0];
- expect(bid.meta.advertiserDomains).to.deep.equal([]);
- });
-});
diff --git a/test/spec/modules/beyondmediaBidAdapter_spec.js b/test/spec/modules/beyondmediaBidAdapter_spec.js
deleted file mode 100644
index 79bf88cb6..000000000
--- a/test/spec/modules/beyondmediaBidAdapter_spec.js
+++ /dev/null
@@ -1,466 +0,0 @@
-import { expect } from 'chai';
-import { spec } from '../../../modules/beyondmediaBidAdapter.js';
-import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js';
-import { getUniqueIdentifierStr } from '../../../src/utils.js';
-
-const bidder = 'beyondmedia';
-
-describe('AndBeyondMediaBidAdapter', function () {
- const userIdAsEids = [{
- source: 'test.org',
- uids: [{
- id: '01**********',
- atype: 1,
- ext: {
- third: '01***********'
- }
- }]
- }];
- const bids = [
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
- placementId: 'testBanner'
- },
- userIdAsEids
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [VIDEO]: {
- playerSize: [[300, 300]],
- minduration: 5,
- maxduration: 60
- }
- },
- params: {
- placementId: 'testVideo'
- },
- userIdAsEids
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [NATIVE]: {
- native: {
- title: {
- required: true
- },
- body: {
- required: true
- },
- icon: {
- required: true,
- size: [64, 64]
- }
- }
- }
- },
- params: {
- placementId: 'testNative'
- },
- userIdAsEids
- }
- ];
-
- const invalidBid = {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
-
- }
- }
-
- const bidderRequest = {
- uspConsent: '1---',
- gdprConsent: {
- consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw',
- vendorData: {}
- },
- refererInfo: {
- referer: 'https://test.com',
- page: 'https://test.com'
- },
- ortb2: {
- device: {
- w: 1512,
- h: 982,
- language: 'en-UK'
- }
- },
- timeout: 500
- };
-
- describe('isBidRequestValid', function () {
- it('Should return true if there are bidId, params and key parameters present', function () {
- expect(spec.isBidRequestValid(bids[0])).to.be.true;
- });
- it('Should return false if at least one of parameters is not present', function () {
- expect(spec.isBidRequestValid(invalidBid)).to.be.false;
- });
- });
-
- describe('buildRequests', function () {
- let serverRequest = spec.buildRequests(bids, bidderRequest);
-
- it('Creates a ServerRequest object with method, URL and data', function () {
- expect(serverRequest).to.exist;
- expect(serverRequest.method).to.exist;
- expect(serverRequest.url).to.exist;
- expect(serverRequest.data).to.exist;
- });
-
- it('Returns POST method', function () {
- expect(serverRequest.method).to.equal('POST');
- });
-
- it('Returns valid URL', function () {
- expect(serverRequest.url).to.equal('https://backend.andbeyond.media/pbjs');
- });
-
- it('Returns general data valid', function () {
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.all.keys('deviceWidth',
- 'deviceHeight',
- 'device',
- 'language',
- 'secure',
- 'host',
- 'page',
- 'placements',
- 'coppa',
- 'ccpa',
- 'gdpr',
- 'tmax',
- 'bcat',
- 'badv',
- 'bapp',
- 'battr'
- );
- expect(data.deviceWidth).to.be.a('number');
- expect(data.deviceHeight).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');
- expect(data.page).to.be.a('string');
- expect(data.coppa).to.be.a('number');
- expect(data.gdpr).to.be.a('object');
- expect(data.ccpa).to.be.a('string');
- expect(data.tmax).to.be.a('number');
- expect(data.placements).to.have.lengthOf(3);
- });
-
- it('Returns valid placements', function () {
- const { placements } = serverRequest.data;
- for (let i = 0, len = placements.length; i < len; i++) {
- const placement = placements[i];
- expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']);
- expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]);
- expect(placement.bidId).to.be.a('string');
- expect(placement.schain).to.be.an('object');
- expect(placement.bidfloor).to.exist.and.to.equal(0);
- expect(placement.type).to.exist.and.to.equal('publisher');
-
- if (placement.adFormat === BANNER) {
- expect(placement.sizes).to.be.an('array');
- }
- switch (placement.adFormat) {
- case BANNER:
- expect(placement.sizes).to.be.an('array');
- break;
- case VIDEO:
- expect(placement.playerSize).to.be.an('array');
- expect(placement.minduration).to.be.an('number');
- expect(placement.maxduration).to.be.an('number');
- break;
- case NATIVE:
- expect(placement.native).to.be.an('object');
- break;
- }
- }
- });
-
- it('Returns data with gdprConsent and without uspConsent', function () {
- delete bidderRequest.uspConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.gdpr).to.exist;
- expect(data.gdpr).to.be.a('object');
- expect(data.gdpr).to.have.property('consentString');
- expect(data.gdpr).to.not.have.property('vendorData');
- expect(data.gdpr.consentString).to.equal(bidderRequest.gdprConsent.consentString);
- expect(data.ccpa).to.not.exist;
- delete bidderRequest.gdprConsent;
- });
-
- it('Returns data with uspConsent and without gdprConsent', function () {
- bidderRequest.uspConsent = '1---';
- delete bidderRequest.gdprConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.ccpa).to.exist;
- expect(data.ccpa).to.be.a('string');
- expect(data.ccpa).to.equal(bidderRequest.uspConsent);
- expect(data.gdpr).to.not.exist;
- });
- });
-
- describe('gpp consent', function () {
- it('bidderRequest.gppConsent', () => {
- bidderRequest.gppConsent = {
- gppString: 'abc123',
- applicableSections: [8]
- };
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
-
- delete bidderRequest.gppConsent;
- })
-
- it('bidderRequest.ortb2.regs.gpp', () => {
- bidderRequest.ortb2 = bidderRequest.ortb2 || {};
- bidderRequest.ortb2.regs = bidderRequest.ortb2.regs || {};
- bidderRequest.ortb2.regs.gpp = 'abc123';
- bidderRequest.ortb2.regs.gpp_sid = [8];
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
- })
- });
-
- describe('interpretResponse', function () {
- it('Should interpret banner response', function () {
- const banner = {
- body: [{
- mediaType: 'banner',
- width: 300,
- height: 250,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const bannerResponses = spec.interpretResponse(banner);
- expect(bannerResponses).to.be.an('array').that.is.not.empty;
- const dataItem = bannerResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal(banner.body[0].requestId);
- expect(dataItem.cpm).to.equal(banner.body[0].cpm);
- expect(dataItem.width).to.equal(banner.body[0].width);
- expect(dataItem.height).to.equal(banner.body[0].height);
- expect(dataItem.ad).to.equal(banner.body[0].ad);
- expect(dataItem.ttl).to.equal(banner.body[0].ttl);
- expect(dataItem.creativeId).to.equal(banner.body[0].creativeId);
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal(banner.body[0].currency);
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should interpret video response', function () {
- const video = {
- body: [{
- vastUrl: 'test.com',
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const videoResponses = spec.interpretResponse(video);
- expect(videoResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = videoResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.5);
- expect(dataItem.vastUrl).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should interpret native response', function () {
- const native = {
- body: [{
- mediaType: 'native',
- native: {
- clickUrl: 'test.com',
- title: 'Test',
- image: 'test.com',
- impressionTrackers: ['test.com'],
- },
- ttl: 120,
- cpm: 0.4,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const nativeResponses = spec.interpretResponse(native);
- expect(nativeResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = nativeResponses[0];
- expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta');
- expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image')
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.4);
- expect(dataItem.native.clickUrl).to.equal('test.com');
- expect(dataItem.native.title).to.equal('Test');
- expect(dataItem.native.image).to.equal('test.com');
- expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty;
- expect(dataItem.native.impressionTrackers[0]).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should return an empty array if invalid banner response is passed', function () {
- const invBanner = {
- body: [{
- width: 300,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
-
- const serverResponses = spec.interpretResponse(invBanner);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid video response is passed', function () {
- const invVideo = {
- body: [{
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invVideo);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid native response is passed', function () {
- const invNative = {
- body: [{
- mediaType: 'native',
- clickUrl: 'test.com',
- title: 'Test',
- impressionTrackers: ['test.com'],
- ttl: 120,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- }]
- };
- const serverResponses = spec.interpretResponse(invNative);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid response is passed', function () {
- const invalid = {
- body: [{
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invalid);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- });
-
- describe('getUserSyncs', function() {
- it('Should return array of objects with proper sync config , include GDPR', function() {
- const syncData = spec.getUserSyncs({}, {}, {
- consentString: 'ALL',
- gdprApplies: true,
- }, {});
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://cookies.andbeyond.media/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0')
- });
- it('Should return array of objects with proper sync config , include CCPA', function() {
- const syncData = spec.getUserSyncs({}, {}, {}, {
- consentString: '1---'
- });
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://cookies.andbeyond.media/image?pbjs=1&ccpa_consent=1---&coppa=0')
- });
- it('Should return array of objects with proper sync config , include GPP', function() {
- const syncData = spec.getUserSyncs({}, {}, {}, {}, {
- gppString: 'abc123',
- applicableSections: [8]
- });
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://cookies.andbeyond.media/image?pbjs=1&gpp=abc123&gpp_sid=8&coppa=0')
- });
- });
-});
diff --git a/test/spec/modules/bidResponseFilter_spec.js b/test/spec/modules/bidResponseFilter_spec.js
index 6251fe352..e6ae0b180 100644
--- a/test/spec/modules/bidResponseFilter_spec.js
+++ b/test/spec/modules/bidResponseFilter_spec.js
@@ -11,6 +11,9 @@ import {addBidResponse} from '../../../src/auction.js';
describe('bidResponseFilter', () => {
let mockAuctionIndex
+ before(() => {
+ addBidResponse.removeAll();
+ });
beforeEach(() => {
mockAuctionIndex = {
getBidRequest: () => {
diff --git a/test/spec/modules/biddoBidAdapter_spec.js b/test/spec/modules/biddoBidAdapter_spec.js
deleted file mode 100644
index 25986b340..000000000
--- a/test/spec/modules/biddoBidAdapter_spec.js
+++ /dev/null
@@ -1,172 +0,0 @@
-import {expect} from 'chai';
-import {spec} from 'modules/biddoBidAdapter.js';
-
-describe('biddo bid adapter tests', function () {
- describe('bid requests', function () {
- it('should accept valid bid', function () {
- const validBid = {
- bidder: 'biddo',
- params: {zoneId: 123},
- };
-
- expect(spec.isBidRequestValid(validBid)).to.equal(true);
- });
-
- it('should reject invalid bid', function () {
- const invalidBid = {
- bidder: 'biddo',
- params: {},
- };
-
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
-
- it('should correctly build payload string', function () {
- const bidRequests = [{
- bidder: 'biddo',
- params: {zoneId: 123},
- mediaTypes: {
- banner: {
- sizes: [[300, 250]],
- },
- },
- bidId: '23acc48ad47af5',
- auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99',
- bidderRequestId: '1c56ad30b9b8ca8',
- transactionId: '92489f71-1bf2-49a0-adf9-000cea934729',
- }];
- const payload = spec.buildRequests(bidRequests)[0].data;
-
- expect(payload).to.contain('ctype=div');
- expect(payload).to.contain('pzoneid=123');
- expect(payload).to.contain('width=300');
- expect(payload).to.contain('height=250');
- });
-
- it('should support multiple bids', function () {
- const bidRequests = [{
- bidder: 'biddo',
- params: {zoneId: 123},
- mediaTypes: {
- banner: {
- sizes: [[300, 250]],
- },
- },
- bidId: '23acc48ad47af5',
- auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99',
- bidderRequestId: '1c56ad30b9b8ca8',
- transactionId: '92489f71-1bf2-49a0-adf9-000cea934729',
- }, {
- bidder: 'biddo',
- params: {zoneId: 321},
- mediaTypes: {
- banner: {
- sizes: [[728, 90]],
- },
- },
- bidId: '23acc48ad47af52',
- auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba992',
- bidderRequestId: '1c56ad30b9b8ca82',
- transactionId: '92489f71-1bf2-49a0-adf9-000cea9347292',
- }];
- const payload = spec.buildRequests(bidRequests);
-
- expect(payload).to.be.lengthOf(2);
- });
-
- it('should support multiple sizes', function () {
- const bidRequests = [{
- bidder: 'biddo',
- params: {zoneId: 123},
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [300, 600]],
- },
- },
- bidId: '23acc48ad47af5',
- auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99',
- bidderRequestId: '1c56ad30b9b8ca8',
- transactionId: '92489f71-1bf2-49a0-adf9-000cea934729',
- }];
- const payload = spec.buildRequests(bidRequests);
-
- expect(payload).to.be.lengthOf(2);
- });
- });
-
- describe('bid responses', function () {
- it('should return complete bid response', function () {
- const serverResponse = {
- body: {
- banner: {
- hash: '1c56ad30b9b8ca8',
- },
- hb: {
- cpm: 0.5,
- netRevenue: false,
- adomains: ['securepubads.g.doubleclick.net'],
- },
- template: {
- html: '
',
- },
- },
- };
- const bidderRequest = {
- bidId: '23acc48ad47af5',
- params: {
- requestedSizes: [300, 250],
- },
- };
-
- const bids = spec.interpretResponse(serverResponse, {bidderRequest});
-
- expect(bids).to.be.lengthOf(1);
- expect(bids[0].requestId).to.equal('23acc48ad47af5');
- expect(bids[0].creativeId).to.equal('1c56ad30b9b8ca8');
- expect(bids[0].width).to.equal(300);
- expect(bids[0].height).to.equal(250);
- expect(bids[0].ttl).to.equal(600);
- expect(bids[0].cpm).to.equal(0.5);
- expect(bids[0].netRevenue).to.equal(false);
- expect(bids[0].currency).to.equal('USD');
- expect(bids[0].meta.advertiserDomains).to.be.lengthOf(1);
- expect(bids[0].meta.advertiserDomains[0]).to.equal('securepubads.g.doubleclick.net');
- });
-
- it('should return empty bid response', function () {
- const serverResponse = {
- body: {},
- };
- const bidderRequest = {
- bidId: '23acc48ad47af5',
- params: {
- requestedSizes: [300, 250],
- },
- };
-
- const bids = spec.interpretResponse(serverResponse, {bidderRequest});
-
- expect(bids).to.be.lengthOf(0);
- });
-
- it('should return empty bid response 2', function () {
- const serverResponse = {
- body: {
- template: {
- html: '',
- }
- },
- };
- const bidderRequest = {
- bidId: '23acc48ad47af5',
- params: {
- requestedSizes: [300, 250],
- },
- };
-
- const bids = spec.interpretResponse(serverResponse, {bidderRequest});
-
- expect(bids).to.be.lengthOf(0);
- });
- });
-});
diff --git a/test/spec/modules/bidfuseBidAdapter_spec.js b/test/spec/modules/bidfuseBidAdapter_spec.js
deleted file mode 100644
index 95c84dcdf..000000000
--- a/test/spec/modules/bidfuseBidAdapter_spec.js
+++ /dev/null
@@ -1,552 +0,0 @@
-import { expect } from 'chai';
-import { spec } from '../../../modules/bidfuseBidAdapter.js';
-import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js';
-import { getUniqueIdentifierStr } from '../../../src/utils.js';
-import { config } from "../../../src/config.ts";
-
-const bidder = 'bidfuse';
-
-describe('BidfuseBidAdapter', function () {
- const userIdAsEids = [{
- source: 'test.org',
- uids: [{
- id: '01**********',
- atype: 1,
- ext: {
- third: '01***********'
- }
- }]
- }];
- const bids = [
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
- placementId: 'testBanner'
- },
- userIdAsEids
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [VIDEO]: {
- playerSize: [[300, 300]],
- minduration: 5,
- maxduration: 60
- }
- },
- params: {
- placementId: 'testVideo'
- },
- userIdAsEids
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [NATIVE]: {
- native: {
- title: {
- required: true
- },
- body: {
- required: true
- },
- icon: {
- required: true,
- size: [64, 64]
- }
- }
- }
- },
- params: {
- placementId: 'testNative'
- },
- userIdAsEids
- }
- ];
-
- const invalidBid = {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
-
- }
- }
-
- const bidderRequest = {
- uspConsent: '1---',
- gdprConsent: {
- consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw',
- vendorData: {}
- },
- refererInfo: {
- referer: 'https://test.com',
- page: 'https://test.com'
- },
- ortb2: {
- device: {
- w: 1512,
- h: 982,
- language: 'en-UK'
- }
- },
- timeout: 500
- };
-
- const serverResponse = {
- body: {
- cid: 'testcid123',
- results: [{
- 'ad': '
',
- 'price': 0.8,
- 'creativeId': '12610997325162499419',
- 'exp': 30,
- 'width': 300,
- 'height': 250,
- 'advertiserDomains': ['securepubads.g.doubleclick.net']
- }]
- }
- };
-
- describe('isBidRequestValid', function () {
- it('Should return true if there are bidId, params and key parameters present', function () {
- expect(spec.isBidRequestValid(bids[0])).to.be.true;
- });
- it('Should return false if at least one of parameters is not present', function () {
- expect(spec.isBidRequestValid(invalidBid)).to.be.false;
- });
- });
-
- describe('buildRequests', function () {
- let serverRequest = spec.buildRequests(bids, bidderRequest);
-
- it('Creates a ServerRequest object with method, URL and data', function () {
- expect(serverRequest).to.exist;
- expect(serverRequest.method).to.exist;
- expect(serverRequest.url).to.exist;
- expect(serverRequest.data).to.exist;
- });
-
- it('Returns POST method', function () {
- expect(serverRequest.method).to.equal('POST');
- });
-
- it('Returns valid URL', function () {
- expect(serverRequest.url).to.equal('https://bn.bidfuse.com/pbjs');
- });
-
- it('Returns general data valid', function () {
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.all.keys('deviceWidth',
- 'deviceHeight',
- 'device',
- 'language',
- 'secure',
- 'host',
- 'page',
- 'placements',
- 'coppa',
- 'ccpa',
- 'gdpr',
- 'tmax',
- 'bcat',
- 'badv',
- 'bapp',
- 'battr'
- );
- expect(data.deviceWidth).to.be.a('number');
- expect(data.deviceHeight).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');
- expect(data.page).to.be.a('string');
- expect(data.coppa).to.be.a('number');
- expect(data.gdpr).to.be.a('object');
- expect(data.ccpa).to.be.a('string');
- expect(data.tmax).to.be.a('number');
- expect(data.placements).to.have.lengthOf(3);
- });
-
- it('Returns valid placements', function () {
- const { placements } = serverRequest.data;
- for (let i = 0, len = placements.length; i < len; i++) {
- const placement = placements[i];
- expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']);
- expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]);
- expect(placement.bidId).to.be.a('string');
- expect(placement.schain).to.be.an('object');
- expect(placement.bidfloor).to.exist.and.to.equal(0);
- expect(placement.type).to.exist.and.to.equal('publisher');
- expect(placement.eids).to.exist.and.to.be.deep.equal(userIdAsEids);
-
- if (placement.adFormat === BANNER) {
- expect(placement.sizes).to.be.an('array');
- }
- switch (placement.adFormat) {
- case BANNER:
- expect(placement.sizes).to.be.an('array');
- break;
- case VIDEO:
- expect(placement.playerSize).to.be.an('array');
- expect(placement.minduration).to.be.an('number');
- expect(placement.maxduration).to.be.an('number');
- break;
- case NATIVE:
- expect(placement.native).to.be.an('object');
- break;
- }
- }
- });
-
- it('Returns valid endpoints', function () {
- const bids = [
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
- endpointId: 'testBanner',
- },
- userIdAsEids
- }
- ];
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
-
- const { placements } = serverRequest.data;
- for (let i = 0, len = placements.length; i < len; i++) {
- const placement = placements[i];
- expect(placement.endpointId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']);
- expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]);
- expect(placement.bidId).to.be.a('string');
- expect(placement.schain).to.be.an('object');
- expect(placement.bidfloor).to.exist.and.to.equal(0);
- expect(placement.type).to.exist.and.to.equal('network');
- expect(placement.eids).to.exist.and.to.be.deep.equal(userIdAsEids);
-
- if (placement.adFormat === BANNER) {
- expect(placement.sizes).to.be.an('array');
- }
- switch (placement.adFormat) {
- case BANNER:
- expect(placement.sizes).to.be.an('array');
- break;
- case VIDEO:
- expect(placement.playerSize).to.be.an('array');
- expect(placement.minduration).to.be.an('number');
- expect(placement.maxduration).to.be.an('number');
- break;
- case NATIVE:
- expect(placement.native).to.be.an('object');
- break;
- }
- }
- });
-
- it('Returns data with gdprConsent and without uspConsent', function () {
- delete bidderRequest.uspConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.gdpr).to.exist;
- expect(data.gdpr).to.be.a('object');
- expect(data.gdpr).to.have.property('consentString');
- expect(data.gdpr).to.not.have.property('vendorData');
- expect(data.gdpr.consentString).to.equal(bidderRequest.gdprConsent.consentString);
- expect(data.ccpa).to.not.exist;
- delete bidderRequest.gdprConsent;
- });
-
- it('Returns data with uspConsent and without gdprConsent', function () {
- bidderRequest.uspConsent = '1---';
- delete bidderRequest.gdprConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.ccpa).to.exist;
- expect(data.ccpa).to.be.a('string');
- expect(data.ccpa).to.equal(bidderRequest.uspConsent);
- expect(data.gdpr).to.not.exist;
- });
- });
-
- describe('getUserSyncs', function () {
- it('should have valid user sync with iframeEnabled', function () {
- const result = spec.getUserSyncs({iframeEnabled: true}, [serverResponse]);
-
- expect(result).to.deep.equal([{
- type: 'iframe',
- url: 'https://syncbf.bidfuse.com/iframe?pbjs=1&coppa=0'
- }]);
- });
-
- it('should have valid user sync with cid on response', function () {
- const result = spec.getUserSyncs({iframeEnabled: true}, [serverResponse]);
- expect(result).to.deep.equal([{
- type: 'iframe',
- url: 'https://syncbf.bidfuse.com/iframe?pbjs=1&coppa=0'
- }]);
- });
-
- it('should have valid user sync with pixelEnabled', function () {
- const result = spec.getUserSyncs({pixelEnabled: true}, [serverResponse]);
-
- expect(result).to.deep.equal([{
- 'url': 'https://syncbf.bidfuse.com/image?pbjs=1&coppa=0',
- 'type': 'image'
- }]);
- });
-
- it('should have valid user sync with coppa 1 on response', function () {
- config.setConfig({
- coppa: 1
- });
- const result = spec.getUserSyncs({iframeEnabled: true}, [serverResponse]);
- expect(result).to.deep.equal([{
- type: 'iframe',
- url: 'https://syncbf.bidfuse.com/iframe?pbjs=1&coppa=1'
- }]);
- });
-
- it('should generate url with consent data', function () {
- const gdprConsent = {
- gdprApplies: true,
- consentString: 'consent_string'
- };
- const uspConsent = 'usp_string';
- const gppConsent = {
- gppString: 'gpp_string',
- applicableSections: [7]
- }
-
- const result = spec.getUserSyncs({pixelEnabled: true}, [serverResponse], gdprConsent, uspConsent, gppConsent);
-
- expect(result).to.deep.equal([{
- 'url': 'https://syncbf.bidfuse.com/image?pbjs=1&gdpr=1&gdpr_consent=consent_string&gpp=gpp_string&gpp_sid=7&coppa=1',
- 'type': 'image'
- }]);
- });
- });
-
- describe('gpp consent', function () {
- it('bidderRequest.gppConsent', () => {
- bidderRequest.gppConsent = {
- gppString: 'abc123',
- applicableSections: [8]
- };
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
-
- delete bidderRequest.gppConsent;
- })
-
- it('bidderRequest.ortb2.regs.gpp', () => {
- bidderRequest.ortb2 = bidderRequest.ortb2 || {};
- bidderRequest.ortb2.regs = bidderRequest.ortb2.regs || {};
- bidderRequest.ortb2.regs.gpp = 'abc123';
- bidderRequest.ortb2.regs.gpp_sid = [8];
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
- })
- });
-
- describe('interpretResponse', function () {
- it('Should interpret banner response', function () {
- const banner = {
- body: [{
- mediaType: 'banner',
- width: 300,
- height: 250,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const bannerResponses = spec.interpretResponse(banner);
- expect(bannerResponses).to.be.an('array').that.is.not.empty;
- const dataItem = bannerResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal(banner.body[0].requestId);
- expect(dataItem.cpm).to.equal(banner.body[0].cpm);
- expect(dataItem.width).to.equal(banner.body[0].width);
- expect(dataItem.height).to.equal(banner.body[0].height);
- expect(dataItem.ad).to.equal(banner.body[0].ad);
- expect(dataItem.ttl).to.equal(banner.body[0].ttl);
- expect(dataItem.creativeId).to.equal(banner.body[0].creativeId);
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal(banner.body[0].currency);
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should interpret video response', function () {
- const video = {
- body: [{
- vastUrl: 'test.com',
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const videoResponses = spec.interpretResponse(video);
- expect(videoResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = videoResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.5);
- expect(dataItem.vastUrl).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should interpret native response', function () {
- const native = {
- body: [{
- mediaType: 'native',
- native: {
- clickUrl: 'test.com',
- title: 'Test',
- image: 'test.com',
- impressionTrackers: ['test.com'],
- },
- ttl: 120,
- cpm: 0.4,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const nativeResponses = spec.interpretResponse(native);
- expect(nativeResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = nativeResponses[0];
- expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta');
- expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image')
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.4);
- expect(dataItem.native.clickUrl).to.equal('test.com');
- expect(dataItem.native.title).to.equal('Test');
- expect(dataItem.native.image).to.equal('test.com');
- expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty;
- expect(dataItem.native.impressionTrackers[0]).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should return an empty array if invalid banner response is passed', function () {
- const invBanner = {
- body: [{
- width: 300,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
-
- const serverResponses = spec.interpretResponse(invBanner);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid video response is passed', function () {
- const invVideo = {
- body: [{
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invVideo);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid native response is passed', function () {
- const invNative = {
- body: [{
- mediaType: 'native',
- clickUrl: 'test.com',
- title: 'Test',
- impressionTrackers: ['test.com'],
- ttl: 120,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- }]
- };
- const serverResponses = spec.interpretResponse(invNative);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid response is passed', function () {
- const invalid = {
- body: [{
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invalid);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- });
-});
diff --git a/test/spec/modules/bidmaticBidAdapter_spec.js b/test/spec/modules/bidmaticBidAdapter_spec.js
deleted file mode 100644
index dfce07648..000000000
--- a/test/spec/modules/bidmaticBidAdapter_spec.js
+++ /dev/null
@@ -1,433 +0,0 @@
-import { expect } from 'chai';
-import { bidToTag, remapBidRequest, prepareBidRequests, createBid, parseResponseBody, getResponseSyncs, getUserSyncsFn, spec } from 'modules/bidmaticBidAdapter.js';
-import { config } from 'src/config.js';
-import { newBidder } from 'src/adapters/bidderFactory.js';
-import { deepClone } from 'src/utils.js';
-import { BANNER, VIDEO } from 'src/mediaTypes.js';
-
-describe('bidmaticBidAdapter', function () {
- const adapter = newBidder(spec);
- const URL = 'https://adapter.bidmatic.io/bdm/auction';
-
- const DEFAULT_BID_REQUEST = {
- 'bidder': 'bidmatic',
- 'params': {
- 'source': 123456
- },
- 'mediaTypes': {
- 'banner': {
- 'sizes': [[300, 250], [300, 600]]
- }
- },
- 'adUnitCode': 'test-div',
- "ortb2Imp": {
- "ext": {
- "gpid": "123456/test-div"
- }
- },
- 'bidId': 'bid123456',
- 'bidderRequestId': 'req123456',
- 'auctionId': 'auct123456',
- 'schain': { ver: '1.0' },
- 'userId': { id1: 'value1' },
- };
-
- const VIDEO_BID_REQUEST = {
- 'bidder': 'bidmatic',
- 'params': {
- 'source': 123456
- },
- "ortb2Imp": {
- "ext": {
- "gpid": "123456/test-div-video"
- }
- },
- 'mediaTypes': {
- 'video': {
- 'playerSize': [[640, 480]]
- }
- },
- 'adUnitCode': 'test-div-video',
- 'bidId': 'bid123456-video',
- 'bidderRequestId': 'req123456',
- 'auctionId': 'auct123456',
- };
-
- const BID_RESPONSE = {
- 'bids': [{
- 'requestId': 'bid123456',
- 'cmpId': 'creative123',
- 'height': 250,
- 'width': 300,
- 'cpm': 0.5,
- 'ad': '
test ad
',
- 'cur': 'USD',
- 'adomain': ['advertiser.com']
- }],
- 'cookieURLs': ['https://sync.bidmatic.com/sync1', 'https://sync.bidmatic.com/sync2'],
- 'cookieURLSTypes': ['iframe', 'image']
- };
-
- const VIDEO_BID_RESPONSE = {
- 'bids': [{
- 'requestId': 'bid123456-video',
- 'cmpId': 'creative123',
- 'height': 480,
- 'width': 640,
- 'cpm': 0.5,
- 'vastUrl': 'https://vast.bidmatic.com/vast.xml',
- 'cur': 'USD',
- 'adomain': ['advertiser.com']
- }],
- 'cookieURLs': ['https://sync.bidmatic.com/sync1']
- };
-
- const BID_REQUEST_PARAMS = {
- 'bidderCode': 'bidmatic',
- 'bidderRequestId': 'req123456',
- 'auctionId': 'auct123456',
- 'timeout': 1000,
- 'refererInfo': {
- 'page': 'https://example.com'
- },
- 'bids': [DEFAULT_BID_REQUEST]
- };
-
- const CONSENTS_PARAMS = {
- 'gdprConsent': {
- 'gdprApplies': true,
- 'consentString': 'CONSENT_STRING',
- },
- 'gppConsent': {
- 'gppString': 'GPP_STRING',
- 'applicableSections': [1, 2, 3]
- },
- 'uspConsent': 'USP_STRING',
- 'ortb2': {
- 'regs': {
- 'coppa': 1,
- 'gpp': 'GPP_FROM_ORTB2',
- 'gpp_sid': [1, 2, 3],
- 'ext': {
- 'age_verification': { 'id': 'age123' }
- }
- }
- }
- };
-
- const BID_REQUEST_WITH_CONSENT = {
- ...BID_REQUEST_PARAMS,
- ...CONSENTS_PARAMS
- };
-
- describe('inherited functions', function () {
- it('exists and is a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('isBidRequestValid', function () {
- it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(DEFAULT_BID_REQUEST)).to.equal(true);
- });
-
- it('should return false when source is not a number', function () {
- const bid = deepClone(DEFAULT_BID_REQUEST);
- bid.params.source = '123456';
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return false when params are missing', function () {
- const bid = deepClone(DEFAULT_BID_REQUEST);
- delete bid.params;
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
- });
-
- describe('prepareBidRequests', function () {
- it('should prepare banner bid request correctly', function () {
- const result = prepareBidRequests(DEFAULT_BID_REQUEST);
-
- expect(result).includes({
- 'CallbackId': 'bid123456',
- 'Aid': 123456,
- 'AdType': 'display',
- 'PlacementId': 'test-div',
- 'Sizes': '300x250,300x600',
- 'GPID': '123456/test-div',
- });
- });
-
- it('should prepare video bid request correctly', function () {
- const result = prepareBidRequests(VIDEO_BID_REQUEST);
-
- expect(result).includes({
- 'CallbackId': 'bid123456-video',
- 'Aid': 123456,
- 'AdType': 'video',
- 'PlacementId': 'test-div-video',
- 'Sizes': '640x480',
- 'GPID': '123456/test-div-video',
- });
- });
- });
-
- describe('remapBidRequest', function () {
- it('should remap bid request with basic params', function () {
- const result = remapBidRequest([DEFAULT_BID_REQUEST], BID_REQUEST_PARAMS);
-
- expect(result).includes({
- 'Domain': 'https://example.com',
- 'Tmax': 1000,
- 'Coppa': 0
- });
- expect(result.Schain).to.deep.equal({ ver: '1.0' });
- expect(result.UserIds).to.deep.equal({ id1: 'value1' });
- });
-
- it('should remap bid request with consent params', function () {
- const result = remapBidRequest([DEFAULT_BID_REQUEST], BID_REQUEST_WITH_CONSENT);
-
- expect(result).to.include({
- 'Domain': 'https://example.com',
- 'USP': 'USP_STRING',
- 'GPP': 'GPP_STRING',
- 'GPPSid': '1,2,3',
- 'GDPRConsent': 'CONSENT_STRING',
- 'GDPR': 1,
- 'Coppa': 1
- });
- expect(result.AgeVerification).to.deep.equal({ id: 'age123' });
- });
- });
-
- describe('bidToTag', function () {
- it('should convert bid requests to tag format', function () {
- const { tag, bids } = bidToTag([DEFAULT_BID_REQUEST], BID_REQUEST_PARAMS);
-
- expect(tag).to.be.an('object');
- expect(bids).to.be.an('array');
- expect(bids.length).to.equal(1);
- expect(bids[0]).includes({
- 'CallbackId': 'bid123456',
- 'Aid': 123456,
- 'AdType': 'display',
- 'PlacementId': 'test-div',
- 'Sizes': '300x250,300x600',
- 'GPID': '123456/test-div',
- });
- });
- });
-
- describe('buildRequests', function () {
- it('should build banner request correctly', function () {
- const requests = spec.buildRequests([DEFAULT_BID_REQUEST], BID_REQUEST_PARAMS);
-
- expect(requests).to.be.an('array');
- expect(requests.length).to.equal(1);
- expect(requests[0].url).to.equal(URL);
- expect(requests[0].method).to.equal('POST');
- expect(requests[0].data).to.have.property('BidRequests');
- expect(requests[0].data.BidRequests.length).to.equal(1);
- });
-
- it('should chunk bid requests according to adapter settings', function () {
- const sandbox = sinon.createSandbox();
- sandbox.stub(config, 'getConfig').returns({ chunkSize: 2 });
-
- const requests = spec.buildRequests([
- DEFAULT_BID_REQUEST,
- deepClone(DEFAULT_BID_REQUEST),
- deepClone(DEFAULT_BID_REQUEST)
- ], BID_REQUEST_PARAMS);
-
- expect(requests.length).to.equal(2);
- expect(requests[0].data.BidRequests.length).to.equal(2);
- expect(requests[1].data.BidRequests.length).to.equal(1);
-
- sandbox.restore();
- });
- });
-
- describe('createBid', function () {
- it('should create banner bid correctly', function () {
- const bid = createBid(BID_RESPONSE.bids[0], { mediaTypes: { banner: {} } });
-
- expect(bid).to.deep.include({
- requestId: 'bid123456',
- creativeId: 'creative123',
- height: 250,
- width: 300,
- cpm: 0.5,
- currency: 'USD',
- netRevenue: true,
- mediaType: BANNER,
- ttl: 300,
- ad: '
test ad
'
- });
-
- expect(bid.meta.advertiserDomains).to.deep.equal(['advertiser.com']);
- });
-
- it('should create video bid correctly', function () {
- const bid = createBid(VIDEO_BID_RESPONSE.bids[0], { mediaTypes: { video: {} } });
-
- expect(bid).to.deep.include({
- requestId: 'bid123456-video',
- creativeId: 'creative123',
- height: 480,
- width: 640,
- cpm: 0.5,
- currency: 'USD',
- netRevenue: true,
- mediaType: VIDEO,
- ttl: 300,
- vastUrl: 'https://vast.bidmatic.com/vast.xml'
- });
- });
- });
-
- describe('parseResponseBody', function () {
- it('should parse valid response', function () {
- const result = parseResponseBody(BID_RESPONSE, { bids: [DEFAULT_BID_REQUEST] });
-
- expect(result).to.be.an('array');
- expect(result.length).to.equal(1);
- expect(result[0]).to.have.property('requestId', 'bid123456');
- });
-
- it('should return empty array for invalid response', function () {
- const result = parseResponseBody({}, { bids: [DEFAULT_BID_REQUEST] });
- expect(result).to.be.an('array');
- expect(result.length).to.equal(0);
- });
-
- it('should return empty array when bid request does not match', function () {
- const result = parseResponseBody({
- bids: [{ requestId: 'non-matching-id' }]
- }, { bids: [DEFAULT_BID_REQUEST] });
-
- expect(result).to.be.an('array');
- expect(result.length).to.equal(0);
- });
- });
-
- describe('getResponseSyncs', function () {
- it('should return image syncs when pixels enabled', function () {
- const syncOptions = { pixelEnabled: true };
- const bid = {
- cookieURLSTypes: ['image'],
- cookieURLs: ['https://sync.bidmatic.com/pixel']
- };
-
- const result = getResponseSyncs(syncOptions, bid);
-
- expect(result).to.be.an('array');
- expect(result.length).to.equal(1);
- expect(result[0].type).to.equal('image');
- expect(result[0].url).to.equal('https://sync.bidmatic.com/pixel');
- });
-
- it('should return iframe syncs when iframes enabled', function () {
- const syncOptions = { iframeEnabled: true };
- const bid = {
- cookieURLSTypes: ['iframe'],
- cookieURLs: ['https://sync.bidmatic.com/iframe']
- };
-
- const result = getResponseSyncs(syncOptions, bid);
-
- expect(result).to.be.an('array');
- expect(result.length).to.equal(1);
- expect(result[0].type).to.equal('iframe');
- expect(result[0].url).to.equal('https://sync.bidmatic.com/iframe');
- });
-
- it('should not return syncs when already done', function () {
- const syncOptions = { iframeEnabled: true };
- const bid = {
- cookieURLSTypes: ['iframe'],
- cookieURLs: ['https://sync.bidmatic.com/sync-done']
- };
-
- let result = getResponseSyncs(syncOptions, bid);
- expect(result.length).to.equal(1);
-
- result = getResponseSyncs(syncOptions, bid);
- expect(result.length).to.equal(0);
- });
-
- it('should use default type image when type not specified', function () {
- const syncOptions = { pixelEnabled: true };
- const bid = {
- cookieURLs: ['https://sync.bidmatic.com/new-pixel']
- };
-
- const result = getResponseSyncs(syncOptions, bid);
-
- expect(result.length).to.equal(1);
- expect(result[0].type).to.equal('image');
- });
- });
-
- describe('getUserSyncsFn', function () {
- it('should return empty array when no syncs enabled', function () {
- const result = getUserSyncsFn({}, []);
- expect(result).to.be.undefined;
- });
-
- it('should return empty array for invalid responses', function () {
- const result = getUserSyncsFn({ pixelEnabled: true }, [{ body: null }]);
- expect(result).to.be.an('array');
- expect(result.length).to.equal(0);
- });
-
- it('should collect syncs from multiple responses', function () {
- const syncOptions = { pixelEnabled: true, iframeEnabled: true };
- const serverResponses = [
- { body: { cookieURLs: ['https://sync1.bidmatic.com/pixel'] } },
- { body: [
- { cookieURLs: ['https://sync2.bidmatic.com/iframe'], cookieURLSTypes: ['iframe'] }
- ]}
- ];
-
- const result = getUserSyncsFn(syncOptions, serverResponses);
-
- expect(result).to.be.an('array');
- expect(result.length).to.equal(2);
- });
- });
-
- describe('interpretResponse', function () {
- it('should interpret banner response correctly', function () {
- const result = spec.interpretResponse({ body: BID_RESPONSE }, { adapterRequest: { bids: [DEFAULT_BID_REQUEST] } });
-
- expect(result).to.be.an('array');
- expect(result.length).to.equal(1);
- expect(result[0].requestId).to.equal('bid123456');
- expect(result[0].mediaType).to.equal(BANNER);
- });
-
- it('should interpret video response correctly', function () {
- const result = spec.interpretResponse({ body: VIDEO_BID_RESPONSE }, { adapterRequest: { bids: [VIDEO_BID_REQUEST] } });
-
- expect(result).to.be.an('array');
- expect(result.length).to.equal(1);
- expect(result[0].requestId).to.equal('bid123456-video');
- expect(result[0].mediaType).to.equal(VIDEO);
- });
-
- it('should handle array of responses', function () {
- const result = spec.interpretResponse({ body: [BID_RESPONSE] }, { adapterRequest: { bids: [DEFAULT_BID_REQUEST] } });
-
- expect(result).to.be.an('array');
- expect(result.length).to.equal(1);
- });
-
- it('should return empty array for empty response', function () {
- const result = spec.interpretResponse({ body: { bids: [] } }, { adapterRequest: { bids: [DEFAULT_BID_REQUEST] } });
- expect(result).to.be.an('array');
- expect(result.length).to.equal(0);
- });
- });
-});
diff --git a/test/spec/modules/bidscubeBidAdapter_spec.js b/test/spec/modules/bidscubeBidAdapter_spec.js
deleted file mode 100644
index 26cf19fc3..000000000
--- a/test/spec/modules/bidscubeBidAdapter_spec.js
+++ /dev/null
@@ -1,226 +0,0 @@
-import { expect } from 'chai'
-import { spec } from '../../../modules/bidscubeBidAdapter.js'
-import { deepStrictEqual, notEqual, ok, strictEqual } from 'assert'
-
-describe('BidsCubeAdapter', () => {
- const bid = {
- bidId: '9ec5b177515ee2e5',
- bidder: 'bidscube',
- params: {
- placementId: 0,
- traffic: 'banner',
- allParams: '{}'
- }
- }
-
- describe('isBidRequestValid', () => {
- it('Should return true if there are bidId, params and placementId parameters present', () => {
- strictEqual(true, spec.isBidRequestValid(bid))
- })
-
- it('Should return false if at least one of parameters is not present', () => {
- const b = { ...bid }
- delete b.params.placementId
- strictEqual(false, spec.isBidRequestValid(b))
- })
- })
-
- describe('buildRequests', () => {
- const serverRequest = spec.buildRequests([bid])
-
- it('Creates a ServerRequest object with method, URL and data', () => {
- ok(serverRequest)
- ok(serverRequest.method)
- ok(serverRequest.url)
- ok(serverRequest.data)
- })
-
- it('Returns POST method', () => {
- strictEqual('POST', serverRequest.method)
- })
-
- it('Returns valid URL', () => {
- strictEqual('https://supply.bidscube.com/?c=o&m=multi', serverRequest.url)
- })
-
- it('Returns valid data if array of bids is valid', () => {
- const { data } = serverRequest
- strictEqual('object', typeof data)
- deepStrictEqual(['deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'], Object.keys(data))
- strictEqual('number', typeof data.deviceWidth)
- strictEqual('number', typeof data.deviceHeight)
- strictEqual('string', typeof data.language)
- strictEqual('string', typeof data.host)
- strictEqual('string', typeof data.page)
- notEqual(-1, [0, 1].indexOf(data.secure))
-
- const placement = data.placements[0]
- deepStrictEqual(['placementId', 'bidId', 'traffic', 'allParams'], Object.keys(placement))
- strictEqual(0, placement.placementId)
- strictEqual('9ec5b177515ee2e5', placement.bidId)
- strictEqual('banner', placement.traffic)
- strictEqual('{"bidId":"9ec5b177515ee2e5","bidder":"bidscube","params":{"placementId":0,"traffic":"banner","allParams":"{}"}}', placement.allParams)
- })
-
- it('Returns empty data if no valid requests are passed', () => {
- const { placements } = spec.buildRequests([]).data
-
- expect(spec.buildRequests([]).data.placements).to.be.an('array')
- strictEqual(0, placements.length)
- })
- })
-
- describe('interpretResponse', () => {
- const validData = [
- {
- body: [{
- mediaType: 'banner',
- width: 300,
- height: 250,
- cpm: 0.4,
- ad: 'Test',
- requestId: '9ec5b177515ee2e5',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['test.com']
- }
- }]
- },
- {
- body: [{
- vastUrl: 'bidscube.com',
- mediaType: 'video',
- cpm: 0.5,
- requestId: '9ec5b177515ee2e5',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['test.com']
- }
- }]
- },
- {
- body: [{
- mediaType: 'native',
- clickUrl: 'bidscube.com',
- title: 'Test',
- image: 'bidscube.com',
- creativeId: '2',
- impressionTrackers: ['bidscube.com'],
- ttl: 120,
- cpm: 0.4,
- requestId: '9ec5b177515ee2e5',
- netRevenue: true,
- currency: 'USD',
- meta: {
- advertiserDomains: ['test.com']
- }
- }]
- }
- ]
-
- for (const obj of validData) {
- const { mediaType } = obj.body[0]
-
- it(`Should interpret ${mediaType} response`, () => {
- const response = spec.interpretResponse(obj)
-
- expect(response).to.be.an('array')
- strictEqual(1, response.length)
-
- const copy = { ...obj.body[0] }
- deepStrictEqual(copy, response[0])
- })
- }
-
- for (const obj of validData) {
- it(`Should interpret response has meta.advertiserDomains`, () => {
- const response = spec.interpretResponse(obj)
-
- expect(response[0]['meta']['advertiserDomains']).to.be.an('array')
- expect(response[0]['meta']['advertiserDomains'][0]).to.be.an('string')
- })
- }
-
- const invalidData = [
- {
- body: [{
- width: 300,
- cpm: 0.4,
- ad: 'Test',
- requestId: '9ec5b177515ee2e5',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- },
- {
- body: [{
- mediaType: 'video',
- cpm: 0.5,
- requestId: '9ec5b177515ee2e5',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- },
- {
- body: [{
- mediaType: 'native',
- clickUrl: 'bidscube.com',
- title: 'Test',
- impressionTrackers: ['bidscube.com'],
- ttl: 120,
- requestId: '9ec5b177515ee2e5',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- }]
- }
- ]
-
- for (const obj of invalidData) {
- const { mediaType } = obj.body[0]
-
- it(`Should return an empty array if invalid ${mediaType} response is passed `, () => {
- const response = spec.interpretResponse(obj)
-
- expect(response).to.be.an('array')
- strictEqual(0, response.length)
- })
- }
-
- it('Should return an empty array if invalid response is passed', () => {
- const response = spec.interpretResponse({
- body: [{
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- })
-
- expect(response).to.be.an('array')
- strictEqual(0, response.length)
- })
- })
-
- describe('getUserSyncs', () => {
- it('Returns valid URL and type', () => {
- const expectedResult = [{ type: 'image', url: 'https://supply.bidscube.com/?c=o&m=cookie' }]
- deepStrictEqual(expectedResult, spec.getUserSyncs())
- })
- })
-})
diff --git a/test/spec/modules/bidtheatreBidAdapter_spec.js b/test/spec/modules/bidtheatreBidAdapter_spec.js
deleted file mode 100644
index 351f59680..000000000
--- a/test/spec/modules/bidtheatreBidAdapter_spec.js
+++ /dev/null
@@ -1,266 +0,0 @@
-import { expect } from 'chai';
-import { spec, ENDPOINT_URL, BIDDER_CODE, DEFAULT_CURRENCY } from 'modules/bidtheatreBidAdapter.js';
-import { BANNER, VIDEO } from 'src/mediaTypes.js';
-import { deepClone } from 'src/utils.js';
-
-const VALID_PUBLISHER_ID = '73b20b3a-12a0-4869-b54e-8d42b55786ee';
-const STATIC_IMP_ID = '3263e5dec855c5';
-const BID_PRICE = 5.112871170043945;
-const AUCTION_PRICE_MACRO = '${AUCTION_PRICE}';
-
-const BANNER_BID_REQUEST = [
- {
- 'bidder': BIDDER_CODE,
- 'params': {
- 'publisherId': VALID_PUBLISHER_ID
- },
- 'bidId': STATIC_IMP_ID,
- 'mediaTypes': {
- 'banner': {
- 'sizes': [
- [
- 980,
- 240
- ]
- ]
- }
- },
- 'sizes': [
- [
- 980,
- 240
- ]
- ]
- }
-];
-
-const BANNER_BIDDER_REQUEST = {'bidderCode': BIDDER_CODE, 'bids': BANNER_BID_REQUEST};
-
-const BANNER_BID_RESPONSE = {
- 'cur': 'USD',
- 'seatbid': [
- {
- 'seat': '5',
- 'bid': [
- {
- 'ext': {
- 'usersync_urls': [
- 'https://match.adsby.bidtheatre.com/usersync?gdpr=1&gdpr_consent=CONSENT_STRING'
- ]
- },
- 'crid': '1915538',
- 'h': 240,
- 'adm': "",
- 'mtype': 1,
- 'adid': '1915538',
- 'adomain': [
- 'bidtheatre.com'
- ],
- 'price': BID_PRICE,
- 'cat': [
- 'IAB3-1'
- ],
- 'w': 980,
- 'id': STATIC_IMP_ID,
- 'impid': STATIC_IMP_ID,
- 'cid': 'c154375'
- }
- ]
- }
- ]
-};
-
-const VIDEO_BID_REQUEST = [
- {
- 'bidder': BIDDER_CODE,
- 'params': {
- 'publisherId': VALID_PUBLISHER_ID
- },
- 'bidId': STATIC_IMP_ID,
- 'mediaTypes': {
- 'video': {
- 'playerSize': [
- [
- 1280,
- 720
- ]
- ],
- 'context': 'instream'
- }
- },
- 'sizes': [[1280, 720]]
- }
-];
-
-const VIDEO_BIDDER_REQUEST = {'bidderCode': BIDDER_CODE, 'bids': VIDEO_BID_REQUEST};
-
-const VIDEO_BID_RESPONSE = {
- 'cur': 'USD',
- 'seatbid': [
- {
- 'seat': '5',
- 'bid': [
- {
- 'ext': {
- 'usersync_urls': [
- 'https://match.adsby.bidtheatre.com/usersync?gdpr=0&gdpr_consent='
- ]
- },
- 'crid': '1922926',
- 'h': 720,
- 'mtype': 2,
- 'nurl': 'https://adsby.bidtheatre.com/video?z=27025;a=1922926;ex=36;es=http%3A%2F%2F127.0.0.1%3A8080;eb=3672319;xs=940400838;so=1;tag=unspec_1280_720;kuid=05914b22-88cb-4c5d-9f7c-f133fdf9669a;wp=${AUCTION_PRICE};su=127.0.0.1%3A8080;iab=vast2;dealId=;ma=eyJjZCI6ZmFsc2UsInN0IjozLCJtbGF0Ijo1OS4yNywibW9yZyI6InRlbGlhIG5ldHdvcmsgc2VydmljZXMiLCJtbHNjb3JlIjowLjg2MDcwMDU0NzY5NTE1OTksIm16aXAiOiIxMjggMzUiLCJiaXAiOiI4MS4yMjcuODIuMjgiLCJhZ2lkIjozNTYyNzAyLCJtbG1vZGVsIjoibWFzdGVyX21sX2Nsa181MzYiLCJ1YSI6Ik1vemlsbGFcLzUuMCAoTWFjaW50b3NoOyBJbnRlbCBNYWMgT1MgWCAxMF8xNV83KSBBcHBsZVdlYktpdFwvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lXC8xMzAuMC4wLjAgU2FmYXJpXC81MzcuMzYiLCJtbG9uIjoxOC4xMywibXJlZ2lvbiI6ImFiIiwiZHQiOjEsIm1jaXR5Ijoic2thcnBuYWNrIiwicGFnZXVybCI6Imh0dHA6XC9cLzEyNy4wLjAuMTo4MDgwXC92aWRlby5odG1sP3BianNfZGVidWc9dHJ1ZSIsImltcGlkIjoieDM2X2FzeC1iLXMyXzQxNDMzMTA0MTIyMzUyNTU3NDgiLCJtY291bnRyeSI6InN3ZSIsInRzIjoxNzMxNTA3NTY5Njg3fQ%3D%3D;cd=0;cb0=;impId=x36_asx-b-s2_4143310412235255748;gdpr=1;gdpr_consent=CP-S4UAP-S4UACGABBENAzEsAP_gAEPgAAAAKKtV_H__bW1r8X73aft0eY1P9_j77sQxBhfJE-4FzLvW_JwXx2ExNA36tqIKmRIEu3bBIQNlHJDUTVCgaogVryDMakWcoTNKJ6BkiFMRO2dYCF5vmwtj-QKY5vr993dx2D-t_dv83dzyz4VHn3a5_2e0WJCdA58tDfv9bROb-9IPd_58v4v0_F_rE2_eT1l_tevp7D9-ct87_XW-9_fff79Ll9-goqAWYaFRAHWBISEGgYRQIAVBWEBFAgAAABIGiAgBMGBTsDAJdYSIAQAoABggBAACjIAEAAAEACEQAQAFAgAAgECgABAAgEAgAIGAAEAFgIBAACA6BCmBBAoFgAkZkRCmBCFAkEBLZUIJAECCuEIRZ4AEAiJgoAAAAACsAAQFgsDiSQEqEggS4g2gAAIAEAghAqEEnJgACBI2WoPBE2jK0gDQ04SAAAAA.YAAAAAAAAAAA',
- 'adid': '1922926',
- 'adomain': [
- 'bidtheatre.com'
- ],
- 'price': BID_PRICE,
- 'cat': [
- 'IAB3-1'
- ],
- 'w': 1280,
- 'id': STATIC_IMP_ID,
- 'impid': STATIC_IMP_ID,
- 'cid': 'c154375'
- }
- ]
- }
- ]
-}
-
-describe('BidtheatreAdapter', function () {
- describe('isBidRequestValid', function () {
- const bid = {
- 'bidder': BIDDER_CODE,
- 'params': {
- 'publisherId': VALID_PUBLISHER_ID
- },
- 'sizes': [[980, 240]]
- };
-
- it('should return true when required param found and of correct type', function () {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should return false when required param is not passed', function () {
- const invalidBid = Object.assign({}, bid);
- delete invalidBid.params;
- invalidBid.params = {
-
- };
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
-
- it('should return false when required param of incorrect data type', function () {
- const invalidBid = Object.assign({}, bid);
- delete invalidBid.params;
- invalidBid.params = {
- 'publisherId': 12345
- };
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
-
- it('should return false when required param of incorrect length', function () {
- const invalidBid = Object.assign({}, bid);
- delete invalidBid.params;
- invalidBid.params = {
- 'publisherId': '73b20b3a-12a0-4869-b54e-8d42b55786e'
- };
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
- });
-
- describe('buildRequests', function () {
- it('should include correct http method, correct url and existing data', function () {
- const request = spec.buildRequests(BANNER_BID_REQUEST, BANNER_BIDDER_REQUEST);
- expect(request[0].method).to.equal('POST');
- expect(request[0].url).to.equal(ENDPOINT_URL);
- expect(request[0].data).to.exist;
- });
-
- it('should include required bid param in request', function () {
- const request = spec.buildRequests(BANNER_BID_REQUEST, BANNER_BIDDER_REQUEST);
- const data = request[0].data;
- expect(data.imp[0].ext.bidder.publisherId).to.equal(VALID_PUBLISHER_ID);
- });
-
- it('should include imp array in request', function () {
- const request = spec.buildRequests(BANNER_BID_REQUEST, BANNER_BIDDER_REQUEST);
- const data = request[0].data;
- expect(data).to.have.property('imp').that.is.an('array').with.lengthOf.at.least(1);
- expect(data.imp[0]).to.be.an('object');
- });
- });
-
- describe('interpretResponse', function () {
- it('should have exactly one bid in banner response', function () {
- const request = spec.buildRequests(BANNER_BID_REQUEST, BANNER_BIDDER_REQUEST);
- const bids = spec.interpretResponse({body: BANNER_BID_RESPONSE}, request[0]);
- expect(bids).to.be.an('array').with.lengthOf(1);
- expect(bids[0]).to.be.an('object');
- });
-
- it('should have currency set to USD in banner response', function () {
- const request = spec.buildRequests(BANNER_BID_REQUEST, BANNER_BIDDER_REQUEST);
- const bids = spec.interpretResponse({body: BANNER_BID_RESPONSE}, request[0]);
- expect(bids[0].currency).to.be.a('string').and.to.equal(DEFAULT_CURRENCY);
- });
-
- it('should have ad in response and auction price macros replaced in banner response', function () {
- const request = spec.buildRequests(BANNER_BID_REQUEST, BANNER_BIDDER_REQUEST);
- const bids = spec.interpretResponse({body: BANNER_BID_RESPONSE}, request[0]);
- const ad = bids[0].ad;
- expect(ad).to.exist;
- expect(ad).to.be.a('string');
- expect(ad).to.include('&wp=' + BID_PRICE + '&');
- expect(ad).to.not.include(AUCTION_PRICE_MACRO);
- });
-
- if (FEATURES.VIDEO) {
- it('should have exactly one bid in video response', function () {
- const request = spec.buildRequests(VIDEO_BID_REQUEST, VIDEO_BIDDER_REQUEST);
- const bids = spec.interpretResponse({body: VIDEO_BID_RESPONSE}, request[0]);
- expect(bids).to.be.an('array').with.lengthOf(1);
- expect(bids[0]).to.be.an('object');
- });
-
- it('should have currency set to USD in video response', function () {
- const request = spec.buildRequests(VIDEO_BID_REQUEST, VIDEO_BIDDER_REQUEST);
- const bids = spec.interpretResponse({body: VIDEO_BID_RESPONSE}, request[0]);
- expect(bids[0].currency).to.be.a('string').and.to.equal(DEFAULT_CURRENCY);
- });
-
- it('should have vastUrl in response and auction price macros replaced in video response', function () {
- const request = spec.buildRequests(VIDEO_BID_REQUEST, VIDEO_BIDDER_REQUEST);
- const bids = spec.interpretResponse({body: VIDEO_BID_RESPONSE}, request[0]);
- const vastUrl = bids[0].vastUrl;
- expect(vastUrl).to.exist;
- expect(vastUrl).to.be.a('string');
- expect(vastUrl).to.include(';wp=' + BID_PRICE + ';');
- expect(vastUrl).to.not.include(AUCTION_PRICE_MACRO);
- });
- }
- });
-
- describe('getUserSyncs', function () {
- const bidResponse = deepClone(BANNER_BID_RESPONSE);
- const bidResponseSyncURL = bidResponse.seatbid[0].bid[0].ext.usersync_urls[0];
-
- const gdprConsent = {
- gdprApplies: true,
- consentString: 'CONSENT_STRING'
- };
-
- it('should return empty when pixel is disallowed', function () {
- expect(spec.getUserSyncs({ pixelEnabled: false }, bidResponse, gdprConsent)).to.be.empty;
- });
-
- it('should return empty when no server response is present', function () {
- expect(spec.getUserSyncs({ pixelEnabled: true }, [], gdprConsent)).to.be.empty;
- });
-
- it('should return usersync url when pixel is allowed and present in bid response', function () {
- expect(spec.getUserSyncs({ pixelEnabled: true }, [{body: bidResponse}], gdprConsent)).to.deep.equal([{ type: 'image', url: bidResponseSyncURL }]);
- });
- });
-});
diff --git a/test/spec/modules/big-richmediaBidAdapter_spec.js b/test/spec/modules/big-richmediaBidAdapter_spec.js
deleted file mode 100644
index ffddad000..000000000
--- a/test/spec/modules/big-richmediaBidAdapter_spec.js
+++ /dev/null
@@ -1,273 +0,0 @@
-import { expect } from 'chai';
-import { spec } from 'modules/big-richmediaBidAdapter.js';
-import { auctionManager } from 'src/auctionManager.js';
-import * as bidderFactory from 'src/adapters/bidderFactory.js';
-import { config } from 'src/config.js';
-import { deepClone } from 'src/utils.js';
-
-describe('bigRichMediaAdapterTests', function () {
- before(function () {
- config.setConfig({
- bigRichmedia: {
- publisherId: '123ABC'
- }
- });
- });
-
- after(function () {
- config.resetConfig();
- });
-
- describe('bidRequestValidity', function () {
- const bid = {
- 'bidder': 'bigRichmedia',
- 'params': {
- 'placementId': '10433394'
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [[300, 250], [300, 600]],
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- };
-
- it('bidRequest with zoneId and deliveryUrl params', function () {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('bidRequest with no params is not valid', function () {
- const localBid = Object.assign({}, bid);
- localBid.params = {};
- expect(spec.isBidRequestValid(localBid)).to.equal(false);
- });
- });
-
- describe('bidRequest', function () {
- let getAdUnitsStub;
- const bidRequests = [
- {
- 'bidder': 'bigRichmedia',
- 'params': {
- 'placementId': '10433394'
- },
- 'mediaTypes': {
- 'banner': {
- 'sizes': [[300, 250], [300, 600], [1800, 1000]]
- }
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [[300, 250], [300, 600], [1800, 1000]],
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- 'transactionId': '04f2659e-c005-4eb1-a57c-fa93145e3843'
- }
- ];
-
- beforeEach(function() {
- getAdUnitsStub = sinon.stub(auctionManager, 'getAdUnits').callsFake(function() {
- return [];
- });
- });
-
- afterEach(function() {
- getAdUnitsStub.restore();
- });
-
- it('should have skin size', function () {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- params: {
- placementId: '10433394',
- format: 'skin'
- }
- }
- );
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].sizes).to.exist;
- expect(payload.tags[0].sizes).to.have.lengthOf(3);
- });
-
- if (FEATURES.VIDEO) {
- it('should build video bid request', function() {
- const bidRequest = deepClone(bidRequests[0]);
- bidRequest.params = {
- placementId: '1234235',
- video: {
- skippable: true,
- playback_method: ['auto_play_sound_off', 'auto_play_sound_unknown'],
- context: 'outstream',
- format: 'sticky-top'
- }
- };
- bidRequest.mediaTypes = {
- video: {
- playerSize: [640, 480],
- context: 'outstream',
- mimes: ['video/mp4'],
- skip: 0,
- minduration: 5,
- api: [1, 5, 6],
- playbackmethod: [2, 4]
- }
- };
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.tags[0].video).to.deep.equal({
- minduration: 5,
- playback_method: 2,
- skippable: true,
- context: 4
- });
- expect(payload.tags[0].video_frameworks).to.deep.equal([1, 4])
- });
- }
- });
-
- describe('interpretResponse', function () {
- const response = {
- 'version': '3.0.0',
- 'tags': [
- {
- 'uuid': '3db3773286ee59',
- 'tag_id': 10433394,
- 'auction_id': '4534722592064951574',
- 'nobid': false,
- 'no_ad_url': 'https://lax1-ib.adnxs.com/no-ad',
- 'timeout_ms': 10000,
- 'ad_profile_id': 27079,
- 'ads': [
- {
- 'content_source': 'rtb',
- 'ad_type': 'banner',
- 'buyer_member_id': 958,
- 'creative_id': 29681110,
- 'media_type_id': 1,
- 'media_subtype_id': 1,
- 'cpm': 0.5,
- 'cpm_publisher_currency': 0.5,
- 'publisher_currency_code': '$',
- 'client_initiated_ad_counting': true,
- 'viewability': {
- 'config': ''
- },
- 'rtb': {
- 'banner': {
- 'content': '',
- 'width': 300,
- 'height': 250
- },
- 'trackers': [
- {
- 'impression_urls': [
- 'https://lax1-ib.adnxs.com/impression',
- 'https://www.test.com/tracker'
- ],
- 'video_events': {}
- }
- ]
- }
- }
- ]
- }
- ]
- };
-
- it('should get correct bid response', function () {
- const expectedResponse = [
- {
- 'adId': '3a1f23123e',
- 'requestId': '3db3773286ee59',
- 'cpm': 0.5,
- 'creativeId': 29681110,
- 'dealId': undefined,
- 'width': 300,
- 'height': 250,
- 'ad': '',
- 'mediaType': 'banner',
- 'currency': 'USD',
- 'ttl': 300,
- 'netRevenue': true,
- 'adUnitCode': 'code',
- 'appnexus': {
- 'buyerMemberId': 958
- },
- 'meta': {
- 'dchain': {
- 'ver': '1.0',
- 'complete': 0,
- 'nodes': [{
- 'bsid': '958'
- }]
- }
- }
- }
- ];
- const bidderRequest = {
- bids: [{
- bidId: '3db3773286ee59',
- adUnitCode: 'code'
- }]
- };
- const result = spec.interpretResponse({ body: response }, {bidderRequest});
- expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0]));
- });
-
- if (FEATURES.VIDEO) {
- it('handles outstream video responses', function () {
- const response = {
- 'tags': [{
- 'uuid': '84ab500420319d',
- 'ads': [{
- 'ad_type': 'video',
- 'cpm': 0.500000,
- 'notify_url': 'imptracker.com',
- 'rtb': {
- 'video': {
- 'content': ''
- }
- },
- 'javascriptTrackers': ''
- }]
- }]
- };
- const bidderRequest = {
- bids: [{
- bidId: '84ab500420319d',
- adUnitCode: 'code',
- mediaTypes: {
- video: {
- context: 'outstream'
- }
- }
- }]
- }
-
- const result = spec.interpretResponse({ body: response }, {bidderRequest});
- expect(result[0]).not.to.have.property('vastXml');
- expect(result[0]).not.to.have.property('vastUrl');
- expect(result[0]).to.have.property('width', 1);
- expect(result[0]).to.have.property('height', 1);
- expect(result[0]).to.have.property('mediaType', 'banner');
- });
- }
- });
-
- describe('getUserSyncs', function() {
- const syncOptions = {
- syncEnabled: false
- };
-
- it('should not return sync', function() {
- const serverResponse = [{ body: '' }];
- const result = spec.getUserSyncs(syncOptions, serverResponse);
- expect(result).to.be.undefined;
- });
- });
-});
diff --git a/test/spec/modules/bitmediaBidAdapter_spec.js b/test/spec/modules/bitmediaBidAdapter_spec.js
deleted file mode 100644
index 537ae3835..000000000
--- a/test/spec/modules/bitmediaBidAdapter_spec.js
+++ /dev/null
@@ -1,499 +0,0 @@
-import {expect} from 'chai';
-import {spec, STORAGE, ENDPOINT_URL} from 'modules/bitmediaBidAdapter.js';
-import * as utils from 'src/utils.js';
-import {config} from 'src/config.js';
-import {BANNER} from '../../../src/mediaTypes.js';
-
-describe('Bitmedia Bid Adapter', function () {
- const createBidRequest = (sandbox, overrides = {}) => {
- return Object.assign({
- bidder: 'bitmedia',
- params: {
- adUnitID: 'test-ad-unit-id',
- currency: 'USD'
- },
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [300, 600]]
- }
- },
- bidId: 'bid123',
- auctionId: 'auction123',
- transactionId: 'transaction123',
- adUnitCode: 'adunit123',
- sizes: [[300, 250], [300, 600]],
- getFloor: sandbox.stub().returns({
- currency: 'USD',
- floor: 0.4
- })
- }, overrides);
- }
-
- const createBidderRequest = (overrides = {}) => {
- return Object.assign({
- refererInfo: {
- page: 'https://example.com/page.html',
- domain: 'example.com',
- referer: 'https://google.com'
- },
- timeout: 2000,
- bidderCode: 'bitmedia',
- auctionId: 'auction123',
- ortb2: {
- site: {
- domain: 'publisher.com',
- page: 'https://publisher.com/homepage.html',
- publisher: {
- domain: 'publisher.com'
- }
- },
- device: {
- ua: 'custom-user-agent',
- language: 'fr'
- }
- }
- }, overrides);
- }
- // Helper function to stub storage for user ID
- const stubStorage = (sandbox, userIdInLocalStorage = null, userIdInCookies = null) => {
- sandbox.stub(STORAGE, 'hasLocalStorage').returns(true);
- sandbox.stub(STORAGE, 'getDataFromLocalStorage')
- .withArgs('bitmedia_fid')
- .returns(userIdInLocalStorage);
-
- sandbox.stub(STORAGE, 'cookiesAreEnabled').returns(true);
- sandbox.stub(STORAGE, 'getCookie')
- .withArgs('bitmedia_fid')
- .returns(userIdInCookies);
-
- if (userIdInLocalStorage || userIdInCookies) {
- const encodedFid = userIdInLocalStorage || userIdInCookies;
- sandbox.stub(window, 'atob')
- .withArgs(encodedFid)
- .returns(`{"fid":"user123"}`);
- }
- }
-
- describe('isBidRequestValid', function () {
- let bid;
- beforeEach(function () {
- bid = {
- bidder: 'bitmedia',
- params: {
- adUnitID: 'test-ad-unit-id',
- currency: 'USD'
- },
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [300, 600]]
- }
- }
- };
- });
-
- it('should return true when required params found and sizes are valid', function () {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should return false if adUnitID is missing', function () {
- delete bid.params.adUnitID;
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return false if currency is invalid', function () {
- bid.params.currency = 'EUR';
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return false if no valid sizes provided', function () {
- bid.mediaTypes.banner.sizes = [[123, 456], [789, 101]];
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return false if mediaTypes.banner is missing', function () {
- delete bid.mediaTypes.banner;
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return false if banner sizes are not an array', function () {
- bid.mediaTypes.banner.sizes = '300x250';
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return false if bid params are missing', function () {
- delete bid.params;
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
- });
-
- describe('buildRequests', function () {
- let sandbox;
-
- beforeEach(function () {
- sandbox = sinon.createSandbox();
-
- // Stub generateUUID to return a fixed value for testing
- sandbox.stub(utils, 'generateUUID').returns('test-generated-uuid');
-
- // Stub config.getConfig for bidderTimeout
- sandbox.stub(config, 'getConfig').withArgs('bidderTimeout').returns(30);
- });
-
- afterEach(function () {
- sandbox.restore();
- });
- describe('when building the request', function () {
- let bidRequests;
- let bidderRequest;
- let requests;
- let request;
- let data;
-
- beforeEach(function () {
- bidRequests = [createBidRequest(sandbox,)];
- bidderRequest = createBidderRequest();
- stubStorage(sandbox, null, 'encodedFidString'); // User ID in cookies
-
- requests = spec.buildRequests(bidRequests, bidderRequest);
- request = requests[0];
- data = request.data;
- });
-
- it('should return an array with one request', function () {
- expect(requests).to.be.an('array').with.lengthOf(1);
- });
-
- it('should have method POST and the correct URL', function () {
- expect(request.method).to.equal('POST');
- expect(request.url).to.equal(`${ENDPOINT_URL}${bidRequests[0].params.adUnitID}`);
- });
-
- it('should have the correct request options', function () {
- expect(request.options).to.deep.equal({
- withCredentials: false,
- crossOrigin: true
- });
- });
-
- it('should have the correct request data structure', function () {
- expect(data).to.be.an('object');
- expect(data).to.have.all.keys('id', 'imp', 'site', 'device', 'cur', 'tmax', 'ext', 'user');
- });
-
- it('should include the generated UUID in the request data', function () {
- expect(data.id).to.equal('test-generated-uuid');
- });
-
- it('should include the correct impressions in the request data', function () {
- expect(data.imp).to.be.an('array').with.lengthOf(2);
-
- const expectedImp1 = {
- id: 'bid123',
- tagid: 'test-ad-unit-id',
- banner: {
- w: 300,
- h: 250
- },
- bidfloor: 0.4,
- bidfloorcur: 'USD'
- };
-
- const expectedImp2 = {
- id: 'bid123',
- tagid: 'test-ad-unit-id',
- banner: {
- w: 300,
- h: 600
- },
- bidfloor: 0.4,
- bidfloorcur: 'USD'
- };
-
- expect(data.imp[0]).to.deep.equal(expectedImp1);
- expect(data.imp[1]).to.deep.equal(expectedImp2);
- });
-
- it('should include the correct site information', function () {
- expect(data.site).to.deep.equal({
- domain: 'publisher.com',
- page: 'https://publisher.com/homepage.html',
- publisher: {
- domain: 'publisher.com'
- }
- });
- });
-
- it('should include the correct device information', function () {
- expect(data.device).to.deep.equal({
- ua: 'custom-user-agent',
- language: 'fr'
- });
- });
-
- it('should include the default currency', function () {
- expect(data.cur).to.deep.equal(['USD']);
- });
-
- it('should include the correct timeout (tmax)', function () {
- expect(data.tmax).to.equal(2000);
- });
-
- it('should include the ext field with adapter_version and prebid_version as strings', function () {
- expect(data.ext.adapter_version).to.be.a('string');
- expect(data.ext.prebid_version).to.be.a('string');
- });
-
- it('should include the user ID when present in cookies', function () {
- expect(data.user).to.deep.equal({
- id: 'user123'
- });
- });
- });
-
- describe('when some invalid sizes are provided', function () {
- let bidRequests;
- let bidderRequest;
- let requests;
- let request;
- let data;
-
- beforeEach(function () {
- bidRequests = [createBidRequest(sandbox, {
- mediaTypes: {
- banner: {
- sizes: [[300, 600], [888, 888]],
- },
- },
- sizes: [[300, 600], [888, 888]],
- })];
- bidderRequest = createBidderRequest();
- stubStorage(sandbox, null, null);
-
- requests = spec.buildRequests(bidRequests, bidderRequest);
- request = requests[0];
- data = request.data;
- });
-
- it('should not build imp with invalid size', function () {
- expect(data.imp).to.be.an('array').with.lengthOf(1);
- });
- });
-
- describe('when user ID is absent', function () {
- let bidRequests;
- let bidderRequest;
- let requests;
- let data;
-
- beforeEach(function () {
- bidRequests = [createBidRequest(sandbox,)];
- bidderRequest = createBidderRequest();
- stubStorage(sandbox, null, null);
-
- requests = spec.buildRequests(bidRequests, bidderRequest);
- data = requests[0].data;
- });
-
- it('should not include user ID in the request data', function () {
- expect(data.user).to.be.undefined;
- });
- });
-
- describe('when getFloor is not available', function () {
- let bidRequests;
- let bidderRequest;
- let requests;
- let imp;
-
- beforeEach(function () {
- bidRequests = [createBidRequest(sandbox, {
- getFloor: undefined
- })];
- bidderRequest = createBidderRequest();
-
- requests = spec.buildRequests(bidRequests, bidderRequest);
- imp = requests[0].data.imp;
- });
-
- it('should not include bidfloor in imp objects', function () {
- imp.forEach(impression => {
- expect(impression).to.not.have.property('bidfloor');
- expect(impression).to.not.have.property('bidfloorcur');
- });
- });
- });
-
- describe('when different bid floors are provided per size', function () {
- let bidRequests;
- let bidderRequest;
- let requests;
- let imp;
-
- beforeEach(function () {
- const getFloorStub = sinon.stub();
- getFloorStub.withArgs({currency: 'USD', mediaType: 'banner', size: [300, 250]}).returns({
- currency: 'USD',
- floor: 0.5
- });
- getFloorStub.withArgs({currency: 'USD', mediaType: 'banner', size: [300, 600]}).returns({
- currency: 'USD',
- floor: 0.7
- });
-
- bidRequests = [createBidRequest(sandbox, {
- getFloor: getFloorStub
- })];
- bidderRequest = createBidderRequest();
-
- requests = spec.buildRequests(bidRequests, bidderRequest);
- imp = requests[0].data.imp;
- });
-
- it('should include the correct bidfloor per impression', function () {
- expect(imp[0].bidfloor).to.equal(0.5);
- expect(imp[0].banner).to.deep.equal({w: 300, h: 250});
- expect(imp[1].bidfloor).to.equal(0.7);
- expect(imp[1].banner).to.deep.equal({w: 300, h: 600});
- });
- });
-
- describe('when bid floor data is invalid', function () {
- let bidRequests;
- let bidderRequest;
- let requests;
- let imp;
-
- beforeEach(function () {
- const invalidGetFloor = sinon.stub().returns({
- currency: 'USD',
- floor: 'invalid'
- });
- bidRequests = [createBidRequest(sandbox, {
- getFloor: invalidGetFloor
- })];
- bidderRequest = createBidderRequest();
-
- requests = spec.buildRequests(bidRequests, bidderRequest);
- imp = requests[0].data.imp;
- });
-
- it('should not include bidfloor when floor value is invalid', function () {
- imp.forEach(impression => {
- expect(impression).to.not.have.property('bidfloor');
- expect(impression).to.not.have.property('bidfloorcur');
- });
- });
- });
- });
-
- describe('interpretResponse', function () {
- let sandbox;
- let bidRequests;
- let bidderRequest;
- let requests;
- beforeEach(function () {
- sandbox = sinon.createSandbox();
- sandbox.stub(utils, 'generateUUID').returns('test-generated-uuid');
- bidRequests = [createBidRequest(sandbox,)];
- bidderRequest = createBidderRequest();
- stubStorage(sandbox, null, null); // No user ID for simplicity
-
- requests = spec.buildRequests(bidRequests, bidderRequest);
- });
-
- afterEach(function () {
- sandbox.restore();
- });
-
- it('should return bids with all required keys when server response has valid bids', function () {
- const request = requests[0];
-
- const serverResponse = {
- body: {
- id: request.data.id,
- seatbid: [
- {
- bid: [
- {
- impid: request.data.imp[0].id,
- price: 1.5,
- w: request.data.imp[0].banner.w,
- h: request.data.imp[0].banner.h,
- adm: '
Ad Content
',
- crid: 'creative123',
- adomain: ['example.com'],
- nurl: 'https://example.com/win',
- exp: 360,
- },
- ],
- },
- ],
- cur: 'USD',
- },
- };
-
- const bids = spec.interpretResponse(serverResponse, request);
-
- expect(bids).to.be.an('array').with.lengthOf(1);
- const bid = bids[0];
- expect(bid).to.include.all.keys(
- 'requestId',
- 'cpm',
- 'currency',
- 'width',
- 'height',
- 'ad',
- 'ttl',
- 'creativeId',
- 'netRevenue',
- 'meta',
- 'nurl',
- 'mediaType'
- );
- expect(bid.mediaType).to.equal(BANNER);
- expect(bid.ttl).to.equal(360);
- expect(bid.nurl).to.equal('https://example.com/win');
- });
-
- it('should return an empty array when server response is empty', function () {
- const serverResponse = {body: {}};
- const bidRequest = {};
-
- const bids = spec.interpretResponse(serverResponse, bidRequest);
-
- expect(bids).to.be.an('array').that.is.empty;
- });
- });
-
- describe('onBidWon', function () {
- let sandbox;
-
- beforeEach(function () {
- sandbox = sinon.createSandbox();
- });
-
- afterEach(function () {
- sandbox.restore();
- });
-
- it('exists and is a function', () => {
- expect(spec.onBidWon).to.exist.and.to.be.a('function');
- });
-
- it('should return nothing and trigger a pixel with nurl', function () {
- const bid = {
- nurl: 'https://example.com/win',
- };
-
- const triggerPixelSpy = sandbox.spy(utils, 'triggerPixel');
-
- const response = spec.onBidWon(bid);
-
- expect(response).to.be.undefined;
-
- expect(triggerPixelSpy.calledOnce).to.equal(true);
-
- expect(triggerPixelSpy.calledWith(bid.nurl)).to.equal(true);
- });
- });
-});
diff --git a/test/spec/modules/blastoBidAdapter_spec.js b/test/spec/modules/blastoBidAdapter_spec.js
deleted file mode 100644
index d0cd8e22b..000000000
--- a/test/spec/modules/blastoBidAdapter_spec.js
+++ /dev/null
@@ -1,310 +0,0 @@
-import { expect } from 'chai';
-import { spec } from 'modules/blastoBidAdapter';
-import 'modules/priceFloors.js';
-import { newBidder } from 'src/adapters/bidderFactory';
-import { config } from '../../../src/config.js';
-import { addFPDToBidderRequest } from '../../helpers/fpd.js';
-
-// load modules that register ORTB processors
-import 'src/prebid.js';
-import 'modules/currency.js';
-import 'modules/userId/index.js';
-import 'modules/multibid/index.js';
-
-import 'modules/consentManagementTcf.js';
-import 'modules/consentManagementUsp.js';
-
-const SIMPLE_BID_REQUEST = {
- bidder: 'blasto',
- params: {
- accountId: 'testAccountId',
- sourceId: 'testSourceId',
- host: 'USE',
- },
- mediaTypes: {
- banner: {
- sizes: [
- [320, 250],
- [300, 600],
- ],
- },
- },
- adUnitCode: 'div-gpt-ad-1499748733608-0',
- transactionId: 'f183e871-fbed-45f0-a427-c8a63c4c01eb',
- bidId: '33e9500b21129f',
- bidderRequestId: '2772c1e566670b',
- auctionId: '192721e36a0239',
- sizes: [[300, 250], [160, 600]],
- gdprConsent: {
- apiVersion: 2,
- consentString: 'CONSENT',
- vendorData: { purpose: { consents: { 1: true } } },
- gdprApplies: true,
- addtlConsent: '1~1.35.41.101',
- },
-}
-
-const BANNER_BID_REQUEST = {
- bidder: 'blasto',
- params: {
- accountId: 'testAccountId',
- sourceId: 'testSourceId',
- host: 'USE',
- },
- mediaTypes: {
- banner: {
- sizes: [
- [300, 250],
- [300, 600],
- ],
- },
- },
- adUnitCode: '/adunit-code/test-path',
- bidId: 'test-bid-id-1',
- bidderRequestId: 'test-bid-request-1',
- auctionId: 'test-auction-1',
- transactionId: 'test-transactionId-1',
- code: 'banner_example',
- timeout: 1000,
-}
-
-const VIDEO_BID_REQUEST = {
- placementCode: '/DfpAccount1/slotVideo',
- bidId: 'test-bid-id-2',
- mediaTypes: {
- video: {
- playerSize: [400, 300],
- w: 400,
- h: 300,
- minduration: 5,
- maxduration: 10,
- startdelay: 0,
- skip: 1,
- minbitrate: 200,
- protocols: [1, 2, 4]
- }
- },
- bidder: 'blasto',
- params: {
- accountId: '123',
- sourceId: '123',
- host: 'USE',
- },
- adUnitCode: '/adunit-code/test-path',
- bidderRequestId: 'test-bid-request-1',
- auctionId: 'test-auction-1',
- transactionId: 'test-transactionId-1',
- timeout: 1000,
-}
-
-const NATIVE_BID_REQUEST = {
- code: 'native_example',
- mediaTypes: {
- native: {
- title: {
- required: true,
- len: 800
- },
- image: {
- required: true,
- len: 80
- },
- sponsoredBy: {
- required: true
- },
- clickUrl: {
- required: true
- },
- privacyLink: {
- required: false
- },
- body: {
- required: true
- },
- icon: {
- required: true,
- sizes: [50, 50]
- }
- }
- },
- bidder: 'blasto',
- params: {
- accountId: 'testAccountId',
- sourceId: 'testSourceId',
- host: 'USE',
- },
- adUnitCode: '/adunit-code/test-path',
- bidId: 'test-bid-id-1',
- bidderRequestId: 'test-bid-request-1',
- auctionId: 'test-auction-1',
- transactionId: 'test-transactionId-1',
- timeout: 1000,
- uspConsent: 'uspConsent'
-};
-
-const bidderRequest = {
- refererInfo: {
- page: 'https://publisher.com/home',
- ref: 'https://referrer'
- }
-};
-
-const gdprConsent = {
- apiVersion: 2,
- consentString: 'CONSENT',
- vendorData: { purpose: { consents: { 1: true } } },
- gdprApplies: true,
- addtlConsent: '1~1.35.41.101',
-}
-
-describe('blastoAdapter', function () {
- const adapter = newBidder(spec);
- describe('inherited functions', function () {
- it('exists and is a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('with user privacy regulations', function () {
- it('should send the Coppa "required" flag set to "1" in the request', async function () {
- sinon.stub(config, 'getConfig')
- .withArgs('coppa')
- .returns(true);
- const serverRequest = spec.buildRequests([SIMPLE_BID_REQUEST], await addFPDToBidderRequest(bidderRequest));
- expect(serverRequest.data.regs.coppa).to.equal(1);
- config.getConfig.restore();
- });
-
- it('should send the GDPR Consent data in the request', async function () {
- const serverRequest = spec.buildRequests([SIMPLE_BID_REQUEST], await addFPDToBidderRequest({
- ...bidderRequest,
- gdprConsent
- }));
- expect(serverRequest.data.regs.ext.gdpr).to.exist.and.to.equal(1);
- expect(serverRequest.data.user.ext.consent).to.equal('CONSENT');
- });
-
- it('should send the CCPA data in the request', async function () {
- const serverRequest = spec.buildRequests([SIMPLE_BID_REQUEST], await addFPDToBidderRequest({...bidderRequest, ...{uspConsent: '1YYY'}}));
- expect(serverRequest.data.regs.ext.us_privacy).to.equal('1YYY');
- });
- });
-
- describe('isBidRequestValid', function () {
- it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(BANNER_BID_REQUEST)).to.equal(true);
- });
-
- it('should return false when accountID/sourceId is missing', function () {
- const localbid = Object.assign({}, BANNER_BID_REQUEST);
- delete localbid.params.accountId;
- delete localbid.params.sourceId;
- expect(spec.isBidRequestValid(BANNER_BID_REQUEST)).to.equal(false);
- });
- });
-
- describe('build request', function () {
- it('should return an empty array when no bid requests', async function () {
- const bidRequest = spec.buildRequests([], await addFPDToBidderRequest(bidderRequest));
- expect(bidRequest).to.be.an('array');
- expect(bidRequest.length).to.equal(0);
- });
-
- it('should return a valid bid request object', async function () {
- const request = spec.buildRequests([SIMPLE_BID_REQUEST], await addFPDToBidderRequest(bidderRequest));
- expect(request).to.not.equal('array');
- expect(request.data).to.be.an('object');
- expect(request.method).to.equal('POST');
- expect(request.url).to.not.equal('');
- expect(request.url).to.not.equal(undefined);
- expect(request.url).to.not.equal(null);
-
- expect(request.data.site).to.have.property('page');
- expect(request.data.site).to.have.property('domain');
- expect(request.data).to.have.property('id');
- expect(request.data).to.have.property('imp');
- expect(request.data).to.have.property('device');
- });
-
- it('should return a valid bid BANNER request object', async function () {
- const request = spec.buildRequests([BANNER_BID_REQUEST], await addFPDToBidderRequest(bidderRequest));
- expect(request.data.imp[0].banner).to.exist;
- expect(request.data.imp[0].banner.format[0].w).to.be.an('number');
- expect(request.data.imp[0].banner.format[0].h).to.be.an('number');
- });
-
- if (FEATURES.VIDEO) {
- it('should return a valid bid VIDEO request object', async function () {
- const request = spec.buildRequests([VIDEO_BID_REQUEST], await addFPDToBidderRequest(bidderRequest));
- expect(request.data.imp[0].video).to.exist;
- expect(request.data.imp[0].video.w).to.be.an('number');
- expect(request.data.imp[0].video.h).to.be.an('number');
- });
- }
-
- it('should return a valid bid NATIVE request object', async function () {
- const request = spec.buildRequests([NATIVE_BID_REQUEST], await addFPDToBidderRequest(bidderRequest));
- expect(request.data.imp[0]).to.be.an('object');
- });
- })
-
- describe('interpretResponse', function () {
- let bidRequests, bidderRequest;
- beforeEach(function () {
- bidRequests = [{
- 'bidId': '28ffdk2B952532',
- 'bidder': 'blasto',
- 'userId': {
- 'freepassId': {
- 'userIp': '172.21.0.1',
- 'userId': '123',
- 'commonId': 'commonIdValue'
- }
- },
- 'adUnitCode': 'adunit-code',
- 'params': {
- 'publisherId': 'publisherIdValue'
- }
- }];
- bidderRequest = {};
- });
-
- it('Empty response must return empty array', function () {
- const emptyResponse = null;
- const response = spec.interpretResponse(emptyResponse, BANNER_BID_REQUEST);
-
- expect(response).to.be.an('array').that.is.empty;
- })
-
- it('Should interpret banner response', function () {
- const serverResponse = {
- body: {
- 'cur': 'USD',
- 'seatbid': [{
- 'bid': [{
- 'impid': '28ffdk2B952532',
- 'price': 97,
- 'adm': '
',
- 'w': 300,
- 'h': 250,
- 'crid': 'creative0'
- }]
- }]
- }
- };
- it('should interpret server response', async function () {
- const bidRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const bids = spec.interpretResponse(serverResponse, bidRequest);
- expect(bids).to.be.an('array');
- const bid = bids[0];
- expect(bid).to.be.an('object');
- expect(bid.currency).to.equal('USD');
- expect(bid.cpm).to.equal(97);
- expect(bid.ad).to.equal(ad)
- expect(bid.width).to.equal(300);
- expect(bid.height).to.equal(250);
- expect(bid.creativeId).to.equal('creative0');
- });
- })
- });
-});
diff --git a/test/spec/modules/bliinkBidAdapter_spec.js b/test/spec/modules/bliinkBidAdapter_spec.js
deleted file mode 100644
index 885a50e0c..000000000
--- a/test/spec/modules/bliinkBidAdapter_spec.js
+++ /dev/null
@@ -1,1196 +0,0 @@
-import { expect } from 'chai';
-import {
- spec,
- buildBid,
- BLIINK_ENDPOINT_ENGINE,
- getMetaList,
- BLIINK_ENDPOINT_COOKIE_SYNC_IFRAME,
- getEffectiveConnectionType,
- getUserIds,
- GVL_ID,
-} from 'modules/bliinkBidAdapter.js';
-import * as utils from 'src/utils.js';
-import { config } from 'src/config.js';
-
-/**
- * @description Mockup bidRequest
- * @return {{
- * bidderWinsCount: number,
- * adUnitCode: string,
- * bidder: string,
- * src: string,
- * bidRequestsCount: number,
- * params: {tagId: string, placement: string},
- * bidId: string,
- * transactionId: string,
- * auctionId: string,
- * bidderRequestId: string,
- * bidderRequestsCount: number,
- * mediaTypes: {banner: {sizes: number[][]}},
- * sizes: number[][],
- * crumbs: {pubcid: string},
- * ortb2Imp: {ext: {data: {pbadslot: string}}}}}
- */
-
-const w = (utils.canAccessWindowTop()) ? utils.getWindowTop() : utils.getWindowSelf();
-const connectionType = getEffectiveConnectionType();
-let domLoadingDuration = utils.getDomLoadingDuration(w).toString();
-const getConfigBid = (placement) => {
- return {
- adUnitCode: '/19968336/test',
- auctionId: '6752b51c-dcd4-4001-85dc-885ab5c504cf',
- bidId: '2def0c5b2a7f6e',
- bidRequestsCount: 1,
- bidder: 'bliink',
- bidderRequestId: '1592eb20088b18',
- bidderRequestsCount: 1,
- bidderWinsCount: 0,
- crumbs: {
- pubcid: '55ffadc5-051f-428d-8ecc-dc585e0bde0d',
- },
- sizes: [[300, 250]],
- mediaTypes: {
- banner: {
- sizes: [[300, 250]],
- },
- },
- ortb2Imp: {
- ext: {
- data: {
- pbadslot: '/19968336/test',
- },
- },
- },
- domLoadingDuration,
- ect: connectionType,
- params: {
- placement: placement,
- tagId: '14f30eca-85d2-11e8-9eed-0242ac120007',
- videoUrl: 'https://www.example.com/advideo.mp4',
- imageUrl: 'https://www.example.com/adimage.jpg',
- },
- src: 'client',
- transactionId: 'cc6678c4-9746-4082-b9e2-d8065d078ebf',
- };
-};
-const getConfigBannerBid = () => {
- return {
- creative: {
- banner: {
- adm: '',
- height: 250,
- width: 300,
- },
- media_type: 'banner',
- creativeId: 125,
- },
- price: 1,
- id: '810',
- token: 'token',
- mode: 'rtb',
- extras: {
- deal_id: '34567erty',
- transaction_id: '2def0c5b2a7f6e',
- },
- currency: 'EUR',
- };
-};
-const getConfigVideoBid = () => {
- return {
- creative: {
- video: {
- content: '
',
- height: 250,
- width: 300,
- },
- media_type: 'video',
- creativeId: 0,
- },
- price: 1,
- id: '8121',
- token: 'token',
- mode: 'rtb',
- extras: {
- deal_id: '34567ertyRTY',
- transaction_id: '2def0c5b2a7f6e',
- },
- currency: 'EUR',
- };
-};
-
-/**
- * @description Mockup response from engine.bliink.io/xxxx
- * @return {
- * {
- * viewability_percent_in_view: number,
- * viewability_duration: number,
- * ad_id: number,
- * id: number,
- * category: number,
- * type: number,
- * content: {
- * creative: {
- * adm: string
- * }
- * }
- * }
- * }
- * }
- */
-const getConfigCreative = () => {
- return {
- ad: '
',
- mediaType: 'banner',
- cpm: 4,
- currency: 'EUR',
- creativeId: '34567erty',
- width: 300,
- height: 250,
- ttl: 300,
- netRevenue: true,
- };
-};
-
-const getConfigCreativeVideo = (isNoVast) => {
- return {
- mediaType: 'video',
- vastXml: isNoVast ? '' : '
',
- cpm: 0,
- currency: 'EUR',
- creativeId: '34567ertyaza',
- requestId: '6a204ce130280d',
- width: 300,
- height: 250,
- ttl: 300,
- netRevenue: true,
- };
-};
-
-/**
- * @description Mockup BuildRequest function
- * @return {{bidderRequestId: string, bidderCode: string, bids: {bidderWinsCount: number, adUnitCode: string, bidder: string, src: string, bidRequestsCount: number, params: {tagId: string, placement: string}, bidId: string, transactionId: string, auctionId: string, bidderRequestId: string, bidderRequestsCount: number, mediaTypes: {banner: {sizes: number[][]}}, sizes: number[][], crumbs: {pubcid: string}, ortb2Imp: {ext: {data: {pbadslot: string}}}}[], refererInfo: {referer: string, canonicalUrl: null, isAmp: boolean, reachedTop: boolean, numIframes: number}}}
- */
-const getConfigBuildRequest = (placement) => {
- const buildRequest = {
- bidderRequestId: '164ddfd207e94d',
- bidderCode: 'bliink',
- bids: [getConfigBid(placement)],
- refererInfo: {
- canonicalUrl: null,
- isAmp: false,
- numIframes: 0,
- reachedTop: true,
- page: 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html?pbjs_debug=true',
- },
- };
-
- if (!placement) {
- return buildRequest;
- }
-
- return Object.assign(buildRequest, {
- params: {
- bids: [getConfigBid(placement)],
- placement: placement,
- },
- });
-};
-
-/**
- * @description Mockup response from API
- * @param noAd
- * @return {{mode: string, message: string}|{headers: {}, body: {mode: string, creative: {viewability_percent_in_view: number, viewability_duration: number, ad_id: number, adm: string, id: number, category: number, type: number}, token: string}}}
- */
-const getConfigInterpretResponse = (noAd = false) => {
- if (noAd) {
- return {
- message: 'invalid tag',
- mode: 'no-ad',
- };
- }
-
- return {
- body: {
- ...getConfigCreative(),
- mode: 'ad',
- transactionId: '2def0c5b2a7f6e',
- token:
- 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MjgxNzA4MzEsImlhdCI6MTYyNzU2NjAzMSwiaXNzIjoiYmxpaW5rIiwiZGF0YSI6eyJ0eXBlIjoiYWQtc2VydmVyIiwidHJhbnNhY3Rpb25JZCI6IjM1YmU1NDNjLTNkZTQtNGQ1Yy04N2NjLWIzYzEyOGZiYzU0MCIsIm5ldHdvcmtJZCI6MjEsInNpdGVJZCI6NTksInRhZ0lkIjo1OSwiY29va2llSWQiOiJjNGU4MWVhOS1jMjhmLTQwZDItODY1ZC1hNjQzZjE1OTcyZjUiLCJldmVudElkIjozLCJ0YXJnZXRpbmciOnsicGxhdGZvcm0iOiJXZWJzaXRlIiwiaXAiOiI3OC4xMjIuNzUuNzIiLCJ0aW1lIjoxNjI3NTY2MDMxLCJsb2NhdGlvbiI6eyJsYXRpdHVkZSI6NDguOTczOSwibG9uZ2l0dWRlIjozLjMxMTMsInJlZ2lvbiI6IkhERiIsImNvdW50cnkiOiJGUiIsImNpdHkiOiJTYXVsY2hlcnkiLCJ6aXBDb2RlIjoiMDIzMTAiLCJkZXBhcnRtZW50IjoiMDIifSwiY2l0eSI6IlNhdWxjaGVyeSIsImNvdW50cnkiOiJGUiIsImRldmljZU9zIjoibWFjT1MiLCJkZXZpY2VQbGF0Zm9ybSI6IldlYnNpdGUiLCJyYXdVc2VyQWdlbnQiOiJNb3ppbGxhLzUuMCAoTWFjaW50b3NoOyBJbnRlbCBNYWMgT1MgWCAxMF8xNV83KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvOTEuMC40NDcyLjEyNCBTYWZhcmkvNTM3LjM2In0sImdkcHIiOnsiaGFzQ29uc2VudCI6dHJ1ZX0sIndpbiI6ZmFsc2UsImFkSWQiOjU2NDgsImFkdmVydGlzZXJJZCI6MSwiY2FtcGFpZ25JZCI6MSwiY3JlYXRpdmVJZCI6MjgyNSwiZXJyb3IiOmZhbHNlfX0.-UefQH4G0k-RJGemBYffs-KL7EEwma2Wuwgk2xnpij8',
- },
- headers: {},
- };
-};
-
-/**
- * @description Mockup response from API for RTB creative
- * @param noAd
- * @return {{body: string} | {mode: string, message: string}}
- */
-const getConfigInterpretResponseRTB = (noAd = false, isInvalidVast = false) => {
- if (noAd) {
- return {
- message: 'invalid tag',
- mode: 'no-ad',
- };
- }
-
- const validVast = `
-
-
-
- BLIINK
- https://vast.bliink.io/p/508379d0-9f65-4198-8ba5-f61f2b51224f.xml
- https://e.api.bliink.io/e?name=vast-error&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MzQwMzA1MjcsImlhdCI6MTYzMzQyNTcyNywiaXNzIjoiYmxpaW5rIiwiZGF0YSI6eyJ0eXBlIjoiYWQtc2VydmVyIiwidHJhbnNhY3Rpb25JZCI6ImE2NjJjZGJmLTkzNDYtNDI0MS1iMTU0LTJhOTc2OTg0NjNmOSIsIm5ldHdvcmtJZCI6MjUsInNpdGVJZCI6MTQzLCJ0YWdJZCI6MTI3MSwiY29va2llSWQiOiIwNWFhN2UwMi05MzgzLTQ1NGYtOTJmZC1jOTE2YWNlMmUyZjYiLCJldmVudElkIjozLCJ0YXJnZXRpbmciOnsicGxhdGZvcm0iOiJXZWJzaXRlIiwicmVmZXJyZXIiOiJodHRwOi8vbG9jYWxob3N0OjgxODEvaW50ZWdyYXRpb25FeGFtcGxlcy9ncHQvYmxpaW5rLWluc3RyZWFtLmh0bWwiLCJwYWdlVXJsIjoiaHR0cDovL2xvY2FsaG9zdDo4MTgxL2ludGVncmF0aW9uRXhhbXBsZXMvZ3B0L2JsaWluay1pbnN0cmVhbS5odG1sIiwiaXAiOiIzMS4zOS4xNDEuMTQwIiwidGltZSI6MTYzMzQyNTcyNywibG9jYXRpb24iOnsibGF0aXR1ZGUiOjQ4Ljk0MjIsImxvbmdpdHVkZSI6Mi41MDM5LCJyZWdpb24iOiJJREYiLCJjb3VudHJ5IjoiRlIiLCJjaXR5IjoiQXVsbmF5LXNvdXMtQm9pcyIsInppcENvZGUiOiI5MzYwMCIsImRlcGFydG1lbnQiOiI5MyJ9LCJjaXR5IjoiQXVsbmF5LXNvdXMtQm9pcyIsImNvdW50cnkiOiJGUiIsImRldmljZU9zIjoibWFjT1MiLCJkZXZpY2VQbGF0Zm9ybSI6IldlYnNpdGUiLCJyYXdVc2VyQWdlbnQiOiJNb3ppbGxhLzUuMCAoTWFjaW50b3NoOyBJbnRlbCBNYWMgT1MgWCAxMF8xNV83KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvOTMuMC40NTc3LjYzIFNhZmFyaS81MzcuMzYiLCJjb250ZW50Q2xhc3NpZmljYXRpb24iOnsiYnJhbmRzYWZlIjpmYWxzZX19LCJnZHByIjp7Imhhc0NvbnNlbnQiOnRydWV9LCJ3aW4iOmZhbHNlLCJhZElkIjo1NzkzLCJhZHZlcnRpc2VySWQiOjEsImNhbXBhaWduSWQiOjEsImNyZWF0aXZlSWQiOjExOTQsImVycm9yIjpmYWxzZX19.nJSJPKovg0_jSHtLdrMPDqesAIlFKCuXPXYxpsyWBDw
- https://e.api.bliink.io/e?name=impression&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MzQwMzA1MjcsImlhdCI6MTYzMzQyNTcyNywiaXNzIjoiYmxpaW5rIiwiZGF0YSI6eyJ0eXBlIjoiYWQtc2VydmVyIiwidHJhbnNhY3Rpb25JZCI6ImE2NjJjZGJmLTkzNDYtNDI0MS1iMTU0LTJhOTc2OTg0NjNmOSIsIm5ldHdvcmtJZCI6MjUsInNpdGVJZCI6MTQzLCJ0YWdJZCI6MTI3MSwiY29va2llSWQiOiIwNWFhN2UwMi05MzgzLTQ1NGYtOTJmZC1jOTE2YWNlMmUyZjYiLCJldmVudElkIjozLCJ0YXJnZXRpbmciOnsicGxhdGZvcm0iOiJXZWJzaXRlIiwicmVmZXJyZXIiOiJodHRwOi8vbG9jYWxob3N0OjgxODEvaW50ZWdyYXRpb25FeGFtcGxlcy9ncHQvYmxpaW5rLWluc3RyZWFtLmh0bWwiLCJwYWdlVXJsIjoiaHR0cDovL2xvY2FsaG9zdDo4MTgxL2ludGVncmF0aW9uRXhhbXBsZXMvZ3B0L2JsaWluay1pbnN0cmVhbS5odG1sIiwiaXAiOiIzMS4zOS4xNDEuMTQwIiwidGltZSI6MTYzMzQyNTcyNywibG9jYXRpb24iOnsibGF0aXR1ZGUiOjQ4Ljk0MjIsImxvbmdpdHVkZSI6Mi41MDM5LCJyZWdpb24iOiJJREYiLCJjb3VudHJ5IjoiRlIiLCJjaXR5IjoiQXVsbmF5LXNvdXMtQm9pcyIsInppcENvZGUiOiI5MzYwMCIsImRlcGFydG1lbnQiOiI5MyJ9LCJjaXR5IjoiQXVsbmF5LXNvdXMtQm9pcyIsImNvdW50cnkiOiJGUiIsImRldmljZU9zIjoibWFjT1MiLCJkZXZpY2VQbGF0Zm9ybSI6IldlYnNpdGUiLCJyYXdVc2VyQWdlbnQiOiJNb3ppbGxhLzUuMCAoTWFjaW50b3NoOyBJbnRlbCBNYWMgT1MgWCAxMF8xNV83KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvOTMuMC40NTc3LjYzIFNhZmFyaS81MzcuMzYiLCJjb250ZW50Q2xhc3NpZmljYXRpb24iOnsiYnJhbmRzYWZlIjpmYWxzZX19LCJnZHByIjp7Imhhc0NvbnNlbnQiOnRydWV9LCJ3aW4iOmZhbHNlLCJhZElkIjo1NzkzLCJhZHZlcnRpc2VySWQiOjEsImNhbXBhaWduSWQiOjEsImNyZWF0aXZlSWQiOjExOTQsImVycm9yIjpmYWxzZX19.nJSJPKovg0_jSHtLdrMPDqesAIlFKCuXPXYxpsyWBDw
- 1EUR
-
-
-
- `;
- const invalidVast = `
-
-
-
-
-
- `;
-
- return {
- body: {
- bids: [
- {
- creative: {
- video: {
- content: isInvalidVast ? invalidVast : validVast,
- height: 250,
- width: 300,
- },
- media_type: 'video',
- creativeId: 0,
- },
- price: 0,
- id: '8121',
- token: 'token',
- mode: 'rtb',
- extras: {
- deal_id: '34567ertyaza',
- transaction_id: '2def0c5b2a7f6e',
- },
- currency: 'EUR',
- },
- ],
- userSyncs: [],
- },
- };
-};
-
-/**
- *
- *
- *
- * @description Below start tests for utils fonctions
- *
- *
- *
- */
-
-const testsGetMetaList = [
- {
- title: 'Should return empty array if there are no parameters',
- args: {
- fn: getMetaList(),
- },
- want: [],
- },
- {
- title: 'Should return list of metas with name associated',
- args: {
- fn: getMetaList('test'),
- },
- want: [
- {
- key: 'name',
- value: 'test',
- },
- {
- key: 'name*',
- value: 'test',
- },
- {
- key: 'itemprop*',
- value: 'test',
- },
- {
- key: 'property',
- value: `'og:${'test'}'`,
- },
- {
- key: 'property',
- value: `'twitter:${'test'}'`,
- },
- {
- key: 'property',
- value: `'article:${'test'}'`,
- },
- ],
- },
-];
-
-describe('BLIINK Adapter getMetaList', function () {
- for (const test of testsGetMetaList) {
- it(test.title, () => {
- const res = test.args.fn;
- expect(res).to.eql(test.want);
- });
- }
-});
-const GetUserIds = [
- {
- title: 'Should return undefined if there are no parameters',
- args: {
- fn: getUserIds(),
- },
- want: undefined,
- },
- {
- title: 'Should return eids if exists',
- args: {
- fn: getUserIds([{ userIdAsEids: [
- {
- 'source': 'criteo.com',
- 'uids': [
- {
- 'id': 'testId',
- 'atype': 1
- }
- ]
- }
- ] }]),
- },
- want: [
- {
- 'source': 'criteo.com',
- 'uids': [
- {
- 'id': 'testId',
- 'atype': 1
- }
- ]
- }
- ],
- },
-];
-
-describe('BLIINK Adapter getUserIds', function () {
- for (const test of GetUserIds) {
- it(test.title, () => {
- const res = test.args.fn;
- expect(res).to.eql(test.want);
- });
- }
-});
-
-/**
- * @description Array of tests used in describe function below
- * @type {[{args: {fn: (string|Document)}, want: string, title: string}, {args: {fn: (string|Document)}, want: string, title: string}]}
- */
-
-/**
- *
- *
- *
- * @description End tests for utils fonctions
- *
- *
- *
- */
-
-/**
- * @description Array of tests used in describe function below
- * @type {[{args: {fn}, want: boolean, title: string}, {args: {fn}, want: boolean, title: string}, {args: {fn}, want: boolean, title: string}]}
- */
-const testsIsBidRequestValid = [
- {
- title: 'isBidRequestValid format not valid',
- args: {
- fn: spec.isBidRequestValid({}),
- },
- want: false,
- },
- {
- title: 'isBidRequestValid does not receive any bid',
- args: {
- fn: spec.isBidRequestValid(),
- },
- want: false,
- },
- {
- title: 'isBidRequestValid Receive a valid bid',
- args: {
- fn: spec.isBidRequestValid(getConfigBid('banner')),
- },
- want: true,
- },
-];
-
-describe('BLIINK Adapter isBidRequestValid', function () {
- for (const test of testsIsBidRequestValid) {
- it(test.title, () => {
- const res = test.args.fn;
- expect(res).to.eql(test.want);
- });
- }
-});
-
-const vastXml =
- getConfigInterpretResponseRTB().body.bids[0].creative.video.content;
-
-const testsInterpretResponse = [
- {
- title: 'Should construct bid for video instream',
- args: {
- fn: spec.interpretResponse(getConfigInterpretResponseRTB(false)),
- },
- want: [
- {
- cpm: 0,
- currency: 'EUR',
- height: 250,
- width: 300,
- creativeId: '34567ertyaza',
- mediaType: 'video',
- netRevenue: true,
- requestId: '2def0c5b2a7f6e',
- ttl: 300,
- vastXml,
- vastUrl:
- 'data:text/xml;charset=utf-8;base64,' +
- btoa(vastXml.replace(/\\"/g, '"')),
- },
- ],
- },
- {
- title: 'ServerResponse with message: invalid tag, return empty array',
- args: {
- fn: spec.interpretResponse(getConfigInterpretResponse(true)),
- },
- want: [],
- },
- {
- title: 'ServerResponse with mediaType banner',
- args: {
- fn: spec.interpretResponse({ body: { bids: [getConfigBannerBid()] } }),
- },
- want: [
- {
- ad: '',
- cpm: 1,
- creativeId: '34567erty',
- currency: 'EUR',
- height: 250,
- mediaType: 'banner',
- netRevenue: true,
- requestId: '2def0c5b2a7f6e',
- ttl: 300,
- width: 300,
- },
- ],
- },
- {
- title: 'ServerResponse with unhandled mediaType, return empty array',
- args: {
- fn: spec.interpretResponse({
- body: {
- bids: [
- {
- ...getConfigBannerBid(),
- creative: {
- unknown: {
- adm: '',
- height: 250,
- width: 300,
- },
- media_type: 'unknown',
- creativeId: 125,
- requestId: '2def0c5b2a7f6e',
- },
- },
- ],
- },
- }),
- },
- want: [],
- },
-];
-
-describe('BLIINK Adapter interpretResponse', function () {
- for (const test of testsInterpretResponse) {
- it(test.title, () => {
- const res = test.args.fn;
-
- if (res) {
- expect(res).to.eql(test.want);
- }
- });
- }
-});
-
-/**
- * @description Array of tests used in describe function below
- * @type {[
- * {args:
- * {fn: {
- * cpm: number,
- * netRevenue: boolean,
- * ad, requestId,
- * meta: {mediaType},
- * width: number,
- * currency: string,
- * ttl: number,
- * creativeId: number,
- * height: number
- * }
- * }, want, title: string}]}
- */
-
-const testsBuildBid = [
- {
- title: 'Should return null if no bid passed in parameters',
- args: {
- fn: buildBid(),
- },
- want: null,
- },
- {
- title: 'Input data must respect the output model',
- args: {
- fn: buildBid(
- { id: 1, test: '123' },
- { id: 2, test: '345' },
- false,
- false
- ),
- },
- want: null,
- },
- {
- title: 'input data respect the output model for video',
- args: {
- fn: buildBid(getConfigVideoBid('video'), getConfigCreativeVideo()),
- },
- want: {
- requestId: getConfigBid('video').bidId,
- cpm: 1,
- currency: 'EUR',
- mediaType: 'video',
- width: 300,
- height: 250,
- creativeId: getConfigVideoBid().extras.deal_id,
- netRevenue: true,
- vastXml: getConfigCreativeVideo().vastXml,
- vastUrl:
- 'data:text/xml;charset=utf-8;base64,' +
- btoa(getConfigCreativeVideo().vastXml.replace(/\\"/g, '"')),
- ttl: 300,
- },
- },
- {
- title: 'use default height width output model for video',
- args: {
- fn: buildBid(
- {
- ...getConfigVideoBid('video'),
- creative: {
- video: {
- content: '',
- height: null,
- width: null,
- },
- media_type: 'video',
- creativeId: getConfigVideoBid().extras.deal_id,
- requestId: '2def0c5b2a7f6e',
- },
- },
- getConfigCreativeVideo()
- ),
- },
- want: {
- requestId: getConfigBid('video').bidId,
- cpm: 1,
- currency: 'EUR',
- mediaType: 'video',
- width: 1,
- height: 1,
- creativeId: getConfigVideoBid().extras.deal_id,
- netRevenue: true,
- vastXml: getConfigCreativeVideo().vastXml,
- vastUrl:
- 'data:text/xml;charset=utf-8;base64,' +
- btoa(getConfigCreativeVideo().vastXml.replace(/\\"/g, '"')),
- ttl: 300,
- },
- },
- {
- title: 'input data respect the output model for banner',
- args: {
- fn: buildBid(getConfigBannerBid()),
- },
- want: {
- requestId: getConfigBid('banner').bidId,
- cpm: 1,
- currency: 'EUR',
- mediaType: 'banner',
- width: 300,
- height: 250,
- creativeId: getConfigCreative().creativeId,
- ad: getConfigBannerBid().creative.banner.adm,
- ttl: 300,
- netRevenue: true,
- },
- },
-];
-
-describe('BLIINK Adapter buildBid', function () {
- for (const test of testsBuildBid) {
- it(test.title, () => {
- const res = test.args.fn;
- expect(res).to.eql(test.want);
- });
- }
-});
-
-/**
- * @description Array of tests used in describe function below
- * @type {[{args: {fn}, want, title: string}]}
- */
-const testsBuildRequests = [
- {
- title: 'Should not build request, no bidder request exist',
- args: {
- fn: spec.buildRequests(),
- },
- want: null,
- },
- {
- title: 'Should build request if bidderRequest exist',
- args: {
- fn: spec.buildRequests([], getConfigBuildRequest('banner')),
- },
- want: {
- method: 'POST',
- url: BLIINK_ENDPOINT_ENGINE,
- data: {
- domLoadingDuration,
- ect: connectionType,
- keywords: '',
- pageDescription: '',
- pageTitle: '',
- pageUrl:
- 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html',
- tags: [
- {
- transactionId: '2def0c5b2a7f6e',
- refresh: window.bliinkBid['14f30eca-85d2-11e8-9eed-0242ac120007'] || undefined,
- id: '14f30eca-85d2-11e8-9eed-0242ac120007',
- imageUrl: 'https://www.example.com/adimage.jpg',
- videoUrl: 'https://www.example.com/advideo.mp4',
- mediaTypes: ['banner'],
- sizes: [
- {
- h: 250,
- w: 300,
- },
- ],
- },
- ],
- },
- },
- },
- {
- title: 'Should build request width GDPR configuration',
- args: {
- fn: spec.buildRequests(
- [],
- Object.assign(getConfigBuildRequest('banner'), {
- gdprConsent: {
- gdprApplies: true,
- consentString: 'XXXX',
- },
- })
- ),
- },
- want: {
- method: 'POST',
- url: BLIINK_ENDPOINT_ENGINE,
- data: {
- domLoadingDuration,
- ect: connectionType,
- gdpr: true,
- gdprConsent: 'XXXX',
- pageDescription: '',
- pageTitle: '',
- keywords: '',
- pageUrl:
- 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html',
- tags: [
- {
- transactionId: '2def0c5b2a7f6e',
- refresh: window.bliinkBid['14f30eca-85d2-11e8-9eed-0242ac120007'] || undefined,
- id: '14f30eca-85d2-11e8-9eed-0242ac120007',
- imageUrl: 'https://www.example.com/adimage.jpg',
- videoUrl: 'https://www.example.com/advideo.mp4',
- mediaTypes: ['banner'],
- sizes: [
- {
- h: 250,
- w: 300,
- },
- ],
- },
- ],
- },
- },
- },
- {
- title: 'Should build request width uspConsent if exists',
- args: {
- fn: spec.buildRequests(
- [],
- Object.assign(getConfigBuildRequest('banner'), {
- gdprConsent: {
- gdprApplies: true,
- consentString: 'XXXX',
- },
- uspConsent: 'uspConsent',
- })
- ),
- },
- want: {
- method: 'POST',
- url: BLIINK_ENDPOINT_ENGINE,
- data: {
- domLoadingDuration,
- ect: connectionType,
- gdpr: true,
- uspConsent: 'uspConsent',
- gdprConsent: 'XXXX',
- pageDescription: '',
- pageTitle: '',
- keywords: '',
- pageUrl:
- 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html',
- tags: [
- {
- transactionId: '2def0c5b2a7f6e',
- refresh: window.bliinkBid['14f30eca-85d2-11e8-9eed-0242ac120007'] || undefined,
- id: '14f30eca-85d2-11e8-9eed-0242ac120007',
- imageUrl: 'https://www.example.com/adimage.jpg',
- videoUrl: 'https://www.example.com/advideo.mp4',
- mediaTypes: ['banner'],
- sizes: [
- {
- h: 250,
- w: 300,
- },
- ],
- },
- ],
- },
- },
- },
- {
- title: 'Should build request width schain if exists',
- args: {
- fn: spec.buildRequests(
- [
- {
- ortb2: {
- source: {
- ext: {
- schain: {
- ver: '1.0',
- complete: 1,
- nodes: [
- {
- asi: 'ssp.test',
- sid: '00001',
- hp: 1,
- },
- ],
- }
- }
- }
- },
- },
- ],
- Object.assign(getConfigBuildRequest('banner'), {
- gdprConsent: {
- gdprApplies: true,
- consentString: 'XXXX',
- },
- })
- ),
- },
- want: {
- method: 'POST',
- url: BLIINK_ENDPOINT_ENGINE,
- data: {
- domLoadingDuration,
- ect: connectionType,
- gdpr: true,
- gdprConsent: 'XXXX',
- pageDescription: '',
- pageTitle: '',
- keywords: '',
- pageUrl:
- 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html',
- schain: {
- ver: '1.0',
- complete: 1,
- nodes: [
- {
- asi: 'ssp.test',
- sid: '00001',
- hp: 1,
- },
- ],
- },
- tags: [
- {
- transactionId: '2def0c5b2a7f6e',
- refresh: window.bliinkBid['14f30eca-85d2-11e8-9eed-0242ac120007'] || undefined,
- id: '14f30eca-85d2-11e8-9eed-0242ac120007',
- imageUrl: 'https://www.example.com/adimage.jpg',
- videoUrl: 'https://www.example.com/advideo.mp4',
- mediaTypes: ['banner'],
- sizes: [
- {
- h: 250,
- w: 300,
- },
- ],
- },
- ],
- },
- },
- },
- {
- title: 'Should build request with eids if exists',
- args: {
- fn: spec.buildRequests(
- [
- {
- userIdAsEids: [
- {
- 'source': 'criteo.com',
- 'uids': [
- {
- 'id': 'vG4RRF93V05LRlJUTVVOQTJJJTJGbG1rZWxEeDVvc0NXWE42TzJqU2hG',
- 'atype': 1
- }
- ]
- },
- {
- 'source': 'netid.de',
- 'uids': [
- {
- 'id': 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg',
- 'atype': 1
- }
- ]
- }
- ],
- },
- ],
- Object.assign(getConfigBuildRequest('banner'), {
- gdprConsent: {
- gdprApplies: true,
- consentString: 'XXXX',
- },
- })
- ),
- },
- want: {
- method: 'POST',
- url: BLIINK_ENDPOINT_ENGINE,
- data: {
- domLoadingDuration,
- ect: connectionType,
- gdpr: true,
- gdprConsent: 'XXXX',
- pageDescription: '',
- pageTitle: '',
- keywords: '',
- pageUrl:
- 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html',
- eids: [
- {
- 'source': 'criteo.com',
- 'uids': [
- {
- 'id': 'vG4RRF93V05LRlJUTVVOQTJJJTJGbG1rZWxEeDVvc0NXWE42TzJqU2hG',
- 'atype': 1
- }
- ]
- },
- {
- 'source': 'netid.de',
- 'uids': [
- {
- 'id': 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg',
- 'atype': 1
- }
- ]
- }
- ],
- tags: [
- {
- transactionId: '2def0c5b2a7f6e',
- refresh: window.bliinkBid['14f30eca-85d2-11e8-9eed-0242ac120007'] || undefined,
- id: '14f30eca-85d2-11e8-9eed-0242ac120007',
- imageUrl: 'https://www.example.com/adimage.jpg',
- videoUrl: 'https://www.example.com/advideo.mp4',
- mediaTypes: ['banner'],
- sizes: [
- {
- h: 250,
- w: 300,
- },
- ],
- },
- ],
- },
- },
- },
-];
-
-describe('BLIINK Adapter buildRequests', function () {
- for (const test of testsBuildRequests) {
- it(test.title, () => {
- const res = test.args.fn;
- expect(res).to.eql(test.want);
- });
- }
-});
-
-const getSyncOptions = (pixelEnabled = true, iframeEnabled = false) => {
- return {
- pixelEnabled,
- iframeEnabled,
- };
-};
-
-const getServerResponses = () => {
- return [
- {
- body: {
- bids: [],
- userSyncs: [
- {
- type: 'script',
- url: 'https://prg.smartadserver.com/ac?out=js&nwid=3392&siteid=305791&pgname=rg&fmtid=81127&tgt=[sas_target]&visit=m&tmstp=[timestamp]&clcturl=[countgo]',
- },
- {
- type: 'image',
- url: 'https://sync.smartadserver.com/getuid?nwid=3392&consentString=XXX&url=https%3A%2F%2Fcookiesync.api.bliink.io%2Fcookiesync%3Fpartner%3Dsmart%26uid%3D%5Bsas_uid%5D',
- },
- ],
- },
- },
- ];
-};
-
-const getGdprConsent = () => {
- return {
- gdprApplies: 1,
- consentString: 'XXX',
- apiVersion: 2,
- };
-};
-
-const testsGetUserSyncs = [
- {
- title: 'Should not have gdprConsent exist',
- args: {
- fn: spec.getUserSyncs(
- getSyncOptions(),
- getServerResponses(),
- getGdprConsent()
- ),
- },
- want: [
- {
- type: 'script',
- url: 'https://prg.smartadserver.com/ac?out=js&nwid=3392&siteid=305791&pgname=rg&fmtid=81127&tgt=[sas_target]&visit=m&tmstp=[timestamp]&clcturl=[countgo]',
- },
- {
- type: 'image',
- url: 'https://sync.smartadserver.com/getuid?nwid=3392&consentString=XXX&url=https%3A%2F%2Fcookiesync.api.bliink.io%2Fcookiesync%3Fpartner%3Dsmart%26uid%3D%5Bsas_uid%5D',
- },
- ],
- },
- {
- title: 'Should return iframe cookie sync if iframeEnabled',
- args: {
- fn: spec.getUserSyncs(
- getSyncOptions(true, true),
- getServerResponses(),
- getGdprConsent()
- ),
- },
- want: [
- {
- type: 'iframe',
- url: `${BLIINK_ENDPOINT_COOKIE_SYNC_IFRAME}?gdpr=${
- getGdprConsent().gdprApplies
- }&coppa=0&gdprConsent=${getGdprConsent().consentString}&apiVersion=${
- getGdprConsent().apiVersion
- }`,
- },
- ],
- },
- {
- title: 'ccpa',
- args: {
- fn: spec.getUserSyncs(
- getSyncOptions(true, true),
- getServerResponses(),
- getGdprConsent(),
- 'ccpa-consent'
- ),
- },
- want: [
- {
- type: 'iframe',
- url: `${BLIINK_ENDPOINT_COOKIE_SYNC_IFRAME}?gdpr=${
- getGdprConsent().gdprApplies
- }&coppa=0&uspConsent=ccpa-consent&gdprConsent=${
- getGdprConsent().consentString
- }&apiVersion=${getGdprConsent().apiVersion}`,
- },
- ],
- },
- {
- title: 'Should output sync if no gdprConsent',
- args: {
- fn: spec.getUserSyncs(getSyncOptions(), getServerResponses()),
- },
- want: getServerResponses()[0].body.userSyncs,
- },
- {
- title: 'Should output empty array if no pixelEnabled',
- args: {
- fn: spec.getUserSyncs({}, getServerResponses()),
- },
- want: [],
- },
-];
-
-describe('BLIINK Adapter getUserSyncs', function () {
- for (const test of testsGetUserSyncs) {
- it(test.title, () => {
- const res = test.args.fn;
- expect(res).to.eql(test.want);
- });
- }
-});
-
-describe('BLIINK Adapter keywords & coppa true', function () {
- let querySelectorStub;
- let configStub;
- let originalTitle;
-
- beforeEach(() => {
- window.bliinkBid = {};
- const metaElement = document.createElement('meta');
- metaElement.name = 'keywords';
- metaElement.content = 'Bliink, Saber, Prebid';
- sinon.stub(utils, 'getDomLoadingDuration').returns(0);
- domLoadingDuration = '0';
- configStub = sinon.stub(config, 'getConfig');
- configStub.withArgs('coppa').returns(true);
- querySelectorStub = sinon.stub(document, 'querySelector').returns(metaElement);
- originalTitle = document.title;
- document.title = '';
- });
-
- afterEach(() => {
- querySelectorStub.restore();
- configStub.restore();
- utils.getDomLoadingDuration.restore();
- document.title = originalTitle;
- });
-
- it('Should build request with keyword and coppa true if exist', () => {
- expect(
- spec.buildRequests(
- [],
- Object.assign(getConfigBuildRequest('banner'), {
- gdprConsent: {
- gdprApplies: true,
- consentString: 'XXXX',
- },
- })
- )
- ).to.eql({
- method: 'POST',
- url: BLIINK_ENDPOINT_ENGINE,
- data: {
- domLoadingDuration,
- ect: getEffectiveConnectionType(),
- gdpr: true,
- coppa: 1,
- gdprConsent: 'XXXX',
- pageDescription: 'Bliink, Saber, Prebid',
- pageTitle: '',
- keywords: 'Bliink,Saber,Prebid',
- pageUrl:
- 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html',
- tags: [
- {
- transactionId: '2def0c5b2a7f6e',
- id: '14f30eca-85d2-11e8-9eed-0242ac120007',
- imageUrl: 'https://www.example.com/adimage.jpg',
- videoUrl: 'https://www.example.com/advideo.mp4',
- mediaTypes: ['banner'],
- refresh: window.bliinkBid['14f30eca-85d2-11e8-9eed-0242ac120007'] || undefined,
- sizes: [
- {
- h: 250,
- w: 300,
- },
- ],
- },
- ],
- },
- });
- });
-});
-
-describe('getEffectiveConnectionType', () => {
- let navigatorStub;
-
- beforeEach(() => {
- if ('connection' in navigator) {
- navigatorStub = sinon.stub(navigator, 'connection').value({
- effectiveType: undefined,
- });
- }
- });
-
- afterEach(() => {
- if (navigatorStub) {
- navigatorStub.restore();
- }
- });
- if (navigatorStub) {
- it('should return "unsupported" when effective connection type is undefined', () => {
- const result = getEffectiveConnectionType();
- expect(result).to.equal('unsupported');
- });
- }
-});
-
-it('should expose gvlid', function () {
- expect(spec.gvlid).to.equal(GVL_ID);
-});
diff --git a/test/spec/modules/blockthroughBidAdapter_spec.js b/test/spec/modules/blockthroughBidAdapter_spec.js
deleted file mode 100644
index f0778eba7..000000000
--- a/test/spec/modules/blockthroughBidAdapter_spec.js
+++ /dev/null
@@ -1,207 +0,0 @@
-import { expect } from 'chai';
-import { spec } from 'modules/blockthroughBidAdapter.js';
-import { BANNER } from '../../../src/mediaTypes.js';
-// load modules that register ORTB processors
-import 'src/prebid.js';
-import 'modules/currency.js';
-import 'modules/userId/index.js';
-import 'modules/multibid/index.js';
-import 'modules/priceFloors.js';
-import 'modules/consentManagementTcf.js';
-import 'modules/consentManagementUsp.js';
-import 'modules/consentManagementGpp.js';
-import 'modules/tcfControl.js';
-import 'modules/gppControl_usnat.js';
-
-describe('BT Bid Adapter', () => {
- const ENDPOINT_URL = 'https://pbs.btloader.com/openrtb2/auction';
- const validBidRequests = [
- {
- bidId: '2e9f38ea93bb9e',
- bidder: 'blockthrough',
- adUnitCode: 'adunit-code',
- mediaTypes: { [BANNER]: { sizes: [[300, 250]] } },
- params: {
- bidderA: {
- pubId: '11111',
- },
- },
- bidderRequestId: 'test-bidder-request-id',
- },
- ];
- const bidderRequest = {
- bidderCode: 'blockthrough',
- bidderRequestId: 'test-bidder-request-id',
- bids: validBidRequests,
- };
-
- describe('isBidRequestValid', function () {
- it('should validate bid request with valid params', () => {
- const validBid = {
- params: {
- pubmatic: {
- publisherId: 55555,
- },
- },
- sizes: [[300, 250]],
- bidId: '123',
- adUnitCode: 'leaderboard',
- };
-
- const isValid = spec.isBidRequestValid(validBid);
-
- expect(isValid).to.be.true;
- });
-
- it('should not validate bid request with invalid params', () => {
- const invalidBid = {
- params: {},
- sizes: [[300, 250]],
- bidId: '123',
- adUnitCode: 'leaderboard',
- };
-
- const isValid = spec.isBidRequestValid(invalidBid);
-
- expect(isValid).to.be.false;
- });
- });
-
- describe('buildRequests', () => {
- it('should build post request when ortb2 fields are present', () => {
- const impExtParams = {
- bidderA: {
- pubId: '11111',
- },
- };
-
- const requests = spec.buildRequests(validBidRequests, bidderRequest);
-
- expect(requests[0].method).to.equal('POST');
- expect(requests[0].url).to.equal(ENDPOINT_URL);
- expect(requests[0].data).to.exist;
- expect(requests[0].data.ext.prebid.channel).to.deep.equal({
- name: 'pbjs',
- version: '$prebid.version$',
- });
- expect(requests[0].data.imp[0].ext).to.deep.equal(impExtParams);
- });
- });
-
- describe('interpretResponse', () => {
- it('should return empty array if serverResponse is not defined', () => {
- const bidRequest = spec.buildRequests(validBidRequests, bidderRequest);
- const bids = spec.interpretResponse(undefined, bidRequest);
-
- expect(bids.length).to.equal(0);
- });
-
- it('should return bids array when serverResponse is defined and seatbid array is not empty', () => {
- const bidResponse = {
- body: {
- id: 'bid-response',
- cur: 'USD',
- seatbid: [
- {
- bid: [
- {
- impid: '2e9f38ea93bb9e',
- crid: 'creative-id',
- cur: 'USD',
- price: 2,
- w: 300,
- h: 250,
- mtype: 1,
- adomain: ['test.com'],
- },
- ],
- seat: 'test-seat',
- },
- ],
- },
- };
-
- const expectedBids = [
- {
- btBidderCode: 'test-seat',
- cpm: 2,
- creativeId: 'creative-id',
- creative_id: 'creative-id',
- currency: 'USD',
- height: 250,
- mediaType: 'banner',
- meta: {
- advertiserDomains: ['test.com'],
- },
- netRevenue: true,
- requestId: '2e9f38ea93bb9e',
- ttl: 60,
- width: 300,
- },
- ];
-
- const request = spec.buildRequests(validBidRequests, bidderRequest)[0];
- const bids = spec.interpretResponse(bidResponse, request);
-
- expect(bids).to.deep.equal(expectedBids);
- });
- });
-
- describe('getUserSyncs', () => {
- const SYNC_URL = 'https://cdn.btloader.com/user_sync.html';
-
- it('should return an empty array if no sync options are provided', () => {
- const syncs = spec.getUserSyncs({}, [], null, null, null);
-
- expect(syncs).to.deep.equal([]);
- });
-
- it('should return an empty array if no server responses are provided', () => {
- const syncs = spec.getUserSyncs(
- { iframeEnabled: true },
- [],
- null,
- null,
- null
- );
-
- expect(syncs).to.deep.equal([]);
- });
-
- it('should pass consent parameters and bidder codes in sync URL if they are provided', () => {
- const gdprConsent = {
- gdprApplies: true,
- consentString: 'GDPRConsentString123',
- };
- const gppConsent = {
- gppString: 'GPPString123',
- applicableSections: ['sectionA'],
- };
- const us_privacy = '1YNY';
- const expectedSyncUrl = new URL(SYNC_URL);
- expectedSyncUrl.searchParams.set('bidders', 'pubmatic,ix');
- expectedSyncUrl.searchParams.set('gdpr', 1);
- expectedSyncUrl.searchParams.set(
- 'gdpr_consent',
- gdprConsent.consentString
- );
- expectedSyncUrl.searchParams.set('gpp', gppConsent.gppString);
- expectedSyncUrl.searchParams.set('gpp_sid', 'sectionA');
- expectedSyncUrl.searchParams.set('us_privacy', us_privacy);
- const syncs = spec.getUserSyncs(
- { iframeEnabled: true },
- [
- { body: { ext: { responsetimemillis: { pubmatic: 123 } } } },
- { body: { ext: { responsetimemillis: { pubmatic: 123, ix: 123 } } } },
- ],
- gdprConsent,
- us_privacy,
- gppConsent
- );
-
- expect(syncs).to.deep.equal([
- { type: 'iframe', url: expectedSyncUrl.href },
- ]);
- });
- });
-});
diff --git a/test/spec/modules/blueBidAdapter_spec.js b/test/spec/modules/blueBidAdapter_spec.js
deleted file mode 100755
index cc373c6c2..000000000
--- a/test/spec/modules/blueBidAdapter_spec.js
+++ /dev/null
@@ -1,164 +0,0 @@
-import { expect } from 'chai';
-import sinon from 'sinon';
-import { spec, storage } from 'modules/blueBidAdapter.js';
-
-const BIDDER_CODE = 'blue';
-const ENDPOINT_URL = 'https://bidder-us-east-1.getblue.io/engine/?src=prebid';
-const GVLID = 620;
-const CURRENCY = 'USD';
-
-describe('blueBidAdapter:', function () {
- let sandbox;
-
- beforeEach(function () {
- sandbox = sinon.createSandbox();
- });
-
- afterEach(function () {
- sandbox.restore();
- });
-
- describe('isBidRequestValid:', function () {
- it('should return true for valid bid requests', function () {
- const validBid = {
- params: {
- placementId: '12345',
- publisherId: '67890',
- },
- };
- expect(spec.isBidRequestValid(validBid)).to.be.true;
- });
-
- it('should return false for invalid bid requests', function () {
- const invalidBid = {
- params: {
- placementId: '12345',
- },
- };
- expect(spec.isBidRequestValid(invalidBid)).to.be.false;
- });
- });
-
- describe('buildRequests:', function () {
- let validBidRequests;
- let bidderRequest;
-
- beforeEach(function () {
- validBidRequests = [
- {
- bidId: 'bid1',
- params: {
- placementId: '12345',
- publisherId: '67890',
- },
- getFloor: () => ({ currency: CURRENCY, floor: 1.5 }),
- },
- ];
-
- bidderRequest = {
- refererInfo: {
- page: 'https://example.com',
- },
- };
-
- sandbox.stub(storage, 'getDataFromLocalStorage').returns('testBuyerId');
- });
-
- it('should build a valid OpenRTB request', function () {
- const [request] = spec.buildRequests(validBidRequests, bidderRequest);
- expect(request.method).to.equal('POST');
- expect(request.url).to.equal(ENDPOINT_URL);
- expect(request.options.contentType).to.equal('application/json');
-
- const ortbRequest = request.data;
- expect(ortbRequest.ext.gvlid).to.equal(GVLID);
- expect(ortbRequest.imp[0].bidfloor).to.equal(1.5);
- expect(ortbRequest.imp[0].bidfloorcur).to.equal(CURRENCY);
- });
-
- it('should omit bidfloor if getFloor is not implemented', function () {
- validBidRequests[0].getFloor = undefined;
-
- const [request] = spec.buildRequests(validBidRequests, bidderRequest);
- const ortbRequest = request.data;
-
- expect(ortbRequest.imp[0].bidfloor).to.be.undefined;
- });
-
- it('should convert from fromORTB', function () {
- const response = {
- id: 'response-id-123456',
- cur: 'USD',
- bidid: '2rgRKcbHfDyX6ZU4zuPuf38h000',
- seatbid: [
- {
- bid: [
- {
- id: '2rgRKcbHfDyX6ZU4zuPuf521444:0',
- impid: '3b948a96652621',
- price: 2,
- adomain: ['example.com'],
- adid: '0',
- adm: '',
- iurl: 'https://ads.bluemsusercontent.com/v1/ad-container?acc=306850905425&ad=2pMGbaJioMDwMIESvwlCUekrdNA',
- h: 600,
- w: 300,
- nurl: 'https://bid-notice.rtb.bluems.com/v1/bid:won?winPrice=${AUCTION_PRICE}&accountId=306850905425&adId=2pMGbaJioMDwMIESvwlCUekrdNA&campaignId=2Xzb0pyfcOibtp9A5XsUSkzj2IT&exchangeId=prebid&tagId=13144370&impressionId=3b948a96652621&bidId=2rgRKcbHfDyX6ZU4zuPuf38hDB8%3A0&bidPrice=2&bidFloor=2&height=600&width=300®ion=us-east-1&targetId=2rgH24MVckzSou4IpTyUa5l3Ija¤cy=USD&campaignCurrency=USD&campaignCurrencyConversionFactor=1&publisherId=13144370&domain=d3fef36u6k6muh.cloudfront.net',
- lurl: 'https://bid-notice.rtb.bluems.com/v1/bid:lost?winPrice=${AUCTION_PRICE}&marketBidRatio=${AUCTION_MBR}&lossReasonCode=${AUCTION_LOSS}&accountId=306850905425&adId=2pMGbaJioMDwMIESvwlCUekrdNA&campaignId=2Xzb0pyfcOibtp9A5XsUSkzj2IT&exchangeId=prebid&tagId=13144370&impressionId=3b948a96652621&bidId=2rgRKcbHfDyX6ZU4zuPuf38hDB8%3A0&bidPrice=2&bidFloor=2&height=600&width=300®ion=us-east-1&targetId=2rgH24MVckzSou4IpTyUa5l3Ija¤cy=USD&campaignCurrency=USD&campaignCurrencyConversionFactor=1&publisherId=13144370&domain=d3fef36u6k6muh.cloudfront.net',
- burl: 'https://bid-notice.rtb.bluems.com/v1/bid:charged?winPrice=${AUCTION_PRICE}&accountId=306850905425&adId=2pMGbaJioMDwMIESvwlCUekrdNA&campaignId=2Xzb0pyfcOibtp9A5XsUSkzj2IT&exchangeId=prebid&tagId=13144370&impressionId=3b948a96652621&bidId=2rgRKcbHfDyX6ZU4zuPuf38hDB8%3A0&bidPrice=2&bidFloor=2&height=600&width=300®ion=us-east-1&targetId=2rgH24MVckzSou4IpTyUa5l3Ija¤cy=USD&campaignCurrency=USD&campaignCurrencyConversionFactor=1&publisherId=13144370&domain=d3fef36u6k6muh.cloudfront.net',
- exp: 60,
- ext: {
- blue: {
- accountId: '306850900000',
- campaignId: '2Xzb0pyfcOibtp9A5X8546254528',
- adId: '2pMGbaJioMDwMIESvwlCUlkojug',
- region: 'us-east-1',
- targetId: '2rgH24MVckzSou4IpTyUalakush',
- },
- },
- },
- ],
- seat: '1',
- },
- ],
- };
- const request = {
- id: '10bb57ee-712f-43e9-9769-b26d03lklkih',
- bidder: BIDDER_CODE,
- params: {
- source: 886409,
- },
- mediaTypes: {
- banner: {
- sizes: [
- [300, 250],
- [300, 600],
- ],
- },
- },
- adUnitCode: 'div-gpt-ad-1460505iosakju-0',
- transactionId: '7d79850b-70aa-4c0f-af95-c1d524sskjkjh',
- sizes: [
- [300, 250],
- [300, 600],
- ],
- bidId: '2eb89f0f062afe',
- bidderRequestId: '1ae6c8e18f8462',
- auctionId: '1286637c-51bc-4fdd-8e35-2435elklklka',
- ortb2: {},
- };
-
- const [ortbReq] = spec.buildRequests([request], {
- bids: [request],
- });
-
- const ortbResponse = spec.interpretResponse(
- { body: response },
- { data: ortbReq.data }
- );
-
- expect(ortbResponse.length).to.eq(1);
- expect(ortbResponse[0].mediaType).to.eq('banner');
- });
- });
-});
diff --git a/test/spec/modules/blueconicRtdProvider_spec.js b/test/spec/modules/blueconicRtdProvider_spec.js
deleted file mode 100644
index 4fe85d8a9..000000000
--- a/test/spec/modules/blueconicRtdProvider_spec.js
+++ /dev/null
@@ -1,135 +0,0 @@
-import {config} from 'src/config.js';
-import {RTD_LOCAL_NAME, addRealTimeData, getRealTimeData, blueconicSubmodule, storage} from 'modules/blueconicRtdProvider.js';
-
-describe('blueconicRtdProvider', function() {
- let getDataFromLocalStorageStub;
- beforeEach(function() {
- config.resetConfig();
- getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage');
- });
-
- afterEach(function () {
- getDataFromLocalStorageStub.restore();
- });
-
- describe('blueconicSubmodule', function() {
- it('successfully instantiates', function () {
- expect(blueconicSubmodule.init()).to.equal(true);
- });
- });
-
- describe('Add Blueconic Real-Time Data', function() {
- it('merges ortb2Fragment data', function() {
- const setConfigUserObj1 = {
- name: 'www.dataprovider1.com',
- ext: {segtax: 1},
- segment: [{id: '1776'}]
- };
- const setConfigUserObj2 = {
- name: 'www.dataprovider2.com',
- ext: {segtax: 1},
- segment: [{id: '1914'}
- ]
- };
-
- const bidConfig = {
- ortb2Fragments: {
- global: {
- user: {
- data: [setConfigUserObj1, setConfigUserObj2]
- }
- }
- }
- };
-
- const rtdUserObj1 = {
- name: 'www.dataprovider4.com',
- ext: {segtax: 1},
- segment: [{id: '1918'}, {id: '1939'}
- ]
- };
-
- const rtd = {
- ortb2: {
- user: {
- data: [rtdUserObj1]
- }
- }
- };
-
- addRealTimeData(bidConfig.ortb2Fragments.global, rtd);
-
- const ortb2Config = bidConfig.ortb2Fragments.global;
- expect(ortb2Config.user.data).to.deep.include.members([setConfigUserObj1, setConfigUserObj2, rtdUserObj1]);
- });
-
- it('merges data without duplication', function() {
- const userObj1 = {
- name: 'www.dataprovider1.com',
- ext: {segtax: 1},
- segment: [{id: '1776'}
- ]
- };
-
- const userObj2 = {
- ext: {segtax: 1},
- name: 'www.dataprovider2.com',
- segment: [{id: '1914'
- }]
- };
-
- const bidConfig = {
- ortb2Fragments:
- {
- global: {
- user: {
- data: [userObj1, userObj2]
- }
- }
- }
- };
-
- const rtd = {
- ortb2: {
- user: {
- data: [userObj1]
- }
- }
- };
-
- addRealTimeData(bidConfig.ortb2Fragments.global, rtd);
-
- const ortb2Config = bidConfig.ortb2Fragments.global;
-
- expect(ortb2Config.user.data).to.deep.include.members([userObj1, userObj2]);
- expect(bidConfig.ortb2Fragments.global.user.data).to.have.lengthOf(2);
- });
- });
-
- describe('Get BlueConic Real-Time Data', function() {
- it('gets rtd from local storage cache', function() {
- const rtdConfig = {
- params: {
- requestParams: {
- publisherId: 'Publisher1',
- coppa: true
- }}
- };
-
- const bidConfig = {ortb2Fragments: {global: {}}};
-
- const rtdUserObj1 = {
- name: 'blueconic',
- ext: {segtax: 1},
- segment: [{id: 'bf23d802-931d-4619-8266-ce9a6328aa2a'}],
- bidId: '1234'
- };
-
- const cachedRtd = {ext: {segtax: 1}, 'segment': [{id: 'bf23d802-931d-4619-8266-ce9a6328aa2a'}], 'bidId': '1234'}
- getDataFromLocalStorageStub.withArgs(RTD_LOCAL_NAME).returns(JSON.stringify(cachedRtd));
-
- getRealTimeData(bidConfig, () => {}, rtdConfig, {});
- expect(bidConfig.ortb2Fragments.global.user.data).to.deep.include.members([rtdUserObj1]);
- });
- });
-});
diff --git a/test/spec/modules/bmsBidAdapter_spec.js b/test/spec/modules/bmsBidAdapter_spec.js
deleted file mode 100755
index 44112032d..000000000
--- a/test/spec/modules/bmsBidAdapter_spec.js
+++ /dev/null
@@ -1,165 +0,0 @@
-import { expect } from 'chai';
-import sinon from 'sinon';
-import { spec, storage } from 'modules/bmsBidAdapter.js';
-
-const BIDDER_CODE = 'bms';
-const ENDPOINT_URL =
- 'https://api.prebid.int.us-east-1.bluems.com/v1/bid?exchangeId=prebid';
-const GVLID = 1105;
-const CURRENCY = 'USD';
-
-describe('bmsBidAdapter:', function () {
- let sandbox;
-
- beforeEach(function () {
- sandbox = sinon.createSandbox();
- });
-
- afterEach(function () {
- sandbox.restore();
- });
-
- describe('isBidRequestValid:', function () {
- it('should return true for valid bid requests', function () {
- const validBid = {
- params: {
- placementId: '12345',
- publisherId: '67890',
- },
- };
- expect(spec.isBidRequestValid(validBid)).to.be.true;
- });
-
- it('should return false for invalid bid requests', function () {
- const invalidBid = {
- params: {
- placementId: '12345',
- },
- };
- expect(spec.isBidRequestValid(invalidBid)).to.be.false;
- });
- });
-
- describe('buildRequests:', function () {
- let validBidRequests;
- let bidderRequest;
-
- beforeEach(function () {
- validBidRequests = [
- {
- bidId: 'bid1',
- params: {
- placementId: '12345',
- publisherId: '67890',
- },
- getFloor: () => ({ currency: CURRENCY, floor: 1.5 }),
- },
- ];
-
- bidderRequest = {
- refererInfo: {
- page: 'https://example.com',
- },
- };
-
- sandbox.stub(storage, 'getDataFromLocalStorage').returns('testBuyerId');
- });
-
- it('should build a valid OpenRTB request', function () {
- const [request] = spec.buildRequests(validBidRequests, bidderRequest);
- expect(request.method).to.equal('POST');
- expect(request.url).to.equal(ENDPOINT_URL);
- expect(request.options.contentType).to.equal('text/plain');
- const ortbRequest = JSON.parse(request.data);
-
- expect(ortbRequest.ext.gvlid).to.equal(GVLID);
- expect(ortbRequest.imp[0].bidfloor).to.equal(1.5);
- expect(ortbRequest.imp[0].bidfloorcur).to.equal(CURRENCY);
- });
-
- it('should omit bidfloor if getFloor is not implemented', function () {
- validBidRequests[0].getFloor = undefined;
-
- const [request] = spec.buildRequests(validBidRequests, bidderRequest);
- const ortbRequest = JSON.parse(request.data);
-
- expect(ortbRequest.imp[0].bidfloor).to.be.undefined;
- });
-
- it('should convert from fromORTB', function () {
- const response = {
- id: 'response-id-123456',
- cur: 'USD',
- bidid: '2rgRKcbHfDyX6ZU4zuPuf38h000',
- seatbid: [
- {
- bid: [
- {
- id: '2rgRKcbHfDyX6ZU4zuPuf521444:0',
- impid: '3b948a96652621',
- price: 2,
- adomain: ['example.com'],
- adid: '0',
- adm: '',
- iurl: 'https://ads.bluemsusercontent.com/v1/ad-container?acc=306850905425&ad=2pMGbaJioMDwMIESvwlCUekrdNA',
- h: 600,
- w: 300,
- nurl: 'https://bid-notice.rtb.bluems.com/v1/bid:won?winPrice=${AUCTION_PRICE}&accountId=306850905425&adId=2pMGbaJioMDwMIESvwlCUekrdNA&campaignId=2Xzb0pyfcOibtp9A5XsUSkzj2IT&exchangeId=prebid&tagId=13144370&impressionId=3b948a96652621&bidId=2rgRKcbHfDyX6ZU4zuPuf38hDB8%3A0&bidPrice=2&bidFloor=2&height=600&width=300®ion=us-east-1&targetId=2rgH24MVckzSou4IpTyUa5l3Ija¤cy=USD&campaignCurrency=USD&campaignCurrencyConversionFactor=1&publisherId=13144370&domain=d3fef36u6k6muh.cloudfront.net',
- lurl: 'https://bid-notice.rtb.bluems.com/v1/bid:lost?winPrice=${AUCTION_PRICE}&marketBidRatio=${AUCTION_MBR}&lossReasonCode=${AUCTION_LOSS}&accountId=306850905425&adId=2pMGbaJioMDwMIESvwlCUekrdNA&campaignId=2Xzb0pyfcOibtp9A5XsUSkzj2IT&exchangeId=prebid&tagId=13144370&impressionId=3b948a96652621&bidId=2rgRKcbHfDyX6ZU4zuPuf38hDB8%3A0&bidPrice=2&bidFloor=2&height=600&width=300®ion=us-east-1&targetId=2rgH24MVckzSou4IpTyUa5l3Ija¤cy=USD&campaignCurrency=USD&campaignCurrencyConversionFactor=1&publisherId=13144370&domain=d3fef36u6k6muh.cloudfront.net',
- burl: 'https://bid-notice.rtb.bluems.com/v1/bid:charged?winPrice=${AUCTION_PRICE}&accountId=306850905425&adId=2pMGbaJioMDwMIESvwlCUekrdNA&campaignId=2Xzb0pyfcOibtp9A5XsUSkzj2IT&exchangeId=prebid&tagId=13144370&impressionId=3b948a96652621&bidId=2rgRKcbHfDyX6ZU4zuPuf38hDB8%3A0&bidPrice=2&bidFloor=2&height=600&width=300®ion=us-east-1&targetId=2rgH24MVckzSou4IpTyUa5l3Ija¤cy=USD&campaignCurrency=USD&campaignCurrencyConversionFactor=1&publisherId=13144370&domain=d3fef36u6k6muh.cloudfront.net',
- exp: 60,
- ext: {
- bms: {
- accountId: '306850900000',
- campaignId: '2Xzb0pyfcOibtp9A5X8546254528',
- adId: '2pMGbaJioMDwMIESvwlCUlkojug',
- region: 'us-east-1',
- targetId: '2rgH24MVckzSou4IpTyUalakush',
- },
- },
- },
- ],
- seat: '1',
- },
- ],
- };
- const request = {
- id: '10bb57ee-712f-43e9-9769-b26d03lklkih',
- bidder: BIDDER_CODE,
- params: {
- source: 886409,
- },
- mediaTypes: {
- banner: {
- sizes: [
- [300, 250],
- [300, 600],
- ],
- },
- },
- adUnitCode: 'div-gpt-ad-1460505iosakju-0',
- transactionId: '7d79850b-70aa-4c0f-af95-c1d524sskjkjh',
- sizes: [
- [300, 250],
- [300, 600],
- ],
- bidId: '2eb89f0f062afe',
- bidderRequestId: '1ae6c8e18f8462',
- auctionId: '1286637c-51bc-4fdd-8e35-2435elklklka',
- ortb2: {},
- };
-
- const [ortbReq] = spec.buildRequests([request], {
- bids: [request],
- });
-
- const ortbResponse = spec.interpretResponse(
- { body: response },
- { data: ortbReq.data }
- );
-
- expect(ortbResponse.length).to.eq(1);
- expect(ortbResponse[0].mediaType).to.eq('banner');
- });
- });
-});
diff --git a/test/spec/modules/bmtmBidAdapter_spec.js b/test/spec/modules/bmtmBidAdapter_spec.js
deleted file mode 100644
index 4af4332f3..000000000
--- a/test/spec/modules/bmtmBidAdapter_spec.js
+++ /dev/null
@@ -1,327 +0,0 @@
-import { expect } from 'chai';
-import { spec } from '../../../modules/bmtmBidAdapter.js';
-
-const BIDDER_CODE = 'bmtm';
-const PLACEMENT_ID = 329;
-
-describe('brightMountainMediaBidAdapter_spec', function () {
- const bidBanner = {
- bidId: '2dd581a2b6281d',
- bidder: BIDDER_CODE,
- bidderRequestId: '145e1d6a7837c9',
- params: {
- placement_id: PLACEMENT_ID
- },
- placementCode: 'placementid_0',
- auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2',
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
- },
- transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62',
- getFloor: function () {
- return {
- currency: 'USD',
- floor: 0.5,
- }
- },
- ortb2: {
- source: {
- ext: {
- schain: {
- ver: '1.0',
- complete: 1,
- nodes: [
- {
- asi: 'directseller.com',
- sid: '00001',
- rid: 'BidRequest1',
- hp: 1
- }
- ]
- }
- }
- }
- },
- userIdAsEids: [
- {
- 'source': 'id5-sync.com',
- 'uids': [
- {
- 'id': 'ID5-ZHMOaW5vh_TJhKVSaTWmuoTpwqjGGwx5v0WbaSV8yw',
- 'atype': 1,
- 'ext': {
- 'linkType': 2
- }
- }
- ]
- },
- {
- 'source': 'pubcid.org',
- 'uids': [
- {
- 'id': '00000000000000000000000000',
- 'atype': 1
- }
- ]
- }
- ]
- };
-
- const bidVideo = {
- bidId: '2dd581a2b6281d',
- bidder: BIDDER_CODE,
- bidderRequestId: '145e1d6a7837c9',
- params: {
- placement_id: PLACEMENT_ID
- },
- placementCode: 'placementid_0',
- auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2',
- mediaTypes: {
- video: {
- playerSizes: [[300, 250]],
- context: 'outstream',
- skip: 0,
- playbackmethod: [1, 2],
- mimes: ['video/mp4']
- }
- },
- transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62',
- };
-
- const bidderRequest = {
- bidderCode: BIDDER_CODE,
- auctionId: 'fffffff-ffff-ffff-ffff-ffffffffffff',
- bidderRequestId: 'ffffffffffffff',
- start: 1472239426002,
- auctionStart: 1472239426000,
- timeout: 5000,
- uspConsent: '1YN-',
- refererInfo: {
- referer: 'http://www.example.com',
- reachedTop: true,
- },
- gdprConsent: {
- consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==',
- gdprApplies: true
- },
- bids: [bidBanner],
- };
-
- describe('isBidRequestValid', function () {
- it('Should return true when when required params found', function () {
- expect(spec.isBidRequestValid(bidBanner)).to.be.true;
- });
- it('Should return false when required params are not passed', function () {
- bidBanner.params = {};
- expect(spec.isBidRequestValid(bidBanner)).to.be.false;
- });
- });
-
- describe('buildRequests', function () {
- const request = spec.buildRequests([bidBanner], bidderRequest)[0];
- const data = JSON.parse(request.data);
-
- it('Creates a ServerRequest object with method, URL and data', function () {
- expect(request).to.exist;
- expect(request.method).to.exist;
- expect(request.url).to.exist;
- expect(request.data).to.exist;
- expect(request.method).to.be.a('string');
- expect(request.url).to.be.a('string');
- expect(request.data).to.be.an('string');
- });
-
- it('Returns valid data if array of bids is valid', function () {
- expect(data).to.be.an('object');
- expect(data).to.have.all.keys('at', 'site', 'device', 'cur', 'tmax', 'regs', 'user', 'source', 'imp', 'id');
- expect(data.at).to.be.a('number');
- expect(data.site).to.be.an('object');
- expect(data.device).to.be.an('object');
- expect(data.cur).to.be.an('array');
- expect(data.tmax).to.be.a('number');
- expect(data.regs).to.be.an('object');
- expect(data.user).to.be.an('object');
- expect(data.source).to.be.an('object');
- expect(data.imp).to.be.an('array');
- expect(data.id).to.be.a('string');
- });
-
- it('Sends bidfloor param if present', function () {
- expect(data.imp[0].bidfloor).to.equal(0.5);
- });
-
- it('Sends regs info if exists', function () {
- expect(data.regs.ext.gdpr).to.exist.and.to.be.a('number');
- expect(data.regs.ext.gdprConsentString).to.exist.and.to.be.a('string');
- expect(data.regs.ext.us_privacy).to.exist.and.to.be.a('string');
- });
-
- it('Sends schain info if exists', function () {
- expect(data.source.ext).to.be.an('object');
- });
-
- it('sends userId info if exists', function () {
- expect(data.user.ext).to.have.property('eids');
- expect(data.user.ext.eids).to.not.equal(null).and.to.not.be.undefined;
- expect(data.user.ext.eids.length).to.greaterThan(0);
- for (const index in data.user.ext.eids) {
- const eid = data.user.ext.eids[index];
- expect(eid.source).to.not.equal(null).and.to.not.be.undefined;
- expect(eid.uids).to.not.equal(null).and.to.not.be.undefined;
- for (const uidsIndex in eid.uids) {
- const uid = eid.uids[uidsIndex];
- expect(uid.id).to.not.equal(null).and.to.not.be.undefined;
- }
- }
- });
-
- it('Returns valid data if array of bids is valid for banner', function () {
- expect(data).to.be.an('object');
- expect(data).to.have.property('imp');
- expect(data.imp.length).to.greaterThan(0);
- expect(data.imp[0]).to.have.property('banner');
- expect(data.imp[0].banner).to.be.an('object');
- expect(data.imp[0].banner.h).to.exist.and.to.be.a('number');
- expect(data.imp[0].banner.w).to.exist.and.to.be.a('number');
- });
-
- it('Returns valid data if array of bids is valid for video', function () {
- bidderRequest.bids = [bidVideo];
- const serverRequest = spec.buildRequests([bidVideo], bidderRequest)[0];
- const data = JSON.parse(serverRequest.data);
- expect(data).to.be.an('object');
- expect(data).to.have.property('imp');
- expect(data.imp.length).to.greaterThan(0);
- expect(data.imp[0]).to.have.property('video');
- expect(data.imp[0].video).to.be.an('object');
- expect(data.imp[0].video.h).to.exist.and.to.be.a('number');
- expect(data.imp[0].video.w).to.exist.and.to.be.a('number');
- });
- });
-
- describe('interpretResponse', function () {
- const resObjectBanner = {
- 'id': '2763-05f22da29b3ffb6-6959',
- 'bidid': 'e5b41111bec9e4a4e94b85d082f8fb08',
- 'seatbid': [
- {
- 'bid': [
- {
- 'id': '9550c3e641761cfbf2a4dd672b50ddb9',
- 'impid': '968',
- 'price': 0.3,
- 'w': 300,
- 'h': 250,
- 'nurl': 'https://example.com/?w=nr&pf=${AUCTION_PRICE}&type=b&uq=483531c101942cbb270cd088b2eec43f',
- 'adomain': [
- 'example.com'
- ],
- 'cid': '3845_105654',
- 'crid': '3845_305654',
- 'adm': 'Test Ad
',
- 'adid': '17794c46ca26',
- 'iurl': 'https://example.com/?t=preview2&k=17794c46ca26'
- }
- ],
- 'seat': '3845'
- }
- ],
- 'cur': 'USD'
- };
-
- const resObjectVideo = {
- 'id': '2763-05f22da29b3ffb6-6959',
- 'bidid': 'e5b41111bec9e4a4e94b85d082f8fb08',
- 'seatbid': [
- {
- 'bid': [
- {
- 'id': '9550c3e641761cfbf2a4dd672b50ddb9',
- 'impid': '968',
- 'price': 0.3,
- 'w': 300,
- 'h': 250,
- 'nurl': 'https://example.com/?w=nr&pf=${AUCTION_PRICE}&type=b&uq=483531c101942cbb270cd088b2eec43f',
- 'adomain': [
- 'example.com'
- ],
- 'cid': '3845_105654',
- 'crid': '3845_305654',
- 'adm': '',
- 'adid': '17794c46ca26',
- 'iurl': 'https://example.com/?t=preview2&k=17794c46ca26'
- }
- ],
- 'seat': '3845'
- }
- ],
- 'cur': 'USD'
- };
-
- it('Returns an array of valid response if response object is valid for banner', function () {
- const bidResponse = spec.interpretResponse({
- body: resObjectBanner
- }, { bidRequest: bidBanner });
-
- expect(bidResponse).to.be.an('array').that.is.not.empty;
- for (let i = 0; i < bidResponse.length; i++) {
- const dataItem = bidResponse[i];
- expect(dataItem.requestId).to.be.a('string');
- expect(dataItem.cpm).to.be.a('number');
- expect(dataItem.width).to.be.a('number');
- expect(dataItem.height).to.be.a('number');
- expect(dataItem.ad).to.be.a('string');
- expect(dataItem.ttl).to.be.a('number');
- expect(dataItem.creativeId).to.be.a('string');
- expect(dataItem.netRevenue).to.be.a('boolean');
- expect(dataItem.currency).to.be.a('string');
- expect(dataItem.mediaType).to.be.a('string');
- expect(dataItem.meta.advertiserDomains[0]).to.be.a('string');
- }
- });
-
- it('Returns an array of valid response if response object is valid for video', function () {
- const bidResponse = spec.interpretResponse({
- body: resObjectVideo
- }, { bidRequest: bidVideo });
-
- expect(bidResponse).to.be.an('array').that.is.not.empty;
- for (let i = 0; i < bidResponse.length; i++) {
- const dataItem = bidResponse[i];
- expect(dataItem.requestId).to.be.a('string');
- expect(dataItem.cpm).to.be.a('number');
- expect(dataItem.width).to.be.a('number');
- expect(dataItem.height).to.be.a('number');
- expect(dataItem.vastXml).to.be.a('string');
- expect(dataItem.ttl).to.be.a('number');
- expect(dataItem.creativeId).to.be.a('string');
- expect(dataItem.netRevenue).to.be.a('boolean');
- expect(dataItem.currency).to.be.a('string');
- expect(dataItem.mediaType).to.be.a('string');
- expect(dataItem.meta.advertiserDomains[0]).to.be.a('string');
- }
- });
-
- it('Returns an empty array if invalid response is passed', function () {
- const bidResponse = spec.interpretResponse({
- body: ''
- }, { bidRequest: bidBanner });
- expect(bidResponse).to.be.an('array').that.is.empty;
- });
- });
-
- describe('getUserSyncs', function () {
- const syncoptionsIframe = {
- 'iframeEnabled': 'true'
- }
- it('should return iframe sync option', function () {
- expect(spec.getUserSyncs(syncoptionsIframe)).to.be.an('array').with.lengthOf(1);
- expect(spec.getUserSyncs(syncoptionsIframe)[0].type).to.exist;
- expect(spec.getUserSyncs(syncoptionsIframe)[0].url).to.exist;
- expect(spec.getUserSyncs(syncoptionsIframe)[0].type).to.equal('iframe')
- expect(spec.getUserSyncs(syncoptionsIframe)[0].url).to.equal('https://console.brightmountainmedia.com:8443/cookieSync')
- });
- });
-});
diff --git a/test/spec/modules/boldwinBidAdapter_spec.js b/test/spec/modules/boldwinBidAdapter_spec.js
deleted file mode 100644
index 5d8c7fab9..000000000
--- a/test/spec/modules/boldwinBidAdapter_spec.js
+++ /dev/null
@@ -1,469 +0,0 @@
-import { expect } from 'chai';
-import { spec } from '../../../modules/boldwinBidAdapter.js';
-import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js';
-import { getUniqueIdentifierStr } from '../../../src/utils.js';
-
-const bidder = 'boldwin';
-
-describe('BoldwinBidAdapter', function () {
- const userIdAsEids = [{
- source: 'test.org',
- uids: [{
- id: '01**********',
- atype: 1,
- ext: {
- third: '01***********'
- }
- }]
- }];
- const bids = [
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
- placementId: 'testBanner'
- },
- userIdAsEids
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [VIDEO]: {
- playerSize: [[300, 300]],
- minduration: 5,
- maxduration: 60
- }
- },
- params: {
- placementId: 'testVideo'
- },
- userIdAsEids
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [NATIVE]: {
- native: {
- title: {
- required: true
- },
- body: {
- required: true
- },
- icon: {
- required: true,
- size: [64, 64]
- }
- }
- }
- },
- params: {
- placementId: 'testNative'
- },
- userIdAsEids
- }
- ];
-
- const invalidBid = {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
-
- }
- }
-
- const bidderRequest = {
- uspConsent: '1---',
- gdprConsent: {
- consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw',
- vendorData: {}
- },
- refererInfo: {
- referer: 'https://test.com',
- page: 'https://test.com'
- },
- ortb2: {
- device: {
- w: 1512,
- h: 982,
- language: 'en-UK'
- }
- },
- timeout: 500
- };
-
- describe('isBidRequestValid', function () {
- it('Should return true if there are bidId, params and key parameters present', function () {
- expect(spec.isBidRequestValid(bids[0])).to.be.true;
- });
- it('Should return false if at least one of parameters is not present', function () {
- expect(spec.isBidRequestValid(invalidBid)).to.be.false;
- });
- });
-
- describe('buildRequests', function () {
- let serverRequest = spec.buildRequests(bids, bidderRequest);
-
- it('Creates a ServerRequest object with method, URL and data', function () {
- expect(serverRequest).to.exist;
- expect(serverRequest.method).to.exist;
- expect(serverRequest.url).to.exist;
- expect(serverRequest.data).to.exist;
- });
-
- it('Returns POST method', function () {
- expect(serverRequest.method).to.equal('POST');
- });
-
- it('Returns valid URL', function () {
- expect(serverRequest.url).to.equal('https://ssp.videowalldirect.com/pbjs');
- });
-
- it('Returns general data valid', function () {
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.all.keys('deviceWidth',
- 'deviceHeight',
- 'device',
- 'language',
- 'secure',
- 'host',
- 'page',
- 'placements',
- 'coppa',
- 'ccpa',
- 'gdpr',
- 'tmax',
- 'bcat',
- 'badv',
- 'bapp',
- 'battr'
- );
- expect(data.deviceWidth).to.be.a('number');
- expect(data.deviceHeight).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');
- expect(data.page).to.be.a('string');
- expect(data.coppa).to.be.a('number');
- expect(data.gdpr).to.be.a('object');
- expect(data.ccpa).to.be.a('string');
- expect(data.tmax).to.be.a('number');
- expect(data.placements).to.have.lengthOf(3);
- });
-
- it('Returns valid placements', function () {
- const { placements } = serverRequest.data;
-
- for (let i = 0, len = placements.length; i < len; i++) {
- const placement = placements[i];
- expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']);
- expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]);
- expect(placement.bidId).to.be.a('string');
- expect(placement.schain).to.be.an('object');
- expect(placement.bidfloor).to.exist.and.to.equal(0);
- expect(placement.type).to.exist.and.to.equal('publisher');
- expect(placement.eids).to.exist.and.to.be.deep.equal(userIdAsEids);
-
- if (placement.adFormat === BANNER) {
- expect(placement.sizes).to.be.an('array');
- }
- switch (placement.adFormat) {
- case BANNER:
- expect(placement.sizes).to.be.an('array');
- break;
- case VIDEO:
- expect(placement.wPlayer).to.be.an('number');
- expect(placement.hPlayer).to.be.an('number');
- expect(placement.minduration).to.be.an('number');
- expect(placement.maxduration).to.be.an('number');
- break;
- case NATIVE:
- expect(placement.native).to.be.an('object');
- break;
- }
- }
- });
-
- it('Returns data with gdprConsent and without uspConsent', function () {
- delete bidderRequest.uspConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.gdpr).to.exist;
- expect(data.gdpr).to.be.a('object');
- expect(data.gdpr).to.have.property('consentString');
- expect(data.gdpr).to.not.have.property('vendorData');
- expect(data.gdpr.consentString).to.equal(bidderRequest.gdprConsent.consentString);
- expect(data.ccpa).to.not.exist;
- delete bidderRequest.gdprConsent;
- });
-
- it('Returns data with uspConsent and without gdprConsent', function () {
- bidderRequest.uspConsent = '1---';
- delete bidderRequest.gdprConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.ccpa).to.exist;
- expect(data.ccpa).to.be.a('string');
- expect(data.ccpa).to.equal(bidderRequest.uspConsent);
- expect(data.gdpr).to.not.exist;
- });
- });
-
- describe('gpp consent', function () {
- it('bidderRequest.gppConsent', () => {
- bidderRequest.gppConsent = {
- gppString: 'abc123',
- applicableSections: [8]
- };
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
-
- delete bidderRequest.gppConsent;
- })
-
- it('bidderRequest.ortb2.regs.gpp', () => {
- bidderRequest.ortb2 = bidderRequest.ortb2 || {};
- bidderRequest.ortb2.regs = bidderRequest.ortb2.regs || {};
- bidderRequest.ortb2.regs.gpp = 'abc123';
- bidderRequest.ortb2.regs.gpp_sid = [8];
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
- })
- });
-
- describe('interpretResponse', function () {
- it('Should interpret banner response', function () {
- const banner = {
- body: [{
- mediaType: 'banner',
- width: 300,
- height: 250,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const bannerResponses = spec.interpretResponse(banner);
- expect(bannerResponses).to.be.an('array').that.is.not.empty;
- const dataItem = bannerResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal(banner.body[0].requestId);
- expect(dataItem.cpm).to.equal(banner.body[0].cpm);
- expect(dataItem.width).to.equal(banner.body[0].width);
- expect(dataItem.height).to.equal(banner.body[0].height);
- expect(dataItem.ad).to.equal(banner.body[0].ad);
- expect(dataItem.ttl).to.equal(banner.body[0].ttl);
- expect(dataItem.creativeId).to.equal(banner.body[0].creativeId);
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal(banner.body[0].currency);
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should interpret video response', function () {
- const video = {
- body: [{
- vastUrl: 'test.com',
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const videoResponses = spec.interpretResponse(video);
- expect(videoResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = videoResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.5);
- expect(dataItem.vastUrl).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should interpret native response', function () {
- const native = {
- body: [{
- mediaType: 'native',
- native: {
- clickUrl: 'test.com',
- title: 'Test',
- image: 'test.com',
- impressionTrackers: ['test.com'],
- },
- ttl: 120,
- cpm: 0.4,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const nativeResponses = spec.interpretResponse(native);
- expect(nativeResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = nativeResponses[0];
- expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta');
- expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image')
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.4);
- expect(dataItem.native.clickUrl).to.equal('test.com');
- expect(dataItem.native.title).to.equal('Test');
- expect(dataItem.native.image).to.equal('test.com');
- expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty;
- expect(dataItem.native.impressionTrackers[0]).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should return an empty array if invalid banner response is passed', function () {
- const invBanner = {
- body: [{
- width: 300,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
-
- const serverResponses = spec.interpretResponse(invBanner);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid video response is passed', function () {
- const invVideo = {
- body: [{
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invVideo);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid native response is passed', function () {
- const invNative = {
- body: [{
- mediaType: 'native',
- clickUrl: 'test.com',
- title: 'Test',
- impressionTrackers: ['test.com'],
- ttl: 120,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- }]
- };
- const serverResponses = spec.interpretResponse(invNative);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid response is passed', function () {
- const invalid = {
- body: [{
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invalid);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- });
-
- describe('getUserSyncs', function() {
- it('Should return array of objects with proper sync config , include GDPR', function() {
- const syncData = spec.getUserSyncs({}, {}, {
- consentString: 'ALL',
- gdprApplies: true,
- }, {});
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://sync.videowalldirect.com/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0')
- });
- it('Should return array of objects with proper sync config , include CCPA', function() {
- const syncData = spec.getUserSyncs({}, {}, {}, {
- consentString: '1---'
- });
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://sync.videowalldirect.com/image?pbjs=1&ccpa_consent=1---&coppa=0')
- });
- it('Should return array of objects with proper sync config , include GPP', function() {
- const syncData = spec.getUserSyncs({}, {}, {}, {}, {
- gppString: 'abc123',
- applicableSections: [8]
- });
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://sync.videowalldirect.com/image?pbjs=1&gpp=abc123&gpp_sid=8&coppa=0')
- });
- });
-});
diff --git a/test/spec/modules/brainxBidAdapter_spec.js b/test/spec/modules/brainxBidAdapter_spec.js
deleted file mode 100644
index baa7152fc..000000000
--- a/test/spec/modules/brainxBidAdapter_spec.js
+++ /dev/null
@@ -1,132 +0,0 @@
-// import or require modules necessary for the test, e.g.:
-import { expect } from 'chai'; // may prefer 'assert' in place of 'expect'
-import { spec } from 'modules/brainxBidAdapter.js';
-import utils, { deepClone } from '../../../src/utils.js';
-// import adapter from 'src/adapters/';
-import { BANNER, NATIVE, VIDEO } from 'src/mediaTypes.js';
-
-describe('Brain-X Aapater', function () {
- describe('isBidRequestValid', function () {
- it('undefined bid should return false', function () {
- expect(spec.isBidRequestValid()).to.be.false;
- });
-
- it('null bid should return false', function () {
- expect(spec.isBidRequestValid(null)).to.be.false;
- });
-
- it('bid.params should be set', function () {
- expect(spec.isBidRequestValid({})).to.be.false;
- });
-
- it('bid.params.pubId should be set', function () {
- expect(spec.isBidRequestValid({
- params: { pubId: 'F7B53DBC-85C1-4685-9A06-9CF4B6261FA3', endpoint: 'http://adx-engine-gray.tec-do.cn/bid' }
- })).to.be.false;
- });
- })
-
- // describe('isBidRequestValid', function () {
- // it('Test the banner request processing function', function () {
- // const request = spec.buildRequests(bannerRequest, bannerRequest[0]);
- // expect(request).to.not.be.empty;
- // const payload = request.data;
- // expect(payload).to.not.be.empty;
- // });
- // it('Test the video request processing function', function () {
- // const request = spec.buildRequests(videoRequest, videoRequest[0]);
- // expect(request).to.not.be.empty;
- // const payload = request.data;
- // expect(payload).to.not.be.empty;
- // });
- // it('Test the param', function () {
- // const request = spec.buildRequests(bannerRequest, bannerRequest[0]);
- // const payload = JSON.parse(request.data);
- // expect(payload.imp[0].tagid).to.eql(videoRequest[0].params.tagid);
- // expect(payload.imp[0].bidfloor).to.eql(videoRequest[0].params.bidfloor);
- // });
- // })
-
- describe('interpretResponse', function () {
- it('Test banner interpretResponse', function () {
- const serverResponse = {
- body: {
- 'bidid': 'a82042c055b04e539ec6876112c10ced1729663902983',
- 'cur': 'USD',
- 'id': '28f8f1f525372a',
- 'seatbid': [
- {
- 'bid': [
- {
- 'adid': '76797',
- 'adm': "\n

\n
\n\n

\n \n
\n
\n\n",
- 'adomain': [
- 'taobao.com'
- ],
- 'bundle': 'com.taobao',
- 'burl': 'https://adx-event-server.bidtrail.top/billing?s=Eid0ZWMxNDk4NDQzODk3MjcwOTU1MzAwNzM3YjczMTQwMTA4ODk5ODQaDjI4ZjhmMWY1MjUzNzJhIKkCKgbmtYvor5U6DmxvY2FsaG9zdDo5OTk5Qgl1bmRlZmluZWRKA0hLR1ADYAFoAXADeAOAAQKKAQpjb20udGFvYmFvlQEX2U49nQEX2U49pQEX2U49ugEqCO4HEiUI7gcSCFRlY2RvRFNQGA01F9lOPTgBQBVKC1RlY2RvRFNQX1NHwAHuB8gBjcqCwKsy0AEC-gGbAmh0dHBzOi8vbm90aWNlLXNnLmJpZHRyYWlsLnRvcC93aW4_YmlkX2lkPWE4MjA0MmMwNTViMDRlNTM5ZWM2ODc2MTEyYzEwY2VkMTcyOTY2MzkwMjk4MyZjYW1wYWlnbl9pZD00MjgmYWRfZ3JvdXBfaWQ9OTc2MSZhZF9pZD03Njc5NyZjcmVhdGl2ZV9pZD02NTI2JmFmZmlsaWF0ZV9pZD0yOTcmYnVuZGxlPSZmaXJzdF9zc3A9YnJhaW54LnRlY2gmcHVibGlzaF9pZD0mb3M9QW5kcm9pZCZ0YWdfaWQ9dW5kZWZpbmVkJmJpZF9zdWNjZXNzX3ByaWNlPTAuMDUwNSZzaWduPWUzODQyNjhiYzAzYzhmYmOSAgp0YW9iYW8uY29togILYnJhaW54LnRlY2ioAgGyAgdhbmRyb2lkwAICygICc2fQAgHYAo3hlcWrMuACjeGVxasy&v=P-1b7JJWs-uUQ68A37V4xDLplU0&auction_price=${AUCTION_PRICE}',
- 'cat': [
- 'IAB18-5'
- ],
- 'cid': '428',
- 'crid': 'D06g1RVGMEnC+9Le4SZMJw==',
- 'h': 480,
- 'id': 'a82042c055b04e539ec6876112c10ced1729663902983',
- 'impid': '3c1dd9e1700358',
- 'iurl': 'https://creative.bidtrail.top/png/2/20f24c10f21e/091b422e3014033e57acffcf2a5c71dbb17383ec15ac9421',
- 'lurl': 'https://notice-sg.bidtrail.top/loss?bid_id=a82042c055b04e539ec6876112c10ced1729663902983&sign=e384268bc03c8fbc&campaign_id=428&ad_group_id=9761&ad_id=76797&creative_id=6526&affiliate_id=297&loss_code=${AUCTION_LOSS}',
- 'nurl': 'https://adx-event-server.bidtrail.top/winnotice?s=Eid0ZWMxNDk4NDQzODk3MjcwOTU1MzAwNzM3YjczMTQwMTA4ODk5ODQaDjI4ZjhmMWY1MjUzNzJhIKkCKgbmtYvor5U6DmxvY2FsaG9zdDo5OTk5Qgl1bmRlZmluZWRKA0hLR1ADYAFoAXADeAOAAQKKAQpjb20udGFvYmFvlQEX2U49nQEX2U49pQEX2U49ugEqCO4HEiUI7gcSCFRlY2RvRFNQGA01F9lOPTgBQBVKC1RlY2RvRFNQX1NHwAHuB8gBjcqCwKsy0AEB-gGbAmh0dHBzOi8vbm90aWNlLXNnLmJpZHRyYWlsLnRvcC93aW4_YmlkX2lkPWE4MjA0MmMwNTViMDRlNTM5ZWM2ODc2MTEyYzEwY2VkMTcyOTY2MzkwMjk4MyZjYW1wYWlnbl9pZD00MjgmYWRfZ3JvdXBfaWQ9OTc2MSZhZF9pZD03Njc5NyZjcmVhdGl2ZV9pZD02NTI2JmFmZmlsaWF0ZV9pZD0yOTcmYnVuZGxlPSZmaXJzdF9zc3A9YnJhaW54LnRlY2gmcHVibGlzaF9pZD0mb3M9QW5kcm9pZCZ0YWdfaWQ9dW5kZWZpbmVkJmJpZF9zdWNjZXNzX3ByaWNlPTAuMDUwNSZzaWduPWUzODQyNjhiYzAzYzhmYmOSAgp0YW9iYW8uY29togILYnJhaW54LnRlY2ioAgGyAgdhbmRyb2lkwAICygICc2fQAgHYAo3hlcWrMuACjeGVxasy&v=jFUg_b6F14d50JL-M6UE5Jc8VuA&auction_price=${AUCTION_PRICE}',
- 'price': 0.0505,
- 'w': 320
- }
- ],
- 'group': 0,
- 'seat': 'agency'
- }
- ]
- }
- };
-
- const bidResponses = spec.interpretResponse(serverResponse, {
- originalBidRequest: {
- auctionId: '3eedbf83-7d1d-423c-be27-39e4af687040',
- auctionStart: 1729663900819,
- adUnitCode: 'dev-1',
- bidId: '28f8f1f525372a',
- bidder: 'brainx',
- mediaTypes: { banner: { sizes: [[300, 250]] } },
- params: {
- pubId: 'F7B53DBC-85C1-4685-9A06-9CF4B6261FA3',
- endpoint: 'http://adx-engine-gray.tec-do.cn/bid'
- },
- src: 'client'
- }
- });
-
- expect(bidResponses).to.be.an('array').that.is.not.empty;
-
- const bid = serverResponse.body.seatbid[0].bid[0];
- const bidResponse = bidResponses[0];
-
- expect(bidResponse.mediaType).to.equal(BANNER);
- expect(bidResponse.requestId).to.equal(bid.impid);
- expect(bidResponse.cpm).to.equal(parseFloat(bid.price).toFixed(2))
- expect(bidResponse.currency).to.equal(serverResponse.body.cur);
- expect(bidResponse.creativeId).to.equal(bid.crid || bid.id);
- expect(bidResponse.netRevenue).to.be.true;
- expect(bidResponse.nurl).to.equal(bid.nurl);
- expect(bidResponse.lurl).to.equal(bid.lurl);
-
- expect(bidResponse.meta).to.be.an('object');
- expect(bidResponse.meta.mediaType).to.equal(BANNER);
- expect(bidResponse.meta.primaryCatId).to.equal('IAB18-5');
- // expect(bidResponse.meta.secondaryCatIds).to.deep.equal(['IAB8']);
- expect(bidResponse.meta.advertiserDomains).to.deep.equal(bid.adomain);
- expect(bidResponse.meta.clickUrl).to.equal(bid.adomain[0]);
-
- expect(bidResponse.ad).to.equal(bid.adm);
- expect(bidResponse.width).to.equal(bid.w);
- expect(bidResponse.height).to.equal(bid.h);
- });
- });
-});
diff --git a/test/spec/modules/brandmetricsRtdProvider_spec.js b/test/spec/modules/brandmetricsRtdProvider_spec.js
deleted file mode 100644
index 6bc521b21..000000000
--- a/test/spec/modules/brandmetricsRtdProvider_spec.js
+++ /dev/null
@@ -1,259 +0,0 @@
-import * as brandmetricsRTD from '../../../modules/brandmetricsRtdProvider.js';
-import {config} from 'src/config.js';
-import * as events from '../../../src/events.js';
-import * as sinon from 'sinon';
-
-const VALID_CONFIG = {
- name: 'brandmetrics',
- waitForIt: true,
- params: {
- scriptId: '00000000-0000-0000-0000-000000000000',
- bidders: ['ozone']
- }
-};
-
-const NO_BIDDERS_CONFIG = {
- name: 'brandmetrics',
- waitForIt: true,
- params: {
- scriptId: '00000000-0000-0000-0000-000000000000'
- }
-};
-
-const NO_SCRIPTID_CONFIG = {
- name: 'brandmetrics',
- waitForIt: true
-};
-
-const USER_CONSENT = {
- gdpr: {
- vendorData: {
- vendor: {
- consents: {
- 422: true
- }
- },
- purpose: {
- consents: {
- 1: true,
- 7: true
- }
- }
- },
- gdprApplies: true
- }
-};
-
-const NO_TCF_CONSENT = {
- gdpr: {
- vendorData: {
- vendor: {
- consents: {
- 422: false
- }
- },
- purpose: {
- consents: {
- 1: false,
- 7: false
- }
- }
- },
- gdprApplies: true
- }
-};
-
-const NO_USP_CONSENT = {
- usp: '1NYY'
-};
-
-const UNDEFINED_USER_CONSENT = {};
-
-function mockSurveyLoaded(surveyConf) {
- const commands = window._brandmetrics || [];
- commands.forEach(command => {
- if (command.cmd === '_addeventlistener') {
- const conf = command.val;
- if (conf.event === 'surveyloaded') {
- conf.handler(surveyConf);
- }
- }
- });
-}
-
-function mockCreativeInView(creativeInViewConf) {
- const commands = window._brandmetrics || [];
- commands.forEach(command => {
- if (command.cmd === '_addeventlistener') {
- const conf = command.val;
- if (conf.event === 'creative_in_view') {
- conf.handler(creativeInViewConf);
- }
- }
- })
-}
-
-describe('BrandmetricsRTD module', () => {
- beforeEach(function () {
- const scriptTags = document.getElementsByTagName('script');
- for (let i = 0; i < scriptTags.length; i++) {
- if (scriptTags[i].src.indexOf('brandmetrics') !== -1) {
- scriptTags[i].remove();
- }
- }
- });
-
- it('should init and return true', () => {
- expect(brandmetricsRTD.brandmetricsSubmodule.init(VALID_CONFIG, USER_CONSENT)).to.equal(true);
- });
-
- it('should init and return true even if bidders is not included', () => {
- expect(brandmetricsRTD.brandmetricsSubmodule.init(NO_BIDDERS_CONFIG, USER_CONSENT)).to.equal(true);
- });
-
- it('should init even if script- id is not configured', () => {
- expect(brandmetricsRTD.brandmetricsSubmodule.init(NO_SCRIPTID_CONFIG, USER_CONSENT)).to.equal(true);
- });
-
- it('should not init when there is no TCF- consent', () => {
- expect(brandmetricsRTD.brandmetricsSubmodule.init(VALID_CONFIG, NO_TCF_CONSENT)).to.equal(false);
- });
-
- it('should not init when there is no usp- consent', () => {
- expect(brandmetricsRTD.brandmetricsSubmodule.init(VALID_CONFIG, NO_USP_CONSENT)).to.equal(false);
- });
-
- it('should init if there are no consent- objects defined', () => {
- expect(brandmetricsRTD.brandmetricsSubmodule.init(VALID_CONFIG, UNDEFINED_USER_CONSENT)).to.equal(true);
- });
-});
-
-describe('getBidRequestData', () => {
- beforeEach(function () {
- config.resetConfig()
- })
-
- it('should set targeting keys for specified bidders', () => {
- const bidderOrtb2 = {};
- brandmetricsRTD.brandmetricsSubmodule.getBidRequestData({ortb2Fragments: {bidder: bidderOrtb2}}, () => {
- const expected = VALID_CONFIG.params.bidders
-
- expected.forEach(exp => {
- expect(bidderOrtb2[exp].user.ext.data.mockTargetKey).to.equal('mockMeasurementId')
- })
- }, VALID_CONFIG);
-
- mockSurveyLoaded({
- available: true,
- conf: {
- displayOption: {
- type: 'pbjs',
- targetKey: 'mockTargetKey'
- }
- },
- survey: {
- measurementId: 'mockMeasurementId'
- }
- });
- });
-
- it('should only set targeting keys when the brandmetrics survey- type is "pbjs"', () => {
- mockSurveyLoaded({
- available: true,
- conf: {
- displayOption: {
- type: 'dfp',
- targetKey: 'mockTargetKey'
- }
- },
- survey: {
- measurementId: 'mockMeasurementId'
- }
- });
-
- const bidderOrtb2 = {};
- brandmetricsRTD.brandmetricsSubmodule.getBidRequestData({ortb2Fragments: {bidder: bidderOrtb2}}, () => {}, VALID_CONFIG);
- expect(Object.keys(bidderOrtb2).length).to.equal(0)
- });
-
- it('should use a default targeting key name if the brandmetrics- configuration does not include one', () => {
- mockSurveyLoaded({
- available: true,
- conf: {
- displayOption: {
- type: 'pbjs',
- }
- },
- survey: {
- measurementId: 'mockMeasurementId'
- }
- });
-
- const bidderOrtb2 = {};
- brandmetricsRTD.brandmetricsSubmodule.getBidRequestData({ortb2Fragments: {bidder: bidderOrtb2}}, () => {}, VALID_CONFIG);
-
- const expected = VALID_CONFIG.params.bidders
-
- expected.forEach(exp => {
- expect(bidderOrtb2[exp].user.ext.data.brandmetrics_survey).to.equal('mockMeasurementId')
- })
- });
-
- describe('billable events', () => {
- let sandbox;
- let eventsEmitSpy;
-
- before(() => {
- sandbox = sinon.createSandbox();
- eventsEmitSpy = sandbox.spy(events, ['emit']);
- });
-
- beforeEach(() => {
- eventsEmitSpy.resetHistory();
- })
-
- afterEach(() => {
- sandbox.restore();
- });
-
- it('should emit billable event from prebid events', () => {
- const expectedEvent = {
- vendor: 'brandmetrics',
- type: 'creative_in_view',
- measurementId: 'mockMeasurementId',
- auctionId: 'mockAuctionId',
- transactionId: 'mockTransactionId'
- };
-
- mockCreativeInView({
- mid: expectedEvent.measurementId,
- source: {
- type: 'pbj',
- data: {
- auctionId: expectedEvent.auctionId,
- transactionId: expectedEvent.transactionId
- },
- }
- });
-
- expect(eventsEmitSpy.callCount).to.equal(1);
-
- const event = eventsEmitSpy.getCalls()[0].args[1];
- delete event['billingId'];
-
- expect(event).to.deep.equal(expectedEvent);
- });
-
- it('should not emit billable event from non prebid- sources', () => {
- mockCreativeInView({
- mid: 'mockMeasurementId',
- source: {
- type: 'gpt',
- data: {},
- }
- });
-
- expect(eventsEmitSpy.callCount).to.equal(0);
- });
- });
-});
diff --git a/test/spec/modules/braveBidAdapter_spec.js b/test/spec/modules/braveBidAdapter_spec.js
deleted file mode 100644
index 92a235a92..000000000
--- a/test/spec/modules/braveBidAdapter_spec.js
+++ /dev/null
@@ -1,363 +0,0 @@
-import { expect } from 'chai';
-import { spec } from 'modules/braveBidAdapter.js';
-
-const request_native = {
- code: 'brave-native-prebid',
- mediaTypes: {
- native: {
- title: {
- required: true,
- len: 800
- },
- image: {
- required: true,
- len: 80
- },
- sponsoredBy: {
- required: true
- },
- clickUrl: {
- required: true
- },
- privacyLink: {
- required: false
- },
- body: {
- required: true
- },
- icon: {
- required: true,
- sizes: [50, 50]
- }
- }
- },
- bidder: 'brave',
- params: {
- placementId: 'to0QI2aPgkbBZq6vgf0oHitouZduz0qw'
- }
-};
-
-const request_banner = {
- code: 'brave-prebid',
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
- },
- bidder: 'brave',
- params: {
- placementId: 'to0QI2aPgkbBZq6vgf0oHitouZduz0qw'
- }
-}
-
-const bidRequest = {
- gdprConsent: {
- consentString: 'HFIDUYFIUYIUYWIPOI87392DSU',
- gdprApplies: true
- },
- uspConsent: 'uspConsentString',
- bidderRequestId: 'testid',
- refererInfo: {
- referer: 'testdomain.com'
- },
- timeout: 700
-}
-
-const request_video = {
- code: 'brave-video-prebid',
- mediaTypes: { video: {
- minduration: 1,
- maxduration: 999,
- boxingallowed: 1,
- skip: 0,
- mimes: [
- 'application/javascript',
- 'video/mp4'
- ],
- playerSize: [[768, 1024]],
- protocols: [
- 2, 3
- ],
- linearity: 1,
- api: [
- 1,
- 2
- ]
- }
- },
-
- bidder: 'brave',
- params: {
- placementId: 'to0QI2aPgkbBZq6vgf0oHitouZduz0qw'
- }
-
-}
-
-const response_banner = {
- id: 'request_id',
- bidid: 'request_imp_id',
- seatbid: [{
- bid: [{
- id: 'bid_id',
- impid: 'request_imp_id',
- price: 5,
- adomain: ['example.com'],
- adm: 'admcode',
- crid: 'crid',
- ext: {
- mediaType: 'banner'
- }
- }]
- }]
-};
-
-const response_video = {
- id: 'request_id',
- bidid: 'request_imp_id',
- seatbid: [{
- bid: [{
- id: 'bid_id',
- impid: 'request_imp_id',
- price: 5,
- adomain: ['example.com'],
- adm: 'admcode',
- crid: 'crid',
- ext: {
- mediaType: 'video'
- }
- }],
- }],
-};
-
-const imgData = {
- url: `https://example.com/image`,
- w: 1200,
- h: 627
-};
-
-const response_native = {
- id: 'request_id',
- bidid: 'request_imp_id',
- seatbid: [{
- bid: [{
- id: 'bid_id',
- impid: 'request_imp_id',
- price: 5,
- adomain: ['example.com'],
- adm: { native:
- {
- assets: [
- {id: 1, title: 'dummyText'},
- {id: 3, image: imgData},
- {
- id: 5,
- data: {value: 'organization.name'}
- }
- ],
- link: {url: 'example.com'},
- imptrackers: ['tracker1.com', 'tracker2.com', 'tracker3.com'],
- jstracker: 'tracker1.com'
- }
- },
- crid: 'crid',
- ext: {
- mediaType: 'native'
- }
- }],
- }],
-};
-
-describe('BraveBidAdapter', function() {
- describe('isBidRequestValid', function() {
- it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(request_banner)).to.equal(true);
- });
-
- it('should return false when required params are not passed', function () {
- const bid = Object.assign({}, request_banner);
- bid.params = {
- 'IncorrectParam': 0
- };
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
- });
-
- describe('build Native Request', function () {
- const request = spec.buildRequests([request_native], bidRequest);
-
- it('Creates a ServerRequest object with method, URL and data', function () {
- expect(request).to.exist;
- expect(request.method).to.exist;
- expect(request.url).to.exist;
- expect(request.data).to.exist;
- });
-
- it('sends bid request to our endpoint via POST', function () {
- expect(request.method).to.equal('POST');
- });
-
- it('Returns valid URL', function () {
- expect(request.url).to.equal('https://point.braveglobal.tv/?t=2&partner=to0QI2aPgkbBZq6vgf0oHitouZduz0qw');
- });
-
- it('Returns empty data if no valid requests are passed', function () {
- const serverRequest = spec.buildRequests([]);
- expect(serverRequest).to.be.an('array').that.is.empty;
- });
- });
-
- describe('build Banner Request', function () {
- const request = spec.buildRequests([request_banner], bidRequest);
-
- it('Creates a ServerRequest object with method, URL and data', function () {
- expect(request).to.exist;
- expect(request.method).to.exist;
- expect(request.url).to.exist;
- expect(request.data).to.exist;
- });
-
- it('sends bid request to our endpoint via POST', function () {
- expect(request.method).to.equal('POST');
- });
-
- it('Returns valid URL', function () {
- expect(request.url).to.equal('https://point.braveglobal.tv/?t=2&partner=to0QI2aPgkbBZq6vgf0oHitouZduz0qw');
- });
- });
-
- describe('build Video Request', function () {
- const request = spec.buildRequests([request_video], bidRequest);
-
- it('Creates a ServerRequest object with method, URL and data', function () {
- expect(request).to.exist;
- expect(request.method).to.exist;
- expect(request.url).to.exist;
- expect(request.data).to.exist;
- });
-
- it('sends bid request to our endpoint via POST', function () {
- expect(request.method).to.equal('POST');
- });
-
- it('Returns valid URL', function () {
- expect(request.url).to.equal('https://point.braveglobal.tv/?t=2&partner=to0QI2aPgkbBZq6vgf0oHitouZduz0qw');
- });
- });
-
- describe('interpretResponse', function () {
- it('Empty response must return empty array', function() {
- const emptyResponse = null;
- const response = spec.interpretResponse(emptyResponse);
-
- expect(response).to.be.an('array').that.is.empty;
- })
-
- it('Should interpret banner response', function () {
- const bannerResponse = {
- body: response_banner
- }
-
- const expectedBidResponse = {
- requestId: response_banner.seatbid[0].bid[0].impid,
- cpm: response_banner.seatbid[0].bid[0].price,
- width: response_banner.seatbid[0].bid[0].w,
- height: response_banner.seatbid[0].bid[0].h,
- ttl: response_banner.ttl || 1200,
- currency: response_banner.cur || 'USD',
- netRevenue: true,
- creativeId: response_banner.seatbid[0].bid[0].crid,
- dealId: response_banner.seatbid[0].bid[0].dealid,
- mediaType: 'banner',
- ad: response_banner.seatbid[0].bid[0].adm
- }
-
- const bannerResponses = spec.interpretResponse(bannerResponse);
-
- expect(bannerResponses).to.be.an('array').that.is.not.empty;
- const dataItem = bannerResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType');
- expect(dataItem.requestId).to.equal(expectedBidResponse.requestId);
- expect(dataItem.cpm).to.equal(expectedBidResponse.cpm);
- expect(dataItem.ad).to.equal(expectedBidResponse.ad);
- expect(dataItem.ttl).to.equal(expectedBidResponse.ttl);
- expect(dataItem.creativeId).to.equal(expectedBidResponse.creativeId);
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal(expectedBidResponse.currency);
- expect(dataItem.width).to.equal(expectedBidResponse.width);
- expect(dataItem.height).to.equal(expectedBidResponse.height);
- });
-
- it('Should interpret video response', function () {
- const videoResponse = {
- body: response_video
- }
-
- const expectedBidResponse = {
- requestId: response_video.seatbid[0].bid[0].impid,
- cpm: response_video.seatbid[0].bid[0].price,
- width: response_video.seatbid[0].bid[0].w,
- height: response_video.seatbid[0].bid[0].h,
- ttl: response_video.ttl || 1200,
- currency: response_video.cur || 'USD',
- netRevenue: true,
- creativeId: response_video.seatbid[0].bid[0].crid,
- dealId: response_video.seatbid[0].bid[0].dealid,
- mediaType: 'video',
- vastXml: response_video.seatbid[0].bid[0].adm
- }
-
- const videoResponses = spec.interpretResponse(videoResponse);
-
- expect(videoResponses).to.be.an('array').that.is.not.empty;
- const dataItem = videoResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'vastXml', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType');
- expect(dataItem.requestId).to.equal(expectedBidResponse.requestId);
- expect(dataItem.cpm).to.equal(expectedBidResponse.cpm);
- expect(dataItem.vastXml).to.equal(expectedBidResponse.vastXml)
- expect(dataItem.ttl).to.equal(expectedBidResponse.ttl);
- expect(dataItem.creativeId).to.equal(expectedBidResponse.creativeId);
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal(expectedBidResponse.currency);
- expect(dataItem.width).to.equal(expectedBidResponse.width);
- expect(dataItem.height).to.equal(expectedBidResponse.height);
- });
-
- it('Should interpret native response', function () {
- const nativeResponse = {
- body: response_native
- }
-
- const expectedBidResponse = {
- requestId: response_native.seatbid[0].bid[0].impid,
- cpm: response_native.seatbid[0].bid[0].price,
- width: response_native.seatbid[0].bid[0].w,
- height: response_native.seatbid[0].bid[0].h,
- ttl: response_native.ttl || 1200,
- currency: response_native.cur || 'USD',
- netRevenue: true,
- creativeId: response_native.seatbid[0].bid[0].crid,
- dealId: response_native.seatbid[0].bid[0].dealid,
- mediaType: 'native',
- native: {clickUrl: response_native.seatbid[0].bid[0].adm.native.link.url}
- }
-
- const nativeResponses = spec.interpretResponse(nativeResponse);
-
- expect(nativeResponses).to.be.an('array').that.is.not.empty;
- const dataItem = nativeResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'native', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType');
- expect(dataItem.requestId).to.equal(expectedBidResponse.requestId);
- expect(dataItem.cpm).to.equal(expectedBidResponse.cpm);
- expect(dataItem.native.clickUrl).to.equal(expectedBidResponse.native.clickUrl)
- expect(dataItem.ttl).to.equal(expectedBidResponse.ttl);
- expect(dataItem.creativeId).to.equal(expectedBidResponse.creativeId);
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal(expectedBidResponse.currency);
- expect(dataItem.width).to.equal(expectedBidResponse.width);
- expect(dataItem.height).to.equal(expectedBidResponse.height);
- });
- });
-})
diff --git a/test/spec/modules/bridBidAdapter_spec.js b/test/spec/modules/bridBidAdapter_spec.js
deleted file mode 100644
index 4819f8174..000000000
--- a/test/spec/modules/bridBidAdapter_spec.js
+++ /dev/null
@@ -1,173 +0,0 @@
-import { spec } from '../../../modules/bridBidAdapter.js'
-import { SYNC_URL } from '../../../libraries/targetVideoUtils/constants.js';
-import { deepClone } from '../../../src/utils.js';
-
-describe('Brid Bid Adapter', function() {
- const videoRequest = [{
- bidder: 'brid',
- params: {
- placementId: 12345,
- },
- mediaTypes: {
- video: {
- playerSize: [[640, 360]],
- context: 'instream',
- playbackmethod: [1, 2, 3, 4]
- }
- }
- }];
-
- it('Test the bid validation function', function() {
- const validBid = spec.isBidRequestValid(videoRequest[0]);
- const invalidBid = spec.isBidRequestValid(null);
-
- expect(validBid).to.be.true;
- expect(invalidBid).to.be.false;
- });
-
- it('Test the request processing function', function () {
- const request = spec.buildRequests(videoRequest, videoRequest[0]);
- expect(request).to.not.be.empty;
-
- const payload = JSON.parse(request[0].data);
- expect(payload).to.not.be.empty;
- expect(payload.sdk).to.deep.equal({
- source: 'pbjs',
- version: '$prebid.version$'
- });
- expect(payload.imp[0].ext.prebid.storedrequest.id).to.equal(12345);
- });
-
- it('Test the request schain sending', function() {
- const globalSchain = {
- ver: '1.0',
- complete: 1,
- nodes: [{
- asi: 'examplewebsite.com',
- sid: '00001',
- hp: 1
- }]
- };
-
- const videoRequestCloned = deepClone(videoRequest);
- videoRequestCloned[0].ortb2 = { source: { ext: { schain: globalSchain } } };
-
- const request = spec.buildRequests(videoRequestCloned, videoRequestCloned[0]);
- expect(request).to.not.be.empty;
-
- const payload = JSON.parse(request[0].data);
- expect(payload).to.not.be.empty;
- expect(payload.source.ext.schain).to.exist;
- expect(payload.source.ext.schain).to.deep.equal(globalSchain);
- });
-
- it('Test nobid responses', function () {
- const responseBody = {
- 'id': 'test-id',
- 'cur': 'USD',
- 'seatbid': [],
- 'nbr': 0
- };
- const bidderRequest = null;
-
- const bidResponse = spec.interpretResponse({ body: responseBody }, {bidderRequest});
-
- expect(bidResponse.length).to.equal(0);
- });
-
- it('Test the response parsing function', function () {
- const responseBody = {
- 'id': 'test-id',
- 'cur': 'USD',
- 'seatbid': [{
- 'bid': [{
- 'id': '5044997188309660254',
- 'price': 5,
- 'adm': 'test ad',
- 'adid': '97517771',
- 'crid': '97517771',
- 'adomain': ['domain.com'],
- 'w': 640,
- 'h': 480
- }],
- 'seat': 'bidder'
- }]
- };
- const bidderRequest = {
- bidderCode: 'brid',
- bidderRequestId: '22edbae2733bf6',
- bids: videoRequest
- };
-
- const bidResponse = spec.interpretResponse({ body: responseBody }, {bidderRequest});
- expect(bidResponse).to.not.be.empty;
-
- const bid = bidResponse[0];
- expect(bid).to.not.be.empty;
- expect(bid.ad).to.equal('test ad');
- expect(bid.cpm).to.equal(5);
- expect(bid.width).to.equal(640);
- expect(bid.height).to.equal(480);
- expect(bid.currency).to.equal('USD');
- });
-
- it('Test GDPR and USP consents are present in the request', function () {
- const gdprConsentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==';
- const uspConsentString = '1YA-';
- const bidderRequest = {
- 'bidderCode': 'brid',
- 'bidderRequestId': '22edbae2733bf6',
- 'timeout': 3000,
- 'uspConsent': uspConsentString,
- 'gdprConsent': {
- consentString: gdprConsentString,
- gdprApplies: true,
- addtlConsent: '1~7.12.35.62.66.70.89.93.108'
- }
- };
- bidderRequest.bids = videoRequest;
-
- const request = spec.buildRequests(videoRequest, bidderRequest);
- const payload = JSON.parse(request[0].data);
-
- expect(payload.user.ext.consent).to.equal(gdprConsentString);
- expect(payload.regs.ext.us_privacy).to.equal(uspConsentString);
- expect(payload.regs.ext.gdpr).to.equal(1);
- });
-
- it('Test GDPR is not present', function () {
- const uspConsentString = '1YA-';
- const bidderRequest = {
- 'bidderCode': 'brid',
- 'bidderRequestId': '22edbae2733bf6',
- 'timeout': 3000,
- 'uspConsent': uspConsentString
- };
- bidderRequest.bids = videoRequest;
-
- const request = spec.buildRequests(videoRequest, bidderRequest);
- const payload = JSON.parse(request[0].data);
-
- expect(payload.regs.ext.gdpr).to.be.undefined;
- expect(payload.regs.ext.us_privacy).to.equal(uspConsentString);
- });
-
- it('Test userSync have only one object and it should have a property type=iframe', function () {
- const userSync = spec.getUserSyncs({ iframeEnabled: true });
- expect(userSync).to.be.an('array');
- expect(userSync.length).to.be.equal(1);
- expect(userSync[0]).to.have.property('type');
- expect(userSync[0].type).to.be.equal('iframe');
- });
-
- it('Test userSync valid sync url for iframe', function () {
- const [userSync] = spec.getUserSyncs({ iframeEnabled: true }, {}, {consentString: 'anyString'});
- expect(userSync.url).to.contain(SYNC_URL + 'load-cookie.html?endpoint=brid&gdpr=0&gdpr_consent=anyString');
- expect(userSync.type).to.be.equal('iframe');
- });
-
- it('Test userSyncs iframeEnabled=false', function () {
- const userSyncs = spec.getUserSyncs({iframeEnabled: false});
- expect(userSyncs).to.have.lengthOf(0);
- });
-});
diff --git a/test/spec/modules/bridgewellBidAdapter_spec.js b/test/spec/modules/bridgewellBidAdapter_spec.js
deleted file mode 100644
index 3802d9761..000000000
--- a/test/spec/modules/bridgewellBidAdapter_spec.js
+++ /dev/null
@@ -1,1344 +0,0 @@
-import { expect } from 'chai';
-import { spec } from 'modules/bridgewellBidAdapter.js';
-import { newBidder } from 'src/adapters/bidderFactory.js';
-
-const userId = {
- 'criteoId': 'vYlICF9oREZlTHBGRVdrJTJCUUJnc3U2ckNVaXhrV1JWVUZVSUxzZmJlcnJZR0ZxbVhFRnU5bDAlMkJaUWwxWTlNcmdEeHFrJTJGajBWVlV4T3lFQ0FyRVcxNyUyQlIxa0lLSlFhcWJpTm9PSkdPVkx0JTJCbzlQRTQlM0Q',
- 'pubcid': '074864cb-3705-430e-9ff7-48ccf3c21b94',
- 'sharedid': {'id': '01F61MX53D786DSB2WYD38ZVM7', 'third': '01F61MX53D786DSB2WYD38ZVM7'},
- 'uid2': {'id': 'eb33b0cb-8d35-1234-b9c0-1a31d4064777'},
-}
-const userIdAsEids = [{
- source: 'test.org',
- uids: [{
- id: '01**********',
- atype: 1,
- ext: {
- third: '01***********'
- }
- }]
-}];
-
-describe('bridgewellBidAdapter', function () {
- const adapter = newBidder(spec);
-
- describe('inherited functions', function () {
- it('exists and is a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('isBidRequestValid', function () {
- it('should return true when required params found', function () {
- const validTag = {
- 'bidder': 'bridgewell',
- 'params': {
- 'ChannelID': 'CLJgEAYYvxUiBXBlbm55KgkIrAIQ-gEaATk'
- },
- };
- expect(spec.isBidRequestValid(validTag)).to.equal(true);
- });
-
- it('should return true when required params found', function () {
- const validTag = {
- 'bidder': 'bridgewell',
- 'params': {
- 'cid': 1234
- },
- };
- expect(spec.isBidRequestValid(validTag)).to.equal(true);
- });
-
- it('should return false when required params not found', function () {
- const invalidTag = {
- 'bidder': 'bridgewell',
- 'params': {},
- };
- expect(spec.isBidRequestValid(invalidTag)).to.equal(false);
- });
-
- it('should return false when required params are empty', function () {
- const invalidTag = {
- 'bidder': 'bridgewell',
- 'params': {
- 'ChannelID': '',
- },
- };
- expect(spec.isBidRequestValid(invalidTag)).to.equal(false);
- });
-
- it('should return false when required params are empty', function () {
- const invalidTag = {
- 'bidder': 'bridgewell',
- 'params': {
- 'cid': '',
- },
- };
- expect(spec.isBidRequestValid(invalidTag)).to.equal(false);
- });
-
- it('should return false when required param cid is not a number', function () {
- const invalidTag = {
- 'bidder': 'bridgewell',
- 'params': {
- 'cid': 'bad_cid',
- },
- };
- expect(spec.isBidRequestValid(invalidTag)).to.equal(false);
- });
- });
-
- describe('buildRequests', function () {
- const bidRequests = [
- {
- 'bidder': 'bridgewell',
- 'params': {
- 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ',
- },
- 'adUnitCode': 'adunit-code-2',
- 'mediaTypes': {
- 'banner': {
- 'sizes': [728, 90]
- }
- },
- 'bidId': '3150ccb55da321',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- 'userId': userId,
- 'userIdAsEids': userIdAsEids,
- },
- {
- 'bidder': 'bridgewell',
- 'params': {
- 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ',
- },
- 'adUnitCode': 'adunit-code-2',
- 'sizes': [1, 1],
- 'mediaTypes': {
- 'native': {
- 'title': {
- 'required': true,
- 'len': 15
- },
- 'body': {
- 'required': true
- },
- 'image': {
- 'required': true,
- 'sizes': [150, 150]
- },
- 'icon': {
- 'required': true,
- 'sizes': [50, 50]
- },
- 'clickUrl': {
- 'required': true
- },
- 'cta': {
- 'required': true
- },
- 'sponsoredBy': {
- 'required': true
- }
- }
- },
- 'bidId': '3150ccb55da321',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- 'userId': userId,
- 'userIdAsEids': userIdAsEids,
- }
- ];
-
- it('should attach valid params to the tag', function () {
- const bidderRequest = {
- refererInfo: {
- page: 'https://www.bridgewell.com/',
- legacy: {
- referer: 'https://www.bridgewell.com/',
- }
- }
- }
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const payload = request.data;
-
- expect(payload).to.be.an('object');
- expect(payload.adUnits).to.be.an('array');
- expect(payload.url).to.exist.and.to.equal('https://www.bridgewell.com/');
- for (let i = 0, max_i = payload.adUnits.length; i < max_i; i++) {
- const u = payload.adUnits[i];
- expect(u).to.have.property('ChannelID').that.is.a('string');
- expect(u).to.not.have.property('cid');
- expect(u).to.have.property('adUnitCode').and.to.equal('adunit-code-2');
- expect(u).to.have.property('requestId').and.to.equal('3150ccb55da321');
- expect(u).to.have.property('userIds');
- expect(u.userIds).to.deep.equal(userId);
- expect(u).to.have.property('userIdAsEids');
- expect(u.userIdAsEids).to.deep.equal(userIdAsEids);
- }
- });
-
- it('should attach valid params to the tag, part2', function() {
- const bidderRequest = {
- refererInfo: {
- page: 'https://www.bridgewell.com/',
- legacy: {
- referer: 'https://www.bridgewell.com/'
- }
- }
- }
- const bidRequests2 = [
- {
- 'bidder': 'bridgewell',
- 'params': {
- 'cid': 1234,
- },
- 'adUnitCode': 'adunit-code-2',
- 'mediaTypes': {
- 'banner': {
- 'sizes': [728, 90]
- }
- },
- 'bidId': '3150ccb55da321',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- 'userId': userId,
- 'userIdAsEids': userIdAsEids,
- },
- ];
-
- const request = spec.buildRequests(bidRequests2, bidderRequest);
- const payload = request.data;
-
- expect(payload).to.be.an('object');
- expect(payload.adUnits).to.be.an('array');
- expect(payload.url).to.exist.and.to.equal('https://www.bridgewell.com/');
- for (let i = 0, max_i = payload.adUnits.length; i < max_i; i++) {
- const u = payload.adUnits[i];
- expect(u).to.have.property('cid').that.is.a('number');
- expect(u).to.not.have.property('ChannelID');
- expect(u).to.have.property('adUnitCode').and.to.equal('adunit-code-2');
- expect(u).to.have.property('requestId').and.to.equal('3150ccb55da321');
- expect(u).to.have.property('userIds');
- expect(u.userIds).to.deep.equal(userId);
- expect(u).to.have.property('userIdAsEids');
- expect(u.userIdAsEids).to.deep.equal(userIdAsEids);
- }
- });
-
- it('should attach validBidRequests to the tag', function () {
- const bidderRequest = {
- refererInfo: {
- page: 'https://www.bridgewell.com/',
- legacy: {
- referer: 'https://www.bridgewell.com/',
- }
- }
- }
-
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const validBidRequests = request.validBidRequests;
- expect(validBidRequests).to.deep.equal(bidRequests);
- });
- });
-
- describe('interpretResponse', function () {
- const nativeBidRequests = {
- validBidRequests: [
- {
- 'bidder': 'bridgewell',
- 'params': {
- 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ',
- },
- 'adUnitCode': 'adunit-code-2',
- 'sizes': [1, 1],
- 'mediaTypes': {
- 'native': {
- 'title': {
- 'required': true,
- 'len': 15
- },
- 'body': {
- 'required': true
- },
- 'image': {
- 'required': true,
- 'sizes': [150, 150]
- },
- 'icon': {
- 'required': true,
- 'sizes': [50, 50]
- },
- 'clickUrl': {
- 'required': true
- },
- 'cta': {
- 'required': true
- },
- 'sponsoredBy': {
- 'required': true
- }
- }
- },
- 'bidId': '3150ccb55da321',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- },
- ]
- };
-
- const nativeServerResponses = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'adomain': ['response.com'],
- 'mediaType': 'native',
- 'native': {
- 'image': {
- 'url': 'https://img.scupio.com/test/test-image.jpg',
- 'width': 150,
- 'height': 150
- },
- 'title': 'test-title',
- 'sponsoredBy': 'test-sponsoredBy',
- 'body': 'test-body',
- 'icon': {
- 'url': 'https://img.scupio.com/test/test-icon.jpg',
- 'width': 50,
- 'height': 50
- },
- 'clickUrl': 'https://img.scupio.com/test-clickUrl',
- 'clickTrackers': ['https://img.scupio.com/test-clickTracker'],
- 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker']
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const bannerBidRequests = {
- validBidRequests: [
- {
- 'mediaTypes': {
- 'banner': {
- 'sizes': [300, 250]
- }
- },
- 'bidId': '3150ccb55da321',
- },
- ]
- };
-
- const bannerServerResponses = [
- {
- 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21',
- 'bidder_code': 'bridgewell',
- 'cpm': 5.0,
- 'width': 300,
- 'height': 250,
- 'adomain': ['response.com'],
- 'mediaType': 'banner',
- 'ad': 'test 300x250
',
- 'ttl': 360,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- it('should return all required parameters', function () {
- const result = spec.interpretResponse({ 'body': nativeServerResponses }, nativeBidRequests);
-
- expect(result[0].requestId).to.equal('3150ccb55da321');
- expect(result[0].cpm).to.equal(7.0);
- expect(result[0].width).to.equal(1);
- expect(result[0].height).to.equal(1);
- expect(result[0].ttl).to.equal(400);
- expect(result[0].creativeId).to.equal('0e4048d3-5c74-4380-a21a-00ba35629f7d');
- expect(result[0].netRevenue).to.equal(true);
- expect(result[0].currency).to.equal('NTD');
- expect(result[0].mediaType).to.equal('native');
- expect(result[0].native.image.url).to.equal('https://img.scupio.com/test/test-image.jpg');
- expect(String(result[0].meta.advertiserDomains)).to.equal('response.com');
- });
-
- it('should return all required parameters banner', function () {
- const result = spec.interpretResponse({ 'body': bannerServerResponses }, bannerBidRequests);
-
- expect(result[0].requestId).to.equal('3150ccb55da321');
- expect(result[0].cpm).to.equal(5.0);
- expect(result[0].width).to.equal(300);
- expect(result[0].height).to.equal(250);
- expect(result[0].ttl).to.equal(360);
- expect(result[0].creativeId).to.equal('e5b10774-32bf-4931-85ee-05095e8cff21');
- expect(result[0].netRevenue).to.equal(true);
- expect(result[0].currency).to.equal('NTD');
- expect(result[0].mediaType).to.equal('banner');
- expect(result[0].ad).to.equal('test 300x250
');
- expect(String(result[0].meta.advertiserDomains)).to.equal('response.com');
- });
-
- it('should give up bid if server response is undefined', function () {
- let result = spec.interpretResponse({ 'body': undefined }, bannerBidRequests);
-
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if request sizes is missing', function () {
- const request = {
- validBidRequests: [
- {
- 'mediaTypes': {
- 'banner': {}
- },
- 'bidId': '3150ccb55da321',
- },
- ]
- };
- const result = spec.interpretResponse({ 'body': bannerServerResponses }, request);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if response sizes is invalid', function () {
- const request = {
- validBidRequests: [
- {
- 'mediaTypes': {
- 'banner': {
- 'sizes': [728, 90]
- }
- },
- 'bidId': '3150ccb55da321',
- },
- ]
- };
- const result = spec.interpretResponse({ 'body': bannerServerResponses }, request);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if cpm is missing', function () {
- const response = [
- {
- 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21',
- 'bidder_code': 'bridgewell',
- 'width': 300,
- 'height': 250,
- 'mediaType': 'banner',
- 'ad': 'test 300x250
',
- 'ttl': 360,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, bannerBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if width or height is missing', function () {
- const response = [
- {
- 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21',
- 'bidder_code': 'bridgewell',
- 'cpm': 5.0,
- 'mediaType': 'banner',
- 'ad': 'test 300x250
',
- 'ttl': 360,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, bannerBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if ad is missing', function () {
- const response = [
- {
- 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21',
- 'bidder_code': 'bridgewell',
- 'cpm': 5.0,
- 'width': 300,
- 'height': 250,
- 'mediaType': 'banner',
- 'ttl': 360,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, bannerBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if revenue mode is missing', function () {
- const response = [
- {
- 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21',
- 'bidder_code': 'bridgewell',
- 'cpm': 5.0,
- 'width': 300,
- 'height': 250,
- 'mediaType': 'banner',
- 'ad': 'test 300x250
',
- 'ttl': 360,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, bannerBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if currency is missing', function () {
- const response = [
- {
- 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21',
- 'bidder_code': 'bridgewell',
- 'cpm': 5.0,
- 'width': 300,
- 'height': 250,
- 'mediaType': 'banner',
- 'ad': 'test 300x250
',
- 'ttl': 360,
- 'netRevenue': true,
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, bannerBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if mediaType is missing', function () {
- const response = [
- {
- 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21',
- 'bidder_code': 'bridgewell',
- 'cpm': 5.0,
- 'width': 300,
- 'height': 250,
- 'ad': 'test 300x250
',
- 'ttl': 360,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, bannerBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if mediaType is not support', function () {
- const responses = [
- {
- 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21',
- 'bidder_code': 'bridgewell',
- 'cpm': 5.0,
- 'width': 300,
- 'height': 250,
- 'mediaType': 'superNiceAd',
- 'ad': 'test 300x250
',
- 'ttl': 360,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': responses }, bannerBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if property native of mediaType native is missing', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if native title is missing', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'native': {
- 'image': {
- 'url': 'https://img.scupio.com/test/test-image.jpg',
- 'width': 150,
- 'height': 150
- },
- 'sponsoredBy': 'test-sponsoredBy',
- 'body': 'test-body',
- 'icon': {
- 'url': 'https://img.scupio.com/test/test-icon.jpg',
- 'width': 50,
- 'height': 50
- },
- 'clickUrl': 'https://img.scupio.com/test-clickUrl',
- 'clickTrackers': ['https://img.scupio.com/test-clickTracker'],
- 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker']
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if native title is too long', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'native': {
- 'image': {
- 'url': 'https://img.scupio.com/test/test-image.jpg',
- 'width': 150,
- 'height': 150
- },
- 'title': 'test-titletest-title',
- 'sponsoredBy': 'test-sponsoredBy',
- 'body': 'test-body',
- 'icon': {
- 'url': 'https://img.scupio.com/test/test-icon.jpg',
- 'width': 50,
- 'height': 50
- },
- 'clickUrl': 'https://img.scupio.com/test-clickUrl',
- 'clickTrackers': ['https://img.scupio.com/test-clickTracker'],
- 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker']
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if native body is missing', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'native': {
- 'image': {
- 'url': 'https://img.scupio.com/test/test-image.jpg',
- 'width': 150,
- 'height': 150
- },
- 'title': 'test-title',
- 'sponsoredBy': 'test-sponsoredBy',
- 'icon': {
- 'url': 'https://img.scupio.com/test/test-icon.jpg',
- 'width': 50,
- 'height': 50
- },
- 'clickUrl': 'https://img.scupio.com/test-clickUrl',
- 'clickTrackers': ['https://img.scupio.com/test-clickTracker'],
- 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker']
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if native image url is missing', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'native': {
- 'image': {
- 'width': 150,
- 'height': 150
- },
- 'title': 'test-title',
- 'sponsoredBy': 'test-sponsoredBy',
- 'body': 'test-body',
- 'icon': {
- 'url': 'https://img.scupio.com/test/test-icon.jpg',
- 'width': 50,
- 'height': 50
- },
- 'clickUrl': 'https://img.scupio.com/test-clickUrl',
- 'clickTrackers': ['https://img.scupio.com/test-clickTracker'],
- 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker']
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if native image is missing', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'native': {
- 'title': 'test-title',
- 'sponsoredBy': 'test-sponsoredBy',
- 'body': 'test-body',
- 'icon': {
- 'url': 'https://img.scupio.com/test/test-icon.jpg',
- 'width': 50,
- 'height': 50
- },
- 'clickUrl': 'https://img.scupio.com/test-clickUrl',
- 'clickTrackers': ['https://img.scupio.com/test-clickTracker'],
- 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker']
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if native image is empty', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'native': {
- 'image': {},
- 'title': 'test-title',
- 'sponsoredBy': 'test-sponsoredBy',
- 'body': 'test-body',
- 'icon': {
- 'url': 'https://img.scupio.com/test/test-icon.jpg',
- 'width': 50,
- 'height': 50
- },
- 'clickUrl': 'https://img.scupio.com/test-clickUrl',
- 'clickTrackers': ['https://img.scupio.com/test-clickTracker'],
- 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker']
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if native image sizes is missing', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'native': {
- 'image': {
- 'url': 'https://img.scupio.com/test/test-image.jpg'
- },
- 'title': 'test-title',
- 'sponsoredBy': 'test-sponsoredBy',
- 'body': 'test-body',
- 'icon': {
- 'url': 'https://img.scupio.com/test/test-icon.jpg',
- 'width': 50,
- 'height': 50
- },
- 'clickUrl': 'https://img.scupio.com/test-clickUrl',
- 'clickTrackers': ['https://img.scupio.com/test-clickTracker'],
- 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker']
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if native sponsoredBy is missing', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'native': {
- 'image': {
- 'url': 'https://img.scupio.com/test/test-image.jpg',
- 'width': 150,
- 'height': 150
- },
- 'title': 'test-title',
- 'body': 'test-body',
- 'icon': {
- 'url': 'https://img.scupio.com/test/test-icon.jpg',
- 'width': 50,
- 'height': 50
- },
- 'clickUrl': 'https://img.scupio.com/test-clickUrl',
- 'clickTrackers': ['https://img.scupio.com/test-clickTracker'],
- 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker']
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if native icon is missing', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'native': {
- 'image': {
- 'url': 'https://img.scupio.com/test/test-image.jpg',
- 'width': 150,
- 'height': 150
- },
- 'title': 'test-title',
- 'sponsoredBy': 'test-sponsoredBy',
- 'body': 'test-body',
- 'clickUrl': 'https://img.scupio.com/test-clickUrl',
- 'clickTrackers': ['https://img.scupio.com/test-clickTracker'],
- 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker']
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if native icon url is missing', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'native': {
- 'image': {
- 'url': 'https://img.scupio.com/test/test-image.jpg',
- 'width': 150,
- 'height': 150
- },
- 'title': 'test-title',
- 'sponsoredBy': 'test-sponsoredBy',
- 'body': 'test-body',
- 'icon': {
- 'width': 50,
- 'height': 50
- },
- 'clickUrl': 'https://img.scupio.com/test-clickUrl',
- 'clickTrackers': ['https://img.scupio.com/test-clickTracker'],
- 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker']
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if native icon sizes is missing', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'native': {
- 'image': {
- 'url': 'https://img.scupio.com/test/test-image.jpg',
- 'width': 150,
- 'height': 150
- },
- 'title': 'test-title',
- 'sponsoredBy': 'test-sponsoredBy',
- 'body': 'test-body',
- 'icon': {
- 'url': 'https://img.scupio.com/test/test-icon.jpg',
- },
- 'clickUrl': 'https://img.scupio.com/test-clickUrl',
- 'clickTrackers': ['https://img.scupio.com/test-clickTracker'],
- 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker']
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if native clickUrl is missing', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'native': {
- 'image': {
- 'url': 'https://img.scupio.com/test/test-image.jpg',
- 'width': 150,
- 'height': 150
- },
- 'title': 'test-title',
- 'sponsoredBy': 'test-sponsoredBy',
- 'body': 'test-body',
- 'icon': {
- 'url': 'https://img.scupio.com/test/test-icon.jpg',
- 'width': 50,
- 'height': 50
- },
- 'clickTrackers': ['https://img.scupio.com/test-clickTracker'],
- 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker']
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if native clickTrackers is missing', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'native': {
- 'image': {
- 'url': 'https://img.scupio.com/test/test-image.jpg',
- 'width': 150,
- 'height': 150
- },
- 'title': 'test-title',
- 'sponsoredBy': 'test-sponsoredBy',
- 'body': 'test-body',
- 'icon': {
- 'url': 'https://img.scupio.com/test/test-icon.jpg',
- 'width': 50,
- 'height': 50
- },
- 'clickUrl': 'https://img.scupio.com/test-clickUrl',
- 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker']
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if native clickTrackers is empty', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'native': {
- 'image': {
- 'url': 'https://img.scupio.com/test/test-image.jpg',
- 'width': 150,
- 'height': 150
- },
- 'title': 'test-title',
- 'sponsoredBy': 'test-sponsoredBy',
- 'body': 'test-body',
- 'icon': {
- 'url': 'https://img.scupio.com/test/test-icon.jpg',
- 'width': 50,
- 'height': 50
- },
- 'clickUrl': 'https://img.scupio.com/test-clickUrl',
- 'clickTrackers': [],
- 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker']
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if native impressionTrackers is missing', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'native': {
- 'image': {
- 'url': 'https://img.scupio.com/test/test-image.jpg',
- 'width': 150,
- 'height': 150
- },
- 'title': 'test-title',
- 'sponsoredBy': 'test-sponsoredBy',
- 'body': 'test-body',
- 'icon': {
- 'url': 'https://img.scupio.com/test/test-icon.jpg',
- 'width': 50,
- 'height': 50
- },
- 'clickUrl': 'https://img.scupio.com/test-clickUrl',
- 'clickTrackers': ['https://img.scupio.com/test-clickTracker'],
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should give up bid if native impressionTrackers is empty', function () {
- const response = [
- {
- 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 1,
- 'height': 1,
- 'mediaType': 'native',
- 'native': {
- 'image': {
- 'url': 'https://img.scupio.com/test/test-image.jpg',
- 'width': 150,
- 'height': 150
- },
- 'title': 'test-title',
- 'sponsoredBy': 'test-sponsoredBy',
- 'body': 'test-body',
- 'icon': {
- 'url': 'https://img.scupio.com/test/test-icon.jpg',
- 'width': 50,
- 'height': 50
- },
- 'clickUrl': 'https://img.scupio.com/test-clickUrl',
- 'clickTrackers': ['https://img.scupio.com/test-clickTracker'],
- 'impressionTrackers': []
- },
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- },
- ];
-
- const result = spec.interpretResponse({ 'body': response }, nativeBidRequests);
- expect(result).to.deep.equal([]);
- });
-
- it('should contain every request bid id in responses', function () {
- const request = {
- validBidRequests: [
- {
- 'mediaTypes': {
- 'banner': {
- 'sizes': [300, 250]
- }
- },
- 'bidId': '3150ccb55da321',
- },
- {
- 'mediaTypes': {
- 'banner': {
- 'sizes': [300, 250]
- }
- },
- 'bidId': '3150ccb55da322',
- }
- ],
- };
- const response = [{
- 'id': '0cd250f4-f40e-4a78-90f5-5168eb0a97e9',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 300,
- 'height': 250,
- 'mediaType': 'banner',
- 'ad': 'test 300x250
',
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- }, {
- 'id': '8a740063-6820-45e4-b01f-34ce9b38e858',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 300,
- 'height': 250,
- 'mediaType': 'banner',
- 'ad': 'test 300x250
',
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- }];
- const result = spec.interpretResponse({ 'body': response }, request);
- const actualBidId = result.map(obj => obj.requestId);
- const expectedBidId = ['3150ccb55da321', '3150ccb55da322'];
-
- expect(actualBidId).to.include(expectedBidId[0]).and.to.include(expectedBidId[1]);
- });
-
- it('should have 2 consumed responses when two requests with same sizes are given', function () {
- const request = {
- validBidRequests: [
- {
- 'mediaTypes': {
- 'banner': {
- 'sizes': [300, 250]
- }
- },
- 'bidId': '3150ccb55da321',
- },
- {
- 'mediaTypes': {
- 'banner': {
- 'sizes': [300, 250]
- }
- },
- 'bidId': '3150ccb55da322',
- }
- ],
- };
- const response = [{
- 'id': '0cd250f4-f40e-4a78-90f5-5168eb0a97e9',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 300,
- 'height': 250,
- 'mediaType': 'banner',
- 'ad': 'test 300x250
',
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- }, {
- 'id': '8a740063-6820-45e4-b01f-34ce9b38e858',
- 'bidder_code': 'bridgewell',
- 'cpm': 7.0,
- 'width': 300,
- 'height': 250,
- 'mediaType': 'banner',
- 'ad': 'test 300x250
',
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- }];
- const reducer = function(accumulator, currentValue) {
- if (currentValue.consumed) accumulator++;
- return accumulator;
- };
-
- spec.interpretResponse({ 'body': response }, request);
- expect(response.reduce(reducer, 0)).to.equal(2);
- });
-
- it('should use adUnitCode to build bidResponses', function () {
- const request = {
- validBidRequests: [
- {
- 'adUnitCode': 'div-gpt-ad-1564632520056-0',
- 'bidId': '3150ccb55da321',
- },
- {
- 'adUnitCode': 'div-gpt-ad-1564632520056-1',
- 'bidId': '3150ccb55da322',
- }
- ],
- };
- const response = [{
- 'id': '0cd250f4-f40e-4a78-90f5-5168eb0a97e9',
- 'bidder_code': 'bridgewell',
- 'adUnitCode': 'div-gpt-ad-1564632520056-0',
- 'cpm': 7.0,
- 'width': 300,
- 'height': 250,
- 'mediaType': 'banner',
- 'ad': 'test 300x250
',
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- }, {
- 'id': '8a740063-6820-45e4-b01f-34ce9b38e858',
- 'bidder_code': 'bridgewell',
- 'adUnitCode': 'div-gpt-ad-1564632520056-1',
- 'cpm': 7.0,
- 'width': 300,
- 'height': 250,
- 'mediaType': 'banner',
- 'ad': 'test 300x250
',
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- }];
- const result = spec.interpretResponse({ 'body': response }, request);
- const actualBidId = result.map(obj => obj.requestId);
- const expectedBidId = ['3150ccb55da321', '3150ccb55da322'];
-
- expect(actualBidId).to.include(expectedBidId[0]).and.to.include(expectedBidId[1]);
- });
-
- it('should use size to match when adUnitCode is empty string in server response', function () {
- const request = {
- validBidRequests: [
- {
- 'mediaTypes': {
- 'banner': {
- 'sizes': [300, 250]
- }
- },
- 'adUnitCode': 'div-gpt-ad-1564632520056-0',
- 'bidId': '3150ccb55da321',
- },
- {
- 'mediaTypes': {
- 'banner': {
- 'sizes': [300, 250]
- }
- },
- 'adUnitCode': 'div-gpt-ad-1564632520056-1',
- 'bidId': '3150ccb55da322',
- }
- ],
- };
- const response = [{
- 'id': '0cd250f4-f40e-4a78-90f5-5168eb0a97e9',
- 'bidder_code': 'bridgewell',
- 'adUnitCode': '',
- 'cpm': 7.0,
- 'width': 300,
- 'height': 250,
- 'mediaType': 'banner',
- 'ad': 'test 300x250
',
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- }, {
- 'id': '8a740063-6820-45e4-b01f-34ce9b38e858',
- 'bidder_code': 'bridgewell',
- 'adUnitCode': '',
- 'cpm': 7.0,
- 'width': 300,
- 'height': 250,
- 'mediaType': 'banner',
- 'ad': 'test 300x250
',
- 'ttl': 400,
- 'netRevenue': true,
- 'currency': 'NTD'
- }];
- const result = spec.interpretResponse({ 'body': response }, request);
- const actualBidId = result.map(obj => obj.requestId);
- const expectedBidId = ['3150ccb55da321', '3150ccb55da322'];
-
- expect(actualBidId).to.include(expectedBidId[0]).and.to.include(expectedBidId[1]);
- });
- });
-});
diff --git a/test/spec/modules/browsiAnalyticsAdapter_spec.js b/test/spec/modules/browsiAnalyticsAdapter_spec.js
deleted file mode 100644
index 6e7098b4d..000000000
--- a/test/spec/modules/browsiAnalyticsAdapter_spec.js
+++ /dev/null
@@ -1,321 +0,0 @@
-import browsiAnalytics, { setStaticData, getStaticData } from '../../../modules/browsiAnalyticsAdapter.js';
-
-import adapterManager from '../../../src/adapterManager.js';
-import { expect } from 'chai';
-import { EVENTS } from '../../../src/constants.js';
-import { server } from '../../../test/mocks/xhr.js';
-import { getGlobal } from '../../../src/prebidGlobal.js';
-import * as utils from '../../../src/utils.js';
-
-const events = require('src/events');
-
-describe('browsi analytics adapter', function () {
- const timestamp = 1740559971388;
- const auctionId = 'abe18da6-cee1-438b-9013-dc5a62c9d4a8';
-
- const auctionEnd = {
- 'auctionId': auctionId,
- 'timestamp': 1740559969178,
- 'auctionEnd': 1740559971388,
- 'auctionStatus': 'completed',
- 'adUnits': [
- {
- 'code': 'realtid_mobile-mobil-1_:r1:',
- 'sizes': [[300, 250], [320, 100], [320, 160], [320, 320]],
- 'mediaTypes': {
- 'banner': {
- 'sizes': [[300, 250], [320, 100], [320, 160], [320, 320]]
- }
- },
- 'bids': [
- {
- 'bidder': 'bidderA',
- 'auctionId': 'abe18da6-cee1-438b-9013-dc5a62c9d4a8',
- 'ortb2Imp': {
- 'ext': {
- 'data': {
- 'browsi': {
- 'scrollDepth': 0.4,
- 'density': 0.6,
- 'numberOfAds': 3,
- 'lcp': 2.5,
- 'cls': 0.08,
- 'inp': 150,
- 'viewability': 0.66,
- 'revenue': 0.44,
- 'adLocation': 1220
- }
- }
- }
- },
- },
- {
- 'bidder': 'adprofitadform',
- 'auctionId': 'abe18da6-cee1-438b-9013-dc5a62c9d4a8',
- },
- {
- 'bidder': 'bidderB',
- 'auctionId': 'abe18da6-cee1-438b-9013-dc5a62c9d4a8',
- 'ortb2Imp': {
- 'ext': {
- 'data': {
- 'browsi': {
- 'scrollDepth': 0.4,
- 'density': 0.6,
- 'numberOfAds': 3,
- 'lcp': 2.5,
- 'cls': 0.08,
- 'inp': 150,
- 'viewability': 0.66,
- 'revenue': 0.44,
- 'adLocation': 1220
- }
- }
- }
- },
- },
- ],
- 'lwPName': 'realtid_mobile-mobil-1',
- 'adUnitId': '974f76d1-02af-4bb9-93d8-6aa8d4f81f30',
- 'transactionId': '39fe8024-758e-4dbc-82c8-656cfba1d06b',
- 'adserverTargeting': {
- 'browsiViewability': [
- '0.60'
- ],
- 'browsiScroll': [
- '0.40'
- ],
- 'browsiRevenue': [
- 'medium'
- ]
- }
- },
- {
- 'code': 'realtid_mobile-mobil-2_:r2:',
- 'sizes': [[300, 250], [320, 100], [320, 160], [320, 320], [320, 400], [320, 480]],
- 'mediaTypes': {
- 'banner': {
- 'sizes': [[300, 250], [320, 100], [320, 160], [320, 320], [320, 400], [320, 480]]
- }
- },
- 'bids': [
- {
- 'bidder': 'bidderA',
- 'auctionId': 'abe18da6-cee1-438b-9013-dc5a62c9d4a8',
- 'ortb2Imp': {
- 'ext': {
- 'data': {
- 'browsi': {
- 'scrollDepth': 0.4,
- 'density': 0.6,
- 'numberOfAds': 3,
- 'lcp': 2.5,
- 'cls': 0.08,
- 'inp': 150
- }
- }
- }
- },
- },
- {
- 'bidder': 'tmapubmatic',
- 'auctionId': 'abe18da6-cee1-438b-9013-dc5a62c9d4a8',
- },
- {
- 'bidder': 'adprofitadform',
- 'auctionId': 'abe18da6-cee1-438b-9013-dc5a62c9d4a8',
- },
- ],
- 'lwPName': 'realtid_mobile-mobil-2',
- 'adUnitId': '644e15c8-4ee4-4205-9bf0-72dd22f8a678',
- 'transactionId': '2299ea95-cd7e-492d-952f-38a637afff81',
- 'adserverTargeting': {
- 'browsiScroll': [
- '0.40'
- ],
- 'browsiRevenue': [
- 'no fill'
- ]
- }
- }
- ],
- 'adUnitCodes': [
- 'realtid_mobile-mobil-1_:r1:',
- 'realtid_mobile-mobil-2_:r2:'
- ]
- }
- const browsiInit = {
- 'moduleName': 'browsi',
- 't': 1740559969178,
- 'pvid': '123456',
- 'pk': 'pub_key',
- 'sk': 'site_key',
- }
- const dataSet1 = {
- moduleName: 'browsi',
- pvid: '123456',
- d: 'MOBILE',
- g: 'IL',
- aid: 'article_123',
- es: true,
- sk: 'site_key',
- pk: 'pub_key',
- t: 1740559969178
- }
- const dataSet2 = {
- moduleName: 'browsi',
- pvid: '123456',
- d: 'DESKTOP',
- g: 'IL',
- aid: 'article_321',
- es: false,
- sk: 'site_key',
- pk: 'pub_key',
- t: 1740559969178
- }
-
- let sandbox;
-
- before(() => {
- sandbox = sinon.createSandbox();
- sandbox.stub(utils, 'timestamp').returns(timestamp);
-
- adapterManager.registerAnalyticsAdapter({
- code: 'browsi',
- adapter: browsiAnalytics
- });
- });
- after(() => {
- sandbox.restore();
- });
-
- beforeEach(() => {
- sandbox.stub(events, 'getEvents').returns([]);
- browsiAnalytics.enableAnalytics({
- provider: 'browsi',
- options: {}
- });
- browsiAnalytics._staticData = undefined;
- });
- afterEach(() => {
- events.getEvents.restore();
- browsiAnalytics.disableAnalytics();
- });
-
- it('should send auction data', function () {
- setStaticData(dataSet1);
-
- events.emit(EVENTS.AUCTION_END, auctionEnd);
- expect(server.requests.length).to.equal(1);
-
- const request = server.requests[0];
- const { protocol, hostname, pathname, search } = utils.parseUrl(request.url);
- expect(protocol).to.equal('https');
- expect(hostname).to.equal('events.browsiprod.com');
- expect(pathname).to.equal('/events/v2/rtd_demand');
- expect(search).to.deep.equal({ 'p': '123456' });
-
- const body = JSON.parse(request.requestBody);
- expect(body.length).to.equal(1);
-
- const event = body[0];
- expect(event.to).to.equal(timestamp - dataSet1.t);
- expect(event.pvid).to.equal(dataSet1.pvid);
- expect(event.pk).to.equal(dataSet1.pk);
- expect(event.sk).to.equal(dataSet1.sk);
- expect(event.geo).to.equal(dataSet1.g);
- expect(event.dp).to.equal(dataSet1.d);
- expect(event.aid).to.equal(dataSet1.aid);
- expect(event.pbv).to.equal(getGlobal().version);
- expect(event.url).to.equal(encodeURIComponent(window.location.href));
- expect(event.et).to.equal('auction_data_sent');
- expect(event.aucid).to.equal(auctionId);
- expect(event.ad_units).to.have.length(2);
-
- expect(event.ad_units[0].plid).to.equal('realtid_mobile-mobil-1_:r1:');
- expect(event.ad_units[0].au).to.be.null;
- expect(event.ad_units[0].pbd).to.deep.equal(['bidderA', 'bidderB']);
- expect(event.ad_units[0].dpc).to.equal(9);
- expect(event.ad_units[0].rtm).to.deep.equal({
- 'scrollDepth': 0.4,
- 'density': 0.6,
- 'numberOfAds': 3,
- 'lcp': 2.5,
- 'cls': 0.08,
- 'inp': 150,
- 'viewability': 0.66,
- 'revenue': 0.44,
- 'adLocation': 1220
- });
- expect(event.ad_units[1].plid).to.equal('realtid_mobile-mobil-2_:r2:');
- expect(event.ad_units[1].au).to.be.null;
- expect(event.ad_units[1].pbd).to.deep.equal(['bidderA']);
- expect(event.ad_units[1].dpc).to.equal(6);
- expect(event.ad_units[1].rtm).to.deep.equal({
- 'scrollDepth': 0.4,
- 'density': 0.6,
- 'numberOfAds': 3,
- 'lcp': 2.5,
- 'cls': 0.08,
- 'inp': 150
- });
- });
- it('should send auction data without rtm data', function () {
- setStaticData(dataSet2);
-
- events.emit(EVENTS.AUCTION_END, auctionEnd);
- expect(server.requests.length).to.equal(1);
-
- const request = server.requests[0];
- const body = JSON.parse(request.requestBody);
- expect(body.length).to.equal(1);
-
- const event = body[0];
- expect(event.ad_units[0].rtm).to.not.exist;
- expect(event.ad_units[1].rtm).to.not.exist;
- });
- it('should send rtd init event', function () {
- events.emit(EVENTS.BROWSI_INIT, browsiInit);
- expect(server.requests.length).to.equal(1);
-
- const request = server.requests[0];
- const { protocol, hostname, pathname, search } = utils.parseUrl(request.url);
- expect(protocol).to.equal('https');
- expect(hostname).to.equal('events.browsiprod.com');
- expect(pathname).to.equal('/events/v2/rtd_supply');
- expect(search).to.deep.equal({ 'p': '123456' });
-
- const body = JSON.parse(request.requestBody);
- expect(body.length).to.equal(1);
-
- const event = body[0];
- expect(event.et).to.equal('rtd_init');
- expect(event.to).to.equal(timestamp - dataSet1.t);
- expect(event.pvid).to.equal(dataSet1.pvid);
- expect(event.pk).to.equal(dataSet1.pk);
- expect(event.sk).to.equal(dataSet1.sk);
- expect(event.pbv).to.equal(getGlobal().version);
- expect(event.url).to.equal(encodeURIComponent(window.location.href));
- });
- it('should not send rtd init event if module name is not browsi', function () {
- events.emit(EVENTS.BROWSI_INIT, { moduleName: 'not_browsi' });
- expect(server.requests.length).to.equal(0);
- });
- it('should not set static data if module name is not browsi', function () {
- events.emit(EVENTS.BROWSI_DATA, { moduleName: 'not_browsi' });
- expect(browsiAnalytics._staticData).to.equal(undefined);
- });
- it('should set static data', function () {
- events.emit(EVENTS.BROWSI_DATA, dataSet2);
- expect(getStaticData()).to.deep.equal({
- pvid: '123456',
- device: 'DESKTOP',
- geo: 'IL',
- aid: 'article_321',
- es: false,
- sk: 'site_key',
- pk: 'pub_key',
- t: 1740559969178
- });
- });
-});
diff --git a/test/spec/modules/browsiBidAdapter_spec.js b/test/spec/modules/browsiBidAdapter_spec.js
deleted file mode 100644
index a4f1778af..000000000
--- a/test/spec/modules/browsiBidAdapter_spec.js
+++ /dev/null
@@ -1,218 +0,0 @@
-import {ENDPOINT, spec} from 'modules/browsiBidAdapter.js';
-import {config} from 'src/config.js';
-import {VIDEO, BANNER} from 'src/mediaTypes.js';
-
-const {expect} = require('chai');
-const DATA = 'brwvidtag';
-const ADAPTER = '__bad';
-
-describe('browsi Bid Adapter Test', function () {
- describe('isBidRequestValid', function () {
- let mediaTypes;
- let bid;
- beforeEach(function () {
- mediaTypes = {};
- mediaTypes[VIDEO] = {};
- bid = {
- 'params': {
- 'pubId': '1234567',
- 'tagId': '1'
- },
- 'mediaTypes': mediaTypes
- };
- });
- it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
- it('should return false when missing pubId', function () {
- delete bid.params.pubId;
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
- it('should return false when missing tagId', function () {
- delete bid.params.tagId;
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
- it('should return false when missing params', function () {
- delete bid.params;
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
- it('should return false when params have invalid type', function () {
- bid.params.tagId = 1;
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
- it('should return false when video mediaType is missing', function () {
- delete bid.mediaTypes[VIDEO];
- bid.mediaTypes[BANNER] = {}
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
- });
-
- describe('buildRequests', function () {
- let bidRequest;
- let bidderRequest;
- beforeEach(function () {
- window[DATA] = {}
- window[DATA][ADAPTER] = {index: 0};
- bidRequest = [
- {
- 'params': {
- 'pubId': 'browiPubId1',
- 'tagId': '2'
- },
- 'adUnitCode': 'adUnitCode1',
- 'auctionId': 'auctionId1',
- 'sizes': [640, 480],
- 'bidId': '12345678',
- 'requestId': '1234567-3456-4562-7689-98765434A',
- ortb2Imp: {
- ext: {
- tid: '1234567-3456-4562-7689-98765434B',
- }
- },
- 'ortb2': {
- 'source': {
- 'ext': {
- 'schain': {}
- }
- }
- },
- 'mediaTypes': {video: {playerSize: [640, 480]}}
- }
- ];
- bidderRequest = {
- 'bidderRequestId': 'bidderRequestId1',
- 'refererInfo': {
- 'canonicalUrl': null,
- 'page': 'https://browsi.com',
- 'domain': 'browsi.com',
- 'ref': null,
- 'numIframes': 0,
- 'reachedTop': true,
- 'isAmp': false,
- 'stack': ['https://browsi.com']
- },
- 'gdprConsent': {
- consentString: 'BOtmiBKOtmiBKABABAENAFAAAAACeAAA',
- gdprApplies: true
- },
- 'uspConsent': '1YYY'
- };
- });
- afterEach(function() {
- window[DATA] = undefined;
- config.resetConfig();
- });
- it('should return an array of requests with single request', function () {
- const requests = spec.buildRequests(bidRequest, bidderRequest);
- expect(requests.length).to.equal(1);
- const request = requests[0];
- const inputRequest = bidRequest[0];
- const requestToExpect = {
- method: 'POST',
- url: ENDPOINT,
- data: {
- requestId: bidderRequest.bidderRequestId,
- bidId: inputRequest.bidId,
- timeout: 3000,
- baData: window[DATA][ADAPTER],
- referer: bidderRequest.refererInfo.page,
- gdpr: bidderRequest.gdprConsent,
- ccpa: bidderRequest.uspConsent,
- sizes: inputRequest.sizes,
- video: {playerSize: [640, 480]},
- aUCode: inputRequest.adUnitCode,
- aID: inputRequest.auctionId,
- tID: inputRequest.ortb2Imp.ext.tid,
- schain: inputRequest.ortb2?.source?.ext?.schain,
- params: inputRequest.params
- }
- }
- assert.deepEqual(request, requestToExpect);
- });
- it('should pass on timeout in bidderRequest', function() {
- bidderRequest.timeout = 8000;
- const requests = spec.buildRequests(bidRequest, bidderRequest);
- expect(requests[0].data.timeout).to.equal(8000);
- });
- it('should pass timeout in config', function() {
- config.setConfig({'bidderTimeout': 6000});
- const requests = spec.buildRequests(bidRequest, bidderRequest);
- expect(requests[0].data.timeout).to.equal(6000);
- });
- });
-
- describe('interpretResponse', function () {
- const bidRequest = {
- 'url': ENDPOINT,
- 'data': {
- 'bidId': 'bidId1',
- }
- };
- const serverResponse = {};
- serverResponse.body = {
- bidId: 'bidId1',
- w: 300,
- h: 250,
- vXml: 'vastXml',
- vUrl: 'vastUrl',
- cpm: 1,
- cur: 'USD',
- ttl: 10000,
- someExtraParams: 8,
- }
-
- it('should return a valid response', function () {
- const bidResponses = spec.interpretResponse(serverResponse, bidRequest);
- expect(bidResponses.length).to.equal(1);
- const actualBidResponse = bidResponses[0];
- const expectedBidResponse = {
- requestId: bidRequest.data.bidId,
- bidId: 'bidId1',
- width: 300,
- height: 250,
- vastXml: 'vastXml',
- vastUrl: 'vastUrl',
- cpm: 1,
- currency: 'USD',
- ttl: 10000,
- someExtraParams: 8,
- mediaType: VIDEO
- };
-
- assert.deepEqual(actualBidResponse, expectedBidResponse);
- });
- });
-
- describe('getUserSyncs', function () {
- const bidResponse = {
- userSyncs: [
- {url: 'syncUrl1', type: 'image'},
- {url: 'http://syncUrl2', type: 'iframe'}
- ]
- }
- const serverResponse = [
- {body: bidResponse}
- ];
- it('should return iframe type userSync', function () {
- const userSyncs = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: false}, serverResponse[0]);
- expect(userSyncs.length).to.equal(1);
- const userSync = userSyncs[0];
- expect(userSync.url).to.equal('http://syncUrl2');
- expect(userSync.type).to.equal('iframe');
- });
- it('should return image type userSyncs', function () {
- const userSyncs = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, serverResponse[0]);
- const userSync = userSyncs[0];
- expect(userSync.url).to.equal('http://syncUrl1');
- expect(userSync.type).to.equal('image');
- });
- it('should handle multiple server responses', function () {
- const userSyncs = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, serverResponse);
- expect(userSyncs.length).to.equal(1);
- });
- it('should return empty userSyncs', function () {
- const userSyncs = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: false}, serverResponse);
- expect(userSyncs.length).to.equal(0);
- });
- });
-});
diff --git a/test/spec/modules/browsiRtdProvider_spec.js b/test/spec/modules/browsiRtdProvider_spec.js
deleted file mode 100644
index 202732202..000000000
--- a/test/spec/modules/browsiRtdProvider_spec.js
+++ /dev/null
@@ -1,522 +0,0 @@
-import * as browsiRTD from '../../../modules/browsiRtdProvider.js';
-import * as browsiUtils from '../../../libraries/browsiUtils/browsiUtils.js';
-import * as utils from '../../../src/utils.js'
-import * as events from '../../../src/events.js';
-import * as sinon from 'sinon';
-import * as mockGpt from 'test/spec/integration/faker/googletag.js';
-import * as Global from '../../../src/prebidGlobal.js';
-
-describe('browsi Real time data sub module', function () {
- const conf = {
- 'auctionDelay': 250,
- dataProviders: [{
- 'name': 'browsi',
- 'params': {
- 'url': 'testUrl.com',
- 'siteKey': 'testKey',
- 'pubKey': 'testPub',
- 'keyName': 'bv'
- }
- }]
- };
- const auction = {
- adUnits: [
- {
- code: 'adMock',
- transactionId: 1
- },
- {
- code: 'hasPrediction',
- transactionId: 1
- }
- ]
- };
- const msPerDay = 24 * 60 * 60 * 1000;
-
- let sandbox;
- let eventsEmitSpy;
- let timestampStub;
-
- before(() => {
- sandbox = sinon.createSandbox();
- eventsEmitSpy = sandbox.spy(events, ['emit']);
- timestampStub = sandbox.stub(utils, 'timestamp');
- sandbox.stub(Global, 'getGlobal').callsFake(() => {
- return {
- enableAnalytics: () => { },
- }
- });
- });
-
- after(() => {
- sandbox.restore();
- });
-
- it('should init and return true', function () {
- browsiRTD.collectData();
- expect(browsiRTD.browsiSubmodule.init(conf.dataProviders[0])).to.equal(true)
- });
-
- it('should create browsi script', function () {
- const script = browsiRTD.addBrowsiTag('scriptUrl.com');
- expect(script.getAttribute('data-sitekey')).to.equal('testKey');
- expect(script.getAttribute('data-pubkey')).to.equal('testPub');
- expect(script.async).to.equal(true);
- expect(script.prebidData.kn).to.equal(conf.dataProviders[0].params.keyName);
- });
-
- it('should return correct macro values', function () {
- const slot = mockGpt.makeSlot({ code: '/123/abc', divId: 'browsiAd_1' });
-
- slot.setTargeting('test', ['test', 'value']);
- // slot getTargeting doesn't act like GPT so we can't expect real value
- const macroResult = browsiUtils.getMacroId({ p: '/' }, slot);
- expect(macroResult).to.equal('/123/abc/NA');
-
- const macroResultB = browsiUtils.getMacroId({}, slot);
- expect(macroResultB).to.equal('browsiAd_1');
-
- const macroResultC = browsiUtils.getMacroId({ p: '', s: { s: 0, e: 1 } }, slot);
- expect(macroResultC).to.equal('/');
- });
-
- describe('should return data to RTD module', function () {
- it('should return empty if no ad units defined', function () {
- browsiRTD.setBrowsiData({});
- expect(browsiRTD.browsiSubmodule.getTargetingData([], null, null, auction)).to.eql({});
- });
- it('should return empty if GAM is not defined', function () {
- mockGpt.makeSlot({ code: 'slot1', divId: 'slot1' });
- const data = {
- plc: { 'slot1': { viewability: { 0: 0.234 } } },
- pmd: undefined,
- sg: false
- };
- browsiRTD.setBrowsiData(data);
- expect(browsiRTD.browsiSubmodule.getTargetingData(['slotId'], null, null, auction)).to.eql({});
- });
- it('should return empty if viewability key is not defined', function () {
- mockGpt.makeSlot({ code: 'slot2', divId: 'slot2' });
- const data = {
- plc: { 'slot2': { someKey: { 0: 0.234 } } },
- pmd: undefined,
- sg: true
- };
- browsiRTD.setBrowsiData(data);
- expect(browsiRTD.browsiSubmodule.getTargetingData(['slot2'], null, null, auction)).to.eql({ 'slot2': {} });
- });
- it('should return all predictions from server', function () {
- mockGpt.makeSlot({ code: 'slot3', divId: 'slot3' });
- const data = {
- pg: { scrollDepth: 0.456 },
- plc: { 'slot3': { viewability: { 0: 0.234 }, revenue: { 0: 0.567 } } },
- pmd: undefined,
- sg: true
- };
- browsiRTD.setBrowsiData(data);
- expect(browsiRTD.browsiSubmodule.getTargetingData(['slot3'], null, null, auction)).to.eql({
- 'slot3': { bv: '0.20', browsiRevenue: 'medium', browsiScroll: '0.40' }
- });
- });
- it('should return the available prediction', function () {
- mockGpt.makeSlot({ code: 'slot4', divId: 'slot4' });
- const data = {
- pg: { scrollDepth: 0.456 },
- plc: { 'slot4': { someKey: { 0: 0.234 } } },
- pmd: undefined,
- sg: true
- };
- browsiRTD.setBrowsiData(data);
- expect(browsiRTD.browsiSubmodule.getTargetingData(['slot4'], null, null, auction)).to.eql({ 'slot4': { browsiScroll: '0.40' } });
- });
- })
-
- describe('should return matching prediction', function () {
- const predictions = {
- 0: 0.123,
- 1: 0.254,
- 3: 0,
- 4: 0.8
- }
- const singlePrediction = {
- 0: 0.123
- }
- const numbericPrediction = 0.456;
- it('should return raw value if valid', function () {
- expect(browsiRTD.getCurrentData(predictions, 0)).to.equal(0.123);
- expect(browsiRTD.getCurrentData(predictions, 1)).to.equal(0.254);
- })
- it('should return 0 for prediction = 0', function () {
- expect(browsiRTD.getCurrentData(predictions, 3)).to.equal(0);
- })
- it('should return -1 for invalid params', function () {
- expect(browsiRTD.getCurrentData(null, 3)).to.equal(-1);
- expect(browsiRTD.getCurrentData(predictions, null)).to.equal(-1);
- })
- it('should return prediction according to object keys length ', function () {
- expect(browsiRTD.getCurrentData(singlePrediction, 0)).to.equal(0.123);
- expect(browsiRTD.getCurrentData(singlePrediction, 1)).to.equal(-1);
- expect(browsiRTD.getCurrentData(singlePrediction, 2)).to.equal(-1);
- expect(browsiRTD.getCurrentData(predictions, 4)).to.equal(0.8);
- expect(browsiRTD.getCurrentData(predictions, 5)).to.equal(0.8);
- expect(browsiRTD.getCurrentData(predictions, 8)).to.equal(0.8);
- })
- it('should return prediction if it is a number', function () {
- expect(browsiRTD.getCurrentData(numbericPrediction, 0)).to.equal(0.456);
- })
- })
-
- describe('should handle bid request data', function () {
- const data = {
- plc: {
- 'adUnit1': { keyA: { 0: 0.234 } },
- 'adUnit2': { keyB: { 0: 0.134 } }
- },
- pr: ['bidder1'],
- pmd: undefined
- }
- const fakeAdUnits = [
- {
- code: 'adUnit1',
- bids: [
- { bidder: 'bidder1' },
- { bidder: 'bidder2' }
- ]
- },
- {
- code: 'adUnit2',
- bids: [
- { bidder: 'bidder1' },
- { bidder: 'bidder2' }
- ]
- }
- ]
- before(async () => {
- browsiRTD.setBrowsiData(data);
- browsiRTD.browsiSubmodule.getBidRequestData({ adUnits: fakeAdUnits }, () => { }, {}, null);
- });
- it('should set bidder params with prediction values', function () {
- expect(utils.deepAccess(fakeAdUnits[0].bids[0], 'ortb2Imp.ext.data.browsi')).to.eql({ keyA: 0.234 });
- expect(utils.deepAccess(fakeAdUnits[1].bids[0], 'ortb2Imp.ext.data.browsi')).to.eql({ keyB: 0.134 });
- })
- it('should not set bidder params if bidder is not in pr', function () {
- expect(utils.deepAccess(fakeAdUnits[0].bids[1], 'ortb2Imp.ext.data.browsi')).to.eql(undefined);
- expect(utils.deepAccess(fakeAdUnits[1].bids[1], 'ortb2Imp.ext.data.browsi')).to.eql(undefined);
- })
- })
-
- describe('should not set bid request data', function () {
- const data = {
- plc: {
- 'adUnit1': { keyA: { 0: 0.234 } },
- 'adUnit2': { keyB: { 0: 0.134 } }
- },
- pr: [],
- pmd: undefined
- }
- const fakeAdUnits = [
- {
- code: 'adUnit1',
- bids: [
- { bidder: 'bidder1' },
- { bidder: 'bidder2' }
- ]
- },
- {
- code: 'adUnit2',
- bids: [
- { bidder: 'bidder1' },
- { bidder: 'bidder2' }
- ]
- }
- ]
- before(() => {
- browsiRTD.setBrowsiData(data);
- browsiRTD.browsiSubmodule.getBidRequestData({ adUnits: fakeAdUnits }, () => { }, {}, null);
- });
- it('should not set bidder params if pr is empty', function () {
- expect(utils.deepAccess(fakeAdUnits[0].bids[0], 'ortb2Imp.ext.data.browsi')).to.eql(undefined);
- expect(utils.deepAccess(fakeAdUnits[1].bids[0], 'ortb2Imp.ext.data.browsi')).to.eql(undefined);
- expect(utils.deepAccess(fakeAdUnits[0].bids[1], 'ortb2Imp.ext.data.browsi')).to.eql(undefined);
- expect(utils.deepAccess(fakeAdUnits[1].bids[1], 'ortb2Imp.ext.data.browsi')).to.eql(undefined);
- })
- })
-
- describe('should emit ad request billable event', function () {
- before(() => {
- const data = {
- p: {
- 'adUnit1': { ps: { 0: 0.234 } },
- 'adUnit2': { ps: { 0: 0.134 } }
- },
- pmd: undefined,
- bet: 'AD_REQUEST'
- };
- browsiRTD.setBrowsiData(data);
- })
- beforeEach(() => {
- eventsEmitSpy.resetHistory();
- })
- it('should send one event per ad unit code', function () {
- const auction = {
- adUnits: [
- {
- code: 'a',
- transactionId: 1
- },
- {
- code: 'b',
- transactionId: 2
- },
- {
- code: 'a',
- transactionId: 3
- },
- ]
- };
-
- browsiRTD.browsiSubmodule.getTargetingData(['a', 'b'], null, null, auction);
- expect(eventsEmitSpy.callCount).to.equal(2);
- })
- it('should send events only for received ad unit codes', function () {
- const auction = {
- adUnits: [
- {
- code: 'a',
- transactionId: 1
- },
- {
- code: 'b',
- transactionId: 2
- },
- {
- code: 'c',
- transactionId: 3
- },
- ]
- };
-
- browsiRTD.browsiSubmodule.getTargetingData(['a'], null, null, auction);
- expect(eventsEmitSpy.callCount).to.equal(1);
- browsiRTD.browsiSubmodule.getTargetingData(['b'], null, null, auction);
- expect(eventsEmitSpy.callCount).to.equal(2);
- })
- it('should use 1st transaction ID in case of twin ad unit codes', function () {
- const auction = {
- auctionId: '123',
- adUnits: [
- {
- code: 'a',
- transactionId: 1
- },
- {
- code: 'a',
- transactionId: 3
- },
- ]
- };
-
- const expectedCall = {
- vendor: 'browsi',
- type: 'adRequest',
- transactionId: 1,
- auctionId: '123'
- }
-
- browsiRTD.browsiSubmodule.getTargetingData(['a'], null, null, auction);
- const callArguments = eventsEmitSpy.getCalls()[0].args[1];
- // billing id is random, we can't check its value
- delete callArguments['billingId'];
- expect(callArguments).to.eql(expectedCall);
- })
- })
-
- describe('should emit pageveiw billable event', function () {
- beforeEach(() => {
- eventsEmitSpy.resetHistory();
- })
- it('should send event if type is correct', function () {
- browsiRTD.sendPageviewEvent('PAGEVIEW')
- const pageViewEvent = new CustomEvent('browsi_pageview', {});
- window.dispatchEvent(pageViewEvent);
- const expectedCall = {
- vendor: 'browsi',
- type: 'pageview',
- }
-
- expect(eventsEmitSpy.callCount).to.equal(1);
- const callArguments = eventsEmitSpy.getCalls()[0].args[1];
- // billing id is random, we can't check its value
- delete callArguments['billingId'];
- expect(callArguments).to.eql(expectedCall);
- })
- it('should not send event if type is incorrect', function () {
- browsiRTD.sendPageviewEvent('AD_REQUEST');
- browsiRTD.sendPageviewEvent('INACTIVE');
- browsiRTD.sendPageviewEvent(undefined);
- expect(eventsEmitSpy.callCount).to.equal(0);
- })
- })
-
- describe('set targeting - invalid params', function () {
- const random = Math.floor(Math.random() * 10) + 1;
- it('should return false if key is undefined', function () {
- expect(browsiUtils.setKeyValue(undefined, random)).to.equal(false);
- })
- it('should return false if key is not string', function () {
- expect(browsiUtils.setKeyValue(1, random)).to.equal(false);
- })
- })
-
- describe('set targeting - valid params', function () {
- let slot;
- const splitKey = 'splitTest';
- const random = Math.floor(Math.random() * 10) + 1;
- before(() => {
- mockGpt.reset();
- window.googletag.pubads().clearTargeting();
- slot = mockGpt.makeSlot({ code: '/123/split', divId: 'split' });
- browsiUtils.setKeyValue(splitKey, random);
- window.googletag.cmd.forEach(cmd => cmd());
- })
- it('should place numeric key value on all slots', function () {
- const targetingValue = window.googletag.pubads().getTargeting(splitKey);
- expect(targetingValue).to.be.an('array').that.is.not.empty;
- expect(targetingValue[0]).to.be.a('string');
- })
- })
-
- describe('should get latest avg highest bid', function () {
- it('should return lahb', function () {
- const currentTimestemp = new Date().getTime();
- const storageTimestemp = currentTimestemp - (msPerDay);
-
- const diffInMilliseconds = Math.abs(storageTimestemp - currentTimestemp);
- const diffInDays = diffInMilliseconds / msPerDay;
-
- const lahb = {
- avg: 0.02,
- smp: 3,
- time: storageTimestemp
- };
-
- timestampStub.returns(currentTimestemp);
-
- expect(browsiUtils.getLahb(lahb, currentTimestemp)).to.deep.equal({ avg: 0.02, age: diffInDays });
- });
- })
-
- describe('should get recent avg highest bid', function () {
- it('should return rahb', function () {
- const currentTimestemp = new Date().getTime();
- const oneDayAgoTimestemp = currentTimestemp - (msPerDay);
- const twoDayAgoTimestemp = currentTimestemp - (2 * msPerDay);
- const rahb = {
- [currentTimestemp]: { 'sum': 20, 'smp': 8 },
- [oneDayAgoTimestemp]: { 'sum': 25, 'smp': 10 },
- [twoDayAgoTimestemp]: { 'sum': 30, 'smp': 12 }
- };
- expect(browsiUtils.getRahb(rahb, currentTimestemp)).to.deep.equal({ avg: 2.5 });
- });
- it('should return rahb without timestamps older than a week', function () {
- const currentTimestemp = new Date().getTime();
- const oneDayAgoTimestemp = currentTimestemp - (msPerDay);
- const twoDayAgoTimestemp = currentTimestemp - (2 * msPerDay);
- const twoWeekAgoTimestemp = currentTimestemp - (14 * msPerDay);
- const rahb = {
- [currentTimestemp]: { 'sum': 20, 'smp': 8 },
- [oneDayAgoTimestemp]: { 'sum': 25, 'smp': 10 },
- [twoDayAgoTimestemp]: { 'sum': 30, 'smp': 12 },
- [twoWeekAgoTimestemp]: { 'sum': 35, 'smp': 20 }
- };
- const expected = {
- [currentTimestemp]: { 'sum': 20, 'smp': 8 },
- [oneDayAgoTimestemp]: { 'sum': 25, 'smp': 10 },
- [twoDayAgoTimestemp]: { 'sum': 30, 'smp': 12 },
- };
- expect(browsiUtils.getRahbByTs(rahb, currentTimestemp)).to.deep.equal(expected);
- });
- it('should return an empty object if all timestamps are older than a week', function () {
- const currentTimestemp = new Date().getTime();
- const eightDaysAgoTimestemp = currentTimestemp - (8 * msPerDay);
- const twoWeekAgoTimestemp = currentTimestemp - (14 * msPerDay);
- const rahb = {
- [eightDaysAgoTimestemp]: { 'sum': 20, 'smp': 8 },
- [twoWeekAgoTimestemp]: { 'sum': 25, 'smp': 10 }
- };
- expect(browsiUtils.getRahbByTs(rahb, currentTimestemp)).to.deep.equal({});
- });
- })
-
- describe('should get avg highest bid metrics', function () {
- const currentTimestemp = new Date().getTime();
- const oneDayAgoTimestemp = currentTimestemp - (msPerDay);
- const twoWeekAgoTimestemp = currentTimestemp - (14 * msPerDay);
-
- const uahb = { avg: 0.2991556234740213, smp: 28 };
- const lahb = { avg: 0.02, smp: 3, time: oneDayAgoTimestemp };
- const rahb = { [currentTimestemp]: { sum: 20, smp: 8 }, [oneDayAgoTimestemp]: { sum: 25, smp: 10 }, };
-
- const getExpected = function (bus) {
- return {
- uahb: +bus.uahb?.avg.toFixed(3),
- rahb: +(2.5).toFixed(3),
- lahb: +bus.lahb?.avg.toFixed(3),
- lbsa: +(1).toFixed(3),
- }
- }
-
- before(() => {
- timestampStub.returns(currentTimestemp);
- browsiRTD.setTimestamp();
- });
- it('should return undefined if bus is not defined', function () {
- expect(browsiUtils.getHbm(undefined)).to.equal(undefined);
- });
- it('should return metrics if bus is defined', function () {
- const bus = { uahb, lahb, rahb };
- expect(browsiUtils.getHbm(bus, currentTimestemp)).to.deep.equal({
- uahb: getExpected(bus).uahb,
- rahb: getExpected(bus).rahb,
- lahb: getExpected(bus).lahb,
- lbsa: getExpected(bus).lbsa
- });
- });
- it('should return metrics without lahb if its not defined', function () {
- const bus = { uahb, rahb };
- expect(browsiUtils.getHbm(bus, currentTimestemp)).to.deep.equal({
- uahb: getExpected(bus).uahb,
- rahb: getExpected(bus).rahb,
- lahb: undefined,
- lbsa: undefined
- });
- });
- it('should return metrics without rahb if its not defined', function () {
- const bus = { uahb, lahb };
- expect(browsiUtils.getHbm(bus, currentTimestemp)).to.deep.equal({
- uahb: getExpected(bus).uahb,
- rahb: undefined,
- lahb: getExpected(bus).lahb,
- lbsa: getExpected(bus).lbsa
- });
- });
- it('should return metrics without uahb if its not defined', function () {
- const bus = { lahb, rahb };
- expect(browsiUtils.getHbm(bus, currentTimestemp)).to.deep.equal({
- uahb: undefined,
- rahb: getExpected(bus).rahb,
- lahb: getExpected(bus).lahb,
- lbsa: getExpected(bus).lbsa
- });
- });
- it('should return metrics without rahb if timestamps are older than a week', function () {
- const bus = { uahb, lahb, rahb: { [twoWeekAgoTimestemp]: { sum: 25, smp: 10 } } };
- expect(browsiUtils.getHbm(bus, currentTimestemp)).to.deep.equal({
- uahb: getExpected(bus).uahb,
- rahb: undefined,
- lahb: getExpected(bus).lahb,
- lbsa: getExpected(bus).lbsa
- });
- });
- })
-});
diff --git a/test/spec/modules/bucksenseBidAdapter_spec.js b/test/spec/modules/bucksenseBidAdapter_spec.js
deleted file mode 100644
index 533dc2f01..000000000
--- a/test/spec/modules/bucksenseBidAdapter_spec.js
+++ /dev/null
@@ -1,145 +0,0 @@
-import {expect} from 'chai';
-import {spec} from 'modules/bucksenseBidAdapter.js';
-
-describe('Bucksense Adapter', function() {
- const BIDDER_CODE = 'bucksense';
- const BID_ID = '12345';
- const PLACE_ID = '1000';
-
- function getValidBidObject() {
- return {
- bidder: BIDDER_CODE,
- params: {
- placementId: PLACE_ID,
- }
- }
- };
-
- describe('isBidRequestValid', function() {
- var bid;
-
- beforeEach(function() {
- bid = getValidBidObject();
- });
-
- it('returns true when valid bid request is sent', function() {
- expect(spec.isBidRequestValid(bid)).to.be.true;
- });
-
- it('returns true when valid test bid request is sent', function() {
- bid.params['test'] = 1;
- expect(spec.isBidRequestValid(bid)).to.be.true;
- });
-
- it('returns false when params not set', function() {
- delete bid.params;
- expect(spec.isBidRequestValid(bid)).to.be.false;
- });
- });
-
- describe('buildRequests', function() {
- var bid, bidRequestObj;
-
- beforeEach(function() {
- bid = getValidBidObject();
- bidRequestObj = {
- 'bidderCode': 'bucksense',
- 'auctionId': '73540558-86cb-4eef-895f-bf99c5353bd7',
- 'bidderRequestId': '1feebcb5938c7e',
- 'bids': [
- {
- 'bidder': 'bucksense',
- 'params': {
- 'placementId': 1000
- },
- 'mediaTypes': {
- 'banner': {
- 'sizes': [ [ 300, 250 ], [ 300, 600 ] ]
- }
- },
- 'adUnitCode': 'test-div',
- 'transactionId': '52b3ed07-2a09-4f58-a426-75acc7602c96',
- 'sizes': [ [ 300, 250 ], [ 300, 600 ] ],
- 'bidId': '22aecdacdcd773',
- 'bidderRequestId': '1feebcb5938c7e',
- 'auctionId': '73540558-86cb-4eef-895f-bf99c5353bd7',
- 'src': 'client',
- 'bidRequestsCount': 1
- }
- ],
- 'auctionStart': 1557176022728,
- 'timeout': 1000,
- 'refererInfo': {
- 'referer': 'https://stefanod.hera.pe/prebid/?pbjs_debug=true',
- 'reachedTop': true,
- 'numIframes': 0,
- 'stack': [
- 'https://stefanod.hera.pe/prebid/?pbjs_debug=true'
- ]
- },
- 'start': 1557176022731
- };
- });
-
- it('should build a very basic request', function() {
- var request = spec.buildRequests([bid], bidRequestObj);
- expect(request[0].method).to.equal('POST');
- });
-
- it('bidRequest data', function () {
- var request = spec.buildRequests([bid], bidRequestObj);
- expect(request[0].data).to.exist;
- });
- });
-
- describe('interpretResponse', function() {
- var serverResponse;
- var serverRequest;
-
- beforeEach(function() {
- serverRequest = {
- 'method': 'POST',
- 'url': 'https://prebid.bksn.se/prebidjs/',
- 'data': {
- 'pub_id': 'prebid.org',
- 'pl_id': '1000',
- 'secure': 0,
- 'href': 'https://prebid.org/developers.html',
- 'bid_id': '27aaf8e96d9fd5',
- 'params': {
- 'placementId': '1000'
- },
- 'sizes': [ [ 300, 250 ], [ 300, 600 ] ]
- }
- };
-
- serverResponse = {
- body: {
- 'requestId': '',
- 'cpm': 0.3,
- 'width': 300,
- 'height': 250,
- 'ttl': 360,
- 'creativeId': 'creative002',
- 'currency': 'USD',
- 'netRevenue': false,
- 'ad': '
',
- 'meta': {
- 'advertiserDomains': ['http://www.bucksense.com/']
- }
- }
- };
- });
-
- it('should return an array of bid responses', function() {
- var responses = spec.interpretResponse(serverResponse, serverRequest);
- expect(responses).to.be.an('array').with.length(1);
- });
-
- it('should return an array of bid responses', function() {
- serverResponse = {};
- var responses = spec.interpretResponse(serverResponse, serverRequest);
- expect(responses).to.be.an('array').with.length(0);
- });
- });
-});
diff --git a/test/spec/modules/buzzoolaBidAdapter_spec.js b/test/spec/modules/buzzoolaBidAdapter_spec.js
deleted file mode 100644
index 5bb60cd12..000000000
--- a/test/spec/modules/buzzoolaBidAdapter_spec.js
+++ /dev/null
@@ -1,413 +0,0 @@
-import {expect} from 'chai';
-import {spec} from 'modules/buzzoolaBidAdapter.js';
-import {newBidder} from 'src/adapters/bidderFactory.js';
-import '../../../src/prebid.js';
-import {executeRenderer, Renderer} from '../../../src/Renderer.js';
-import {deepClone} from '../../../src/utils.js';
-
-const ENDPOINT = 'https://exchange.buzzoola.com/ssp/prebidjs';
-const RENDERER_SRC = 'https://tube.buzzoola.com/new/build/buzzlibrary.js';
-
-const INVALID_BIDS = [{
- 'bidder': 'buzzoola',
- 'mediaTypes': {'banner': {'sizes': [[240, 400], [300, 600]]}},
- 'sizes': [[240, 400], [300, 600]]
-}, {
- 'bidder': 'buzzoola',
- 'params': {'placementId': 417846},
- 'sizes': [[240, 400], [300, 600]]
-}, {
- 'bidder': 'buzzoola',
- 'mediaTypes': {
- 'video': {
- 'playerSize': [[640, 380]],
- 'mimes': ['video/mp4'],
- 'minduration': 1,
- 'maxduration': 2
- }
- }
-}, {
- 'bidder': 'buzzoola',
- 'params': {'placementId': 417845}
-}];
-
-const BANNER_BID = {
- 'bidder': 'buzzoola',
- 'params': {'placementId': 417846},
- 'mediaTypes': {'banner': {'sizes': [[240, 400], [300, 600]]}},
- 'sizes': [[240, 400], [300, 600]],
- 'bidId': '2a11641ada3c6a'
-};
-
-const BANNER_BID_REQUEST = {
- bidderCode: 'buzzoola',
- bids: [BANNER_BID]
-};
-
-const BANNER_RESPONSE = [{
- 'requestId': '2a11641ada3c6a',
- 'cpm': 5.583115,
- 'width': 240,
- 'height': 400,
- 'creativeId': '11773',
- 'dealId': '',
- 'currency': 'RUB',
- 'netRevenue': true,
- 'ttl': 10800,
- 'ad': '',
- 'mediaType': 'banner',
- 'meta': {
- 'advertiserDomains': [
- 'buzzoola.com'
- ]
- }
-}];
-
-const REQUIRED_BANNER_FIELDS = [
- 'requestId',
- 'cpm',
- 'width',
- 'height',
- 'ad',
- 'ttl',
- 'creativeId',
- 'netRevenue',
- 'currency',
- 'mediaType',
- 'meta'
-];
-
-const VIDEO_BID = {
- 'bidder': 'buzzoola',
- 'params': {'placementId': 417845},
- 'mediaTypes': {
- 'video': {
- 'context': 'instream',
- 'playerSize': [[640, 380]],
- 'mimes': ['video/mp4'],
- 'minduration': 1,
- 'maxduration': 2
- }
- },
- 'bidId': '325a54271dc40a'
-};
-
-const VIDEO_BID_REQUEST = {
- bidderCode: 'buzzoola',
- bids: [VIDEO_BID]
-};
-
-const VIDEO_RESPONSE = [{
- 'requestId': '325a54271dc40a',
- 'cpm': 5.528554074074074,
- 'width': 640,
- 'height': 480,
- 'creativeId': '11774',
- 'dealId': '',
- 'currency': 'RUB',
- 'netRevenue': true,
- 'ttl': 10800,
- 'ad': '{"crs":[{"advertiser_id":165,"title":"qa//PrebidJStestVideoURL","description":"qa//PrebidJStest","duration":0,"ya_id":"55038886","raw_content":"{\\"main_content\\": \\"https://tube.buzzoola.com/xstatic/o42/mcaug/2.mp4\\"}","content":{"main_content":"https://tube.buzzoola.com/xstatic/o42/mcaug/2.mp4"},"content_type":"video_url","sponsor_link":"","sponsor_name":"","overlay":"","overlay_start_after":0,"overlay_close_after":0,"action_button_title":"","tracking_url":{},"iframe_domains":[],"soc_share_url":"https://tube.buzzoola.com/share.html","player_show_skip_button_before_play":false,"player_show_skip_button_seconds":5,"player_show_title":true,"player_data_attributes":{"expandable":"default","overroll":"default"},"click_event_view":"default","share_panel_position":"left","auto_play":true,"logo_url":{},"share_buttons":["vkontakte","facebook","twitter","moimir","odnoklassniki","embed"],"player_show_panels":false,"thumbnail":"","tracking_js":{},"click_event_url":"https://exchange.buzzoola.com/event/f9382ceb-49c2-4683-50d8-5c516c53cd69/14795a96-6261-49dc-7241-207333ab1490/m7JVQI9Y7J35_gEDugNO2bIiP2qTqPKfuLrqqh_LoJu0tD6PoLEglMXUBzVpSg75c-unsaijXpIERGosa1adogXgqjDml4Pm/click/0/","vpaid_js_url":"https://tube.buzzoola.com/new/js/lib/vpaid_js_proxy.js","skip_clickthru":false,"landing_link_text":"","sound_enabled_by_default":false,"landing_link_position":"right","displayed_price":"","js_wrapper_url":"","enable_moat":false,"branding_template":"","event_url":"https://exchange.buzzoola.com/event/f9382ceb-49c2-4683-50d8-5c516c53cd69/14795a96-6261-49dc-7241-207333ab1490/m7JVQI9Y7J35_gEDugNO2bIiP2qTqPKfuLrqqh_LoJu0tD6PoLEglMXUBzVpSg75c-unsaijXpIERGosa1adogXgqjDml4Pm/","resend_event_url":"https://exchange.buzzoola.com/resend_event/f9382ceb-49c2-4683-50d8-5c516c53cd69/14795a96-6261-49dc-7241-207333ab1490/m7JVQI9Y7J35_gEDugNO2bIiP2qTqPKfuLrqqh_LoJu0tD6PoLEglMXUBzVpSg75c-unsaijXpIERGosa1adogXgqjDml4Pm/","creative_hash":"m7JVQI9Y7J35_gEDugNO2bIiP2qTqPKfuLrqqh_LoJu0tD6PoLEglMXUBzVpSg75c-unsaijXpIERGosa1adogXgqjDml4Pm","custom_html":"","custom_js":"","height":0,"width":0,"campaign_id":5758,"line_item_id":17319,"creative_id":11774,"extra":{"imp_id":"14795a96-6261-49dc-7241-207333ab1490","rtime":"2019-08-27 13:58:36"},"subcontent":"vast","auction_settings":{"price":"4.6158956756756755","currency":"RUB","event_name":"player_seen","time_slice":0},"hash_to_embed":"kbDH64c7yFYkSu0KCwSkoUD2bNHAnUTHBERqLGtWnaIF4Kow5peD5g","need_ad":false}],"tracking_urls":{"ctor":["https://www.tns-counter.ru/V13a****buzzola_com/ru/CP1251/tmsec=buzzola_total/1322650417245790778","https://www.tns-counter.ru/V13a****buzzoola_kz/ru/UTF-8/tmsec=buzzoola_video/5395765100939533275","https://buzzoolaru.solution.weborama.fr/fcgi-bin/dispatch.fcgi?a.A=ev&a.si=3071&a.te=37&a.aap=1&a.agi=862&a.evn=PrebidJS.test&g.ra=4581478478720298652","https://x01.aidata.io/0.gif?pid=BUZZOOLA&id=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://top-fwz1.mail.ru/counter?id=3026769","https://www.tns-counter.ru/V13a****buzzola_com/ru/UTF-8/tmsec=buzzola_inread/542059452789128996","https://dm.hybrid.ai/match?id=111&vid=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://px.adhigh.net/p/cm/buzzoola?u=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://ssp1.rtb.beeline.ru/userbind?src=buz&ssp_user_id=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://sync.upravel.com/image?source=buzzoola&id=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://relap.io/api/partners/bzcs.gif?uid=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://x.bidswitch.net/sync?ssp=sspicyads","https://inv-nets.admixer.net/adxcm.aspx?ssp=3C5173FC-CA30-4692-9116-009C19CB1BF9&rurl=%2F%2Fexchange.buzzoola.com%2Fcookiesync%2Fdsp%2Fadmixer-video%2F%24%24visitor_cookie%24%24","https://sync.datamind.ru/cookie/accepter?source=buzzoola&id=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://dmp.vihub.ru/match?sysid=buz&redir=no&uid=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://ad.adriver.ru/cgi-bin/rle.cgi?sid=1&ad=608223&bt=21&pid=2551979&bid=6150299&bn=6150299&rnd=1279444531737367663","https://reichelcormier.bid/point/?method=match&type=ssp&key=4677290772f9000878093d69c199bfba&id=3509&extUid=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://sync.republer.com/match?src=buzzoola&id=dbdb5b13-e719-4987-7f6a-a882322bbfce","https://sm.rtb.mts.ru/p?id=dbdb5b13-e719-4987-7f6a-a882322bbfce&ssp=buzzoola","https://cm.mgid.com/m?cdsp=371151&adu=https%3A%2F%2Fexchange.buzzoola.com%2Fcookiesync%2Fdsp%2Fmarketgid-native%2F%7Bmuidn%7D","https://dmp.gotechnology.io/dmp/syncsspdmp?sspid=122258"]},"tracking_js":{"ctor":["https://buzzoola.fraudscore.mobi/dooJ9sheeeDaZ3fe.js?s=268671&l=417845"]},"placement":{"placement_id":417845,"unit_type":"inread","unit_settings":{"align":"left","autoplay_enable_sound":false,"creatives_amount":1,"debug_mode":false,"expandable":"never","sound_control":"default","target":"","width":"100%"},"unit_settings_list":["width","sound_control","debug_mode","target","creatives_amount","expandable","container_height","align","height"]},"uuid":"dbdb5b13-e719-4987-7f6a-a882322bbfce","auction_id":"f9382ceb-49c2-4683-50d8-5c516c53cd69","env":"prod"}',
- 'vastUrl': 'https://exchange.buzzoola.com/prebid/adm/6cfa2ee1-f001-4fab-5582-a62eaee46205/m7JVQI9Y7J35_gEDugNO2bIiP2qTqPKfuLrqqh_LoJu0tD6PoLEglMXUBzVpSg75R6wziBhL0JAERGosa1adogXgqjDml4Pm/?auction_id=92702ce1-2328-4c7a-57aa-41c738e8bb75',
- 'mediaType': 'video',
- 'meta': {
- 'advertiserDomains': [
- 'buzzoola.com'
- ]
- }
-}];
-
-const RENDERER_DATA = {
- data: JSON.parse(VIDEO_RESPONSE[0].ad)
-};
-RENDERER_DATA.data.placement.unit_settings.width = '' + VIDEO_RESPONSE[0].width;
-RENDERER_DATA.data.placement.unit_settings.height = RENDERER_DATA.data.placement.unit_settings.container_height = '' + VIDEO_RESPONSE[0].height;
-
-const REQUIRED_VIDEO_FIELDS = [
- 'requestId',
- 'cpm',
- 'width',
- 'height',
- 'ad',
- 'ttl',
- 'creativeId',
- 'netRevenue',
- 'currency',
- 'vastUrl',
- 'mediaType',
- 'meta'
-];
-
-const NATIVE_BID = {
- 'bidder': 'buzzoola',
- 'params': {'placementId': 417845},
- 'mediaTypes': {
- 'native': {
- 'image': {
- 'required': true,
- 'sizes': [640, 134]
- },
- 'title': {
- 'required': true,
- 'len': 80
- },
- 'sponsoredBy': {
- 'required': true
- },
- 'clickUrl': {
- 'required': true
- },
- 'privacyLink': {
- 'required': false
- },
- 'body': {
- 'required': true
- },
- 'icon': {
- 'required': true,
- 'sizes': [50, 50]
- }
- }
- },
- 'bidId': '22a42cd3522c6f'
-};
-
-const NATIVE_BID_REQUEST = {
- bidderCode: 'buzzoola',
- bids: [NATIVE_BID]
-};
-
-const NATIVE_RESPONSE = [{
- 'requestId': '22a42cd3522c6f',
- 'cpm': 6.553015238095238,
- 'width': 600,
- 'height': 300,
- 'creativeId': '17970',
- 'dealId': '',
- 'currency': 'RUB',
- 'netRevenue': true,
- 'ttl': 10800,
- 'ad': 'https://tube.buzzoola.com/xstatic/o42/stoloto/6',
- 'mediaType': 'native',
- 'native': {
- 'body': 'В 1388-м тираже «Русского лото» джекпот',
- 'clickTrackers': [
- 'https://exchange.buzzoola.com/event/6cee890f-1878-4a37-46b3-0107b6c590ae/a1aedc5b-50f2-4a7c-6d24-e235bb1f87ed/m7JVQI9Y7J35_gEDugNO2bIiP2qTqPKfuLrqqh_LoJu0tD6PoLEglMXUBzVpSg75c-unsaijXpJwP8cy-zNH8GX-_nWFkILh/click/'
- ],
- 'clickUrl': 'https://ad.doubleclick.net/ddm/trackclk/N250204.3446512BUZZOOLA/B25801892.303578321;dc_trk_aid=496248119;dc_trk_cid=151207455;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;tfua=;ltd=?https://stoloto.onelink.me/mEJM?pid=Buzzoola_mb4&c=rl_10_05_2021&is_retargeting=true&af_ios_url=https%3A%2F%2Fapps.apple.com%2Fru%2Fapp%2F%25D1%2581%25D1%2582%25D0%25BE%25D0%25BB%25D0%25BE%25D1%2582%25D0%25BE-%25D1%2583-%25D0%25BD%25D0%25B0%25D1%2581-%25D0%25B2%25D1%258B%25D0%25B8%25D0%25B3%25D1%2580%25D1%258B%25D0%25B2%25D0%25B0%25D1%258E%25D1%2582%2Fid579961527&af_android_url=https%3A%2F%2Fgalaxystore.samsung.com%2Fdetail%2Fru.stoloto.mobile&af_dp=stolotoone%3A%2F%2Fgames&af_web_dp=https%3A%2F%2Fwww.stoloto.ru%2Fruslotto%2Fgame%3Flastdraw%3Fad%3Dbuzzoola_app_dx_rl_10_05_2021%26utm_source%3Dbuzzoola_app_dx%26utm_medium%3Dcpm%26utm_campaign%3Drl_10_05_2021%26utm_content%3Dbuzzoola_app_dx_mob_native_ios_mb4%26utm_term%3D__6ple2-9znjyg_',
- 'icon': {
- 'height': '100',
- 'url': 'https://tube.buzzoola.com/xstatic/o42/stoloto/logo3.png',
- 'width': '100'
- },
- 'image': {
- 'height': '450',
- 'url': 'https://tube.buzzoola.com/xstatic/o42/stoloto/6/16x9.png',
- 'width': '800'
- },
- 'impressionTrackers': [
- 'https://exchange.buzzoola.com/event/6cee890f-1878-4a37-46b3-0107b6c590ae/a1aedc5b-50f2-4a7c-6d24-e235bb1f87ed/m7JVQI9Y7J35_gEDugNO2bIiP2qTqPKfuLrqqh_LoJu0tD6PoLEglMXUBzVpSg75c-unsaijXpJwP8cy-zNH8GX-_nWFkILh/ctor/',
- 'https://exchange.buzzoola.com/event/6cee890f-1878-4a37-46b3-0107b6c590ae/a1aedc5b-50f2-4a7c-6d24-e235bb1f87ed/m7JVQI9Y7J35_gEDugNO2bIiP2qTqPKfuLrqqh_LoJu0tD6PoLEglMXUBzVpSg75c-unsaijXpJwP8cy-zNH8GX-_nWFkILh/impression/?price=${AUCTION_PRICE}&cur=${AUCTION_CURRENCY}',
- 'https://exchange.buzzoola.com/event/6cee890f-1878-4a37-46b3-0107b6c590ae/a1aedc5b-50f2-4a7c-6d24-e235bb1f87ed/m7JVQI9Y7J35_gEDugNO2bIiP2qTqPKfuLrqqh_LoJu0tD6PoLEglMXUBzVpSg75c-unsaijXpJwP8cy-zNH8GX-_nWFkILh/player_seen/',
- 'https://cr.frontend.weborama.fr/cr?key=mailru&url=https%3A%2F%2Fad.mail.ru%2Fcm.gif%3Fp%3D68%26id%3D%7BWEBO_CID%7D'
- ],
- 'sponsoredBy': 'Buzzoola',
- 'title': 'Test PrebidJS Native'
- },
- 'meta': {
- 'advertiserDomains': [
- 'buzzoola.com'
- ]
- }
-}];
-
-const REQUIRED_NATIVE_FIELDS = [
- 'requestId',
- 'cpm',
- 'width',
- 'height',
- 'ad',
- 'native',
- 'ttl',
- 'creativeId',
- 'netRevenue',
- 'currency',
- 'mediaType',
- 'meta'
-];
-
-describe('buzzoolaBidAdapter', () => {
- const adapter = newBidder(spec);
-
- describe('inherited functions', () => {
- it('exists and is a function', () => {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('isBidRequestValid', () => {
- it('should return true when required params found', () => {
- expect(spec.isBidRequestValid(VIDEO_BID)).to.be.true;
- });
-
- it('should return false when required params are not passed', () => {
- INVALID_BIDS.forEach(bid => {
- expect(spec.isBidRequestValid(bid)).to.be.false;
- });
- });
- });
-
- describe('buildRequests', () => {
- const videoBidRequests = [VIDEO_BID];
- const bannerBidRequests = [BANNER_BID];
- const nativeBidRequests = [NATIVE_BID];
-
- const bannerRequest = spec.buildRequests(bannerBidRequests, BANNER_BID_REQUEST);
- const nativeRequest = spec.buildRequests(nativeBidRequests, NATIVE_BID_REQUEST);
- const videoRequest = spec.buildRequests(videoBidRequests, VIDEO_BID_REQUEST);
-
- it('sends bid request to ENDPOINT via POST', () => {
- expect(videoRequest.method).to.equal('POST');
- expect(bannerRequest.method).to.equal('POST');
- expect(nativeRequest.method).to.equal('POST');
- });
-
- it('sends bid request to correct ENDPOINT', () => {
- expect(videoRequest.url).to.equal(ENDPOINT);
- expect(bannerRequest.url).to.equal(ENDPOINT);
- expect(nativeRequest.url).to.equal(ENDPOINT);
- });
-
- it('sends correct video bid parameters', () => {
- expect(videoRequest.data).to.deep.equal(VIDEO_BID_REQUEST);
- });
-
- it('sends correct banner bid parameters', () => {
- expect(bannerRequest.data).to.deep.equal(BANNER_BID_REQUEST);
- });
-
- it('sends correct native bid parameters', () => {
- expect(nativeRequest.data).to.deep.equal(NATIVE_BID_REQUEST);
- });
- });
-
- describe('interpretResponse', () => {
- const noBidServerResponse = [];
- const emptyResponse = '';
-
- function nobidServerResponseCheck(request, response = noBidServerResponse) {
- const noBidResult = spec.interpretResponse({body: response}, {data: request});
-
- expect(noBidResult.length).to.equal(0);
- }
-
- function bidServerResponseCheck(response, request, fields) {
- const result = spec.interpretResponse({body: response}, {data: request});
-
- expect(result).to.deep.equal(response);
- result.forEach(bid => {
- fields.forEach(field => {
- expect(bid).to.have.own.property(field);
- })
- });
- }
-
- it('handles video nobid responses', () => {
- nobidServerResponseCheck(VIDEO_BID_REQUEST);
- });
-
- it('handles banner nobid responses', () => {
- nobidServerResponseCheck(BANNER_BID_REQUEST);
- });
-
- it('handles native nobid responses', () => {
- nobidServerResponseCheck(NATIVE_BID_REQUEST);
- });
-
- it('handles video empty responses', () => {
- nobidServerResponseCheck(VIDEO_BID_REQUEST, emptyResponse);
- });
-
- it('handles banner empty responses', () => {
- nobidServerResponseCheck(BANNER_BID_REQUEST, emptyResponse);
- });
-
- it('handles native empty responses', () => {
- nobidServerResponseCheck(NATIVE_BID_REQUEST, emptyResponse);
- });
-
- it('should get correct video bid response', () => {
- bidServerResponseCheck(VIDEO_RESPONSE, VIDEO_BID_REQUEST, REQUIRED_VIDEO_FIELDS);
- });
-
- it('should get correct banner bid response', () => {
- bidServerResponseCheck(BANNER_RESPONSE, BANNER_BID_REQUEST, REQUIRED_BANNER_FIELDS);
- });
-
- it('should get correct native bid response', () => {
- bidServerResponseCheck(NATIVE_RESPONSE, NATIVE_BID_REQUEST, REQUIRED_NATIVE_FIELDS);
- });
- });
-
- describe('outstream renderer', () => {
- let result;
- let renderer;
-
- before(() => {
- const adContainer = document.createElement('div');
- adContainer.id = 'adUnitCode';
- document.body.appendChild(adContainer);
-
- const outstreamVideoBid = deepClone(VIDEO_BID);
- outstreamVideoBid.mediaTypes.video.context = 'outstream';
-
- const outstreamVideoRequest = deepClone(VIDEO_BID_REQUEST);
- outstreamVideoRequest.bids = [outstreamVideoBid];
-
- const scriptElement = document.createElement('div');
-
- const scriptStub = sinon.stub(document, 'createElement');
- scriptStub.withArgs('script').returns(scriptElement);
-
- result = spec.interpretResponse({body: VIDEO_RESPONSE}, {data: outstreamVideoRequest})[0];
- renderer = result.renderer;
-
- result.adUnitCode = 'adUnitCode';
-
- if (scriptElement.onload) {
- scriptElement.onload();
- }
-
- scriptStub.restore();
- });
-
- it('should add renderer for outstream video', () => {
- expect(result).to.have.own.property('renderer');
- });
-
- it('should be instance of Renderer', () => {
- expect(renderer).to.be.instanceof(Renderer);
- });
-
- it('should have valid src', () => {
- expect(renderer.url).to.equal(RENDERER_SRC);
- });
-
- it('should create player instance', () => {
- window.Buzzoola = {
- Core: {
- install: () => {}
- }
- };
- const spy = sinon.spy(window.Buzzoola.Core, 'install');
- executeRenderer(renderer, result);
- renderer.callback();
- expect(spy.called).to.be.true;
-
- const spyCall = spy.getCall(0);
-
- expect(spyCall.args[0]).to.be.instanceof(Element);
- expect(spyCall.args[1]).to.deep.equal(RENDERER_DATA);
- });
- });
-});
diff --git a/test/spec/modules/byDataAnalyticsAdapter_spec.js b/test/spec/modules/byDataAnalyticsAdapter_spec.js
deleted file mode 100644
index 862a0ee79..000000000
--- a/test/spec/modules/byDataAnalyticsAdapter_spec.js
+++ /dev/null
@@ -1,192 +0,0 @@
-import ascAdapter from 'modules/byDataAnalyticsAdapter';
-import { expect } from 'chai';
-import {EVENTS} from 'src/constants.js';
-
-const adapterManager = require('src/adapterManager').default;
-const events = require('src/events');
-const auctionId = 'b70ef967-5c5b-4602-831e-f2cf16e59af2';
-const initOptions = {
- clientId: 'asc00000',
- logFrequency: 1,
-};
-const userData = {
- 'uid': '271a8-2b86-f4a4-f59bc',
- 'cid': 'asc00000',
- 'pid': 'www.letsrun.com',
- 'os': 'Macintosh',
- 'osv': 10.157,
- 'br': 'Chrome',
- 'brv': 103,
- 'ss': {
- 'width': 1792,
- 'height': 1120
- },
- 'de': 'Desktop',
- 'tz': 'Asia/Calcutta'
-};
-const bidTimeoutArgs = [{
- auctionId,
- bidId: '12e90cb5ddc5dea',
- bidder: 'appnexus',
- adUnitCode: 'div-gpt-ad-mrec1'
-}];
-const noBidArgs = {
- adUnitCode: 'div-gpt-ad-mrec1',
- auctionId,
- bidId: '14480e9832f2d2b',
- bidder: 'appnexus',
- bidderRequestId: '13b87b6c20d3636',
- mediaTypes: {banner: {sizes: [[300, 250], [250, 250]]}},
- sizes: [[300, 250], [250, 250]],
- src: 'client',
- transactionId: 'c8ee3914-1ee0-4ce6-9126-748d5692188c'
-}
-const bidWonArgs = {
- auctionId,
- adUnitCode: 'div-gpt-ad-mrec1',
- size: '300x250',
- requestId: '15c86b6c10d3746',
- bidder: 'appnexus',
- timeToRespond: 114,
- currency: 'USD',
- mediaType: 'display',
- cpm: 0.50
-}
-
-const auctionEndArgs = {
- adUnitCodes: ['div-gpt-ad-mrec1'],
- adUnits: [{
- code: 'div-gpt-ad-mrec1',
- mediaTypes: {banner: {sizes: [[300, 250], [250, 250]]}},
- sizes: [[300, 250], [250, 250]],
- bids: [{bidder: 'appnexus', params: {placementId: '19305195'}}],
- transactionId: 'c8ee3914-1ee0-4ce6-9126-748d5692188c'
- }],
- auctionEnd: 1627973487504,
- auctionId,
- auctionStatus: 'completed',
- timestamp: 1627973484504,
- bidsReceived: [],
- bidderRequests: [{
- auctionId,
- auctionStart: 1627973484504,
- bidderCode: 'appnexus',
- bidderRequestId: '13b87b6c20d3636',
- bids: [
- {
- adUnitCode: 'div-gpt-ad-mrec1',
- auctionId,
- bidId: '14480e9832f2d2b',
- bidder: 'appnexus',
- bidderRequestId: '13b87b6c20d3636',
- src: 'client',
- mediaTypes: {banner: {sizes: [[300, 250], [250, 250]]}},
- sizes: [[300, 250], [250, 250]],
- transactionId: 'c8ee3914-1ee0-4ce6-9126-748d5692188c'
- }
- ]
- }]
-}
-const expectedDataArgs = {
- visitor_data: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiIyNzFhOC0yYjg2LWY0YTQtZjU5YmMiLCJjaWQiOiJhc2MwMDAwMCIsInBpZCI6Ind3dy5sZXRzcnVuLmNvbSIsIm9zIjoiTWFjaW50b3NoIiwib3N2IjoxMC4xNTcsImJyIjoiQ2hyb21lIiwiYnJ2IjoxMDMsInNzIjp7IndpZHRoIjoxNzkyLCJoZWlnaHQiOjExMjB9LCJkZSI6IkRlc2t0b3AiLCJ0eiI6IkFzaWEvQ2FsY3V0dGEifQ.Oj3qnh--t06XO-foVmrMJCGqFfOBed09A-f7LZX5rtfBf4w1_RNRZ4F3on4TMPLonSa7GgzbcEfJS9G_amnleQ',
- aid: auctionId,
- as: 1627973484504,
- auctionData: [ {
- au: 'div-gpt-ad-mrec1',
- auc: 'div-gpt-ad-mrec1',
- aus: '300x250',
- bidadv: 'appnexus',
- bid: '14480e9832f2d2b',
- inb: 1,
- ito: 0,
- ipwb: 0,
- iwb: 0,
- mt: 'display',
- }, {
- au: 'div-gpt-ad-mrec1',
- auc: 'div-gpt-ad-mrec1',
- aus: '250x250',
- bidadv: 'appnexus',
- bid: '14480e9832f2d2b',
- inb: 1,
- ito: 0,
- ipwb: 0,
- iwb: 0,
- mt: 'display',
- }]
-}
-const expectedBidWonArgs = {
- visitor_data: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiIyNzFhOC0yYjg2LWY0YTQtZjU5YmMiLCJjaWQiOiJhc2MwMDAwMCIsInBpZCI6Ind3dy5sZXRzcnVuLmNvbSIsIm9zIjoiTWFjaW50b3NoIiwib3N2IjoxMC4xNTcsImJyIjoiQ2hyb21lIiwiYnJ2IjoxMDMsInNzIjp7IndpZHRoIjoxNzkyLCJoZWlnaHQiOjExMjB9LCJkZSI6IkRlc2t0b3AiLCJ0eiI6IkFzaWEvQ2FsY3V0dGEifQ.Oj3qnh--t06XO-foVmrMJCGqFfOBed09A-f7LZX5rtfBf4w1_RNRZ4F3on4TMPLonSa7GgzbcEfJS9G_amnleQ',
- aid: auctionId,
- as: '',
- auctionData: [{
- au: 'div-gpt-ad-mrec1',
- auc: 'div-gpt-ad-mrec1',
- aus: '300x250',
- bid: '15c86b6c10d3746',
- bidadv: 'appnexus',
- br_pb_mg: 0.50,
- br_tr: 114,
- bradv: 'appnexus',
- brid: '15c86b6c10d3746',
- brs: '300x250',
- cur: 'USD',
- inb: 0,
- ito: 0,
- ipwb: 1,
- iwb: 1,
- mt: 'display',
- }]
-}
-
-describe('byData Analytics Adapter ', () => {
- beforeEach(() => {
- sinon.stub(events, 'getEvents').returns([]);
- });
- afterEach(() => {
- events.getEvents.restore();
- });
-
- describe('enableAnalytics ', function () {
- beforeEach(() => {
- sinon.spy(ascAdapter, 'track');
- });
- afterEach(() => {
- ascAdapter.disableAnalytics();
- ascAdapter.track.restore();
- });
- it('should init with correct options', function () {
- ascAdapter.enableAnalytics(initOptions)
- // Step 1: Initialize adapter
- adapterManager.enableAnalytics({
- provider: 'bydata',
- options: initOptions
- });
- expect(ascAdapter.initOptions).to.have.property('clientId', 'asc00000');
- expect(ascAdapter.initOptions).to.have.property('logFrequency', 1);
- });
- });
-
- describe('track-events', function () {
- before(() => {
- ascAdapter.enableAnalytics(initOptions)
- // Step 1: Initialize adapter
- adapterManager.enableAnalytics({
- provider: 'bydata',
- options: initOptions
- });
- });
- it('sends and formatted auction data ', function () {
- events.emit(EVENTS.BID_TIMEOUT, bidTimeoutArgs);
- events.emit(EVENTS.NO_BID, noBidArgs);
- events.emit(EVENTS.BID_WON, bidWonArgs)
- var userToken = ascAdapter.getVisitorData(userData);
- var newAuData = ascAdapter.dataProcess(auctionEndArgs);
- var newBwData = ascAdapter.getBidWonData(bidWonArgs);
- newAuData['visitor_data'] = userToken;
- newBwData['visitor_data'] = userToken;
- expect(newAuData).to.deep.equal(expectedDataArgs);
- expect(newBwData).to.deep.equal(expectedBidWonArgs);
- });
- });
-});
diff --git a/test/spec/modules/c1xBidAdapter_spec.js b/test/spec/modules/c1xBidAdapter_spec.js
deleted file mode 100644
index a325e4377..000000000
--- a/test/spec/modules/c1xBidAdapter_spec.js
+++ /dev/null
@@ -1,189 +0,0 @@
-import { expect } from 'chai';
-import { newBidder } from 'src/adapters/bidderFactory';
-import { c1xAdapter } from '../../../modules/c1xBidAdapter.js';
-
-const ENDPOINT = 'https://hb-stg.c1exchange.com/ht';
-const BIDDER_CODE = 'c1x';
-
-describe('C1XAdapter', () => {
- const adapter = newBidder(c1xAdapter);
- describe('inherited functions', () => {
- it('exists and is a function', () => {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
- describe('isBidRequestValid', () => {
- const bid = {
- 'bidder': BIDDER_CODE,
- 'adUnitCode': 'adunit-code',
- 'sizes': [[300, 250], [300, 600]],
- 'params': {
- 'placementId': 'div-gpt-ad-1654594619717-0'
- }
- };
- it('should return true when required params found', function () {
- expect(c1xAdapter.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should return false when placementId not passed correctly', function () {
- bid.params.placementId = undefined;
- expect(c1xAdapter.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return false when require params are not passed', function () {
- const invalidBid = Object.assign({}, bid);
- invalidBid.params = {};
- expect(c1xAdapter.isBidRequestValid(invalidBid)).to.equal(false);
- });
- });
- describe('buildRequests', () => {
- const bidRequests = [
- {
- 'bidder': BIDDER_CODE,
- 'params': {
- 'placementId': 'div-gpt-ad-1654594619717-0',
- 'dealId': '1233'
- },
- 'mediaTypes': {
- 'banner': {
- 'sizes': [
- [300, 250], [300, 600]
- ]
- }
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [[300, 250], [300, 600]],
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- }
- ];
- const parseRequest = (data) => {
- const parsedData = '{"' + data.replace(/=|&/g, (foundChar) => {
- if (foundChar === '=') return '":"';
- else if (foundChar === '&') return '","';
- }) + '"}'
- return parsedData;
- };
- it('sends bid request to ENDPOINT via GET', () => {
- const request = c1xAdapter.buildRequests(bidRequests);
- expect(request[0].url).to.contain(ENDPOINT);
- expect(request[0].method).to.equal('GET');
- });
- it('should generate correct bid Id tag', () => {
- const request = c1xAdapter.buildRequests(bidRequests)[0];
- expect(request.bids[0].adUnitCode).to.equal('adunit-code');
- expect(request.bids[0].bidId).to.equal('30b31c1838de1e');
- });
- it('should convert params to proper form and attach to request', () => {
- const request = c1xAdapter.buildRequests(bidRequests)[0];
- const originalPayload = parseRequest(request.data);
- const payloadObj = JSON.parse(originalPayload);
- expect(payloadObj.adunits).to.equal('1');
- expect(payloadObj.a1s).to.equal('300x250,300x600');
- expect(payloadObj.a1).to.equal('adunit-code');
- expect(payloadObj.a1d).to.equal('1233');
- });
- it('should convert floor price to proper form and attach to request', () => {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- 'params': {
- 'placementId': 'div-gpt-ad-1654594619717-0',
- 'dealId': '1233',
- 'floorPriceMap': {
- '300x250': 4.35
- }
- }
- });
- const request = c1xAdapter.buildRequests([bidRequest])[0];
- const originalPayload = parseRequest(request.data);
- const payloadObj = JSON.parse(originalPayload);
- expect(payloadObj.a1p).to.equal('4.35');
- });
- it('should convert pageurl to proper form and attach to request', () => {
- const bidRequest = Object.assign({},
- bidRequests[0],
- {
- 'params': {
- 'placementId': 'div-gpt-ad-1654594619717-0',
- 'dealId': '1233',
- 'pageurl': 'http://c1exchange.com/'
- }
- });
-
- const bidderRequest = {
- 'bidderCode': 'c1x'
- }
- bidderRequest.bids = bidRequests;
- const request = c1xAdapter.buildRequests([bidRequest], bidderRequest)[0];
- const originalPayload = parseRequest(request.data);
- const payloadObj = JSON.parse(originalPayload);
- expect(payloadObj.pageurl).to.equal('http://c1exchange.com/');
- });
-
- it('should convert GDPR Consent to proper form and attach to request', () => {
- const consentString = 'BOP2gFWOQIFovABABAENBGAAAAAAMw';
- const bidderRequest = {
- 'bidderCode': 'c1x',
- 'gdprConsent': {
- 'consentString': consentString,
- 'gdprApplies': true
- }
- }
- bidderRequest.bids = bidRequests;
-
- const request = c1xAdapter.buildRequests(bidRequests, bidderRequest)[0];
- const originalPayload = parseRequest(request.data);
- const payloadObj = JSON.parse(originalPayload);
- expect(payloadObj['consent_string']).to.equal('BOP2gFWOQIFovABABAENBGAAAAAAMw');
- expect(payloadObj['consent_required']).to.equal('true');
- });
- });
-
- describe('interpretResponse', () => {
- const response = {
- 'bid': true,
- 'cpm': 1.5,
- 'ad': '',
- 'width': 300,
- 'height': 250,
- 'crid': '8888',
- 'adId': 'c1x-test',
- 'bidType': 'GROSS_BID'
- };
- it('should get correct bid response', () => {
- const expectedResponse = [
- {
- width: 300,
- height: 250,
- cpm: 1.5,
- ad: '',
- creativeId: '8888',
- currency: 'USD',
- ttl: 300,
- netRevenue: false,
- requestId: 'yyyy'
- }
- ];
- const bidderRequest = {};
- bidderRequest.bids = [
- {
- adUnitCode: 'c1x-test',
- bidId: 'yyyy'
- }
- ];
- const result = c1xAdapter.interpretResponse({ body: [response] }, bidderRequest);
- expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0]));
- });
- it('handles nobid responses', () => {
- const response = {
- bid: false,
- adId: 'c1x-test'
- };
- const bidderRequest = {};
- const result = c1xAdapter.interpretResponse({ body: [response] }, bidderRequest);
- expect(result.length).to.equal(0);
- });
- });
-});
diff --git a/test/spec/modules/cadent_aperture_mxBidAdapter_spec.js b/test/spec/modules/cadent_aperture_mxBidAdapter_spec.js
deleted file mode 100644
index de33d5ff6..000000000
--- a/test/spec/modules/cadent_aperture_mxBidAdapter_spec.js
+++ /dev/null
@@ -1,871 +0,0 @@
-import * as utils from 'src/utils.js';
-
-import { expect } from 'chai';
-import { newBidder } from 'src/adapters/bidderFactory.js';
-import { spec } from 'modules/cadent_aperture_mxBidAdapter.js';
-
-describe('cadent_aperture_mx Adapter', function () {
- describe('callBids', function () {
- const adapter = newBidder(spec);
- it('exists and is a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('isBidRequestValid', function () {
- describe('banner request validity', function () {
- const bid = {
- 'bidder': 'cadent_aperture_mx',
- 'params': {
- 'tagid': '25251'
- },
- 'mediaTypes': {
- 'banner': {
- 'sizes': [[300, 250]]
- }
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [
- [300, 250],
- [300, 600]
- ],
- 'bidId': '30b31c2501de1e',
- 'bidderRequestId': '22edbae3120bf6',
- 'auctionId': '1d1a01234a475'
- };
- const badBid = {
- 'bidder': 'cadent_aperture_mx',
- 'params': {
- 'tagid': '25251'
- },
- 'mediaTypes': {
- 'banner': {
- }
- },
- 'adUnitCode': 'adunit-code',
- 'bidId': '30b31c2501de1e',
- 'bidderRequestId': '22edbae3120bf6',
- 'auctionId': '1d1a01234a475'
- };
- const noBid = {};
-
- it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- expect(spec.isBidRequestValid(badBid)).to.equal(false);
- expect(spec.isBidRequestValid(noBid)).to.equal(false);
- });
- });
-
- describe('video request validity', function () {
- const bid = {
- 'bidder': 'cadent_aperture_mx',
- 'params': {
- 'tagid': '25251',
- 'video': {}
- },
- 'mediaTypes': {
- 'video': {
- 'context': 'instream',
- 'playerSize': [640, 480]
- }
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [
- [300, 250],
- [300, 600]
- ],
- 'bidId': '30b31c2501de1e',
- 'bidderRequestId': '22edbae3120bf6',
- 'auctionId': '1d1a01234a475'
- };
- const noInstreamBid = {
- 'bidder': 'cadent_aperture_mx',
- 'params': {
- 'tagid': '25251',
- 'video': {
- 'protocols': [1, 7]
- }
- },
- 'mediaTypes': {
- 'video': {
- 'context': 'something_random'
- }
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [
- [300, 250],
- [300, 600]
- ],
- 'bidId': '30b31c2501de1e',
- 'bidderRequestId': '22edbae3120bf6',
- 'auctionId': '1d1a01234a475'
- };
-
- const outstreamBid = {
- 'bidder': 'cadent_aperture_mx',
- 'params': {
- 'tagid': '25251',
- 'video': {}
- },
- 'mediaTypes': {
- 'video': {
- 'context': 'outstream',
- 'playerSize': [640, 480]
- }
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [
- [300, 250],
- [300, 600]
- ],
- 'bidId': '30b31c2501de1e',
- 'bidderRequestId': '22edbae3120bf6',
- 'auctionId': '1d1a01234a475'
- };
-
- it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- expect(spec.isBidRequestValid(noInstreamBid)).to.equal(false);
- expect(spec.isBidRequestValid(outstreamBid)).to.equal(true);
- });
-
- it('should contain tagid param', function () {
- expect(spec.isBidRequestValid({
- bidder: 'cadent_aperture_mx',
- params: {},
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
- }
- })).to.equal(false);
- expect(spec.isBidRequestValid({
- bidder: 'cadent_aperture_mx',
- params: {
- tagid: ''
- },
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
- }
- })).to.equal(false);
- expect(spec.isBidRequestValid({
- bidder: 'cadent_aperture_mx',
- params: {
- tagid: '123'
- },
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
- }
- })).to.equal(true);
- });
- });
- });
-
- describe('buildRequests', function () {
- const bidderRequest = {
- 'bidderCode': 'cadent_aperture_mx',
- 'auctionId': 'e19f1eff-8b27-42a6-888d-9674e5a6130c',
- 'bidderRequestId': '22edbae3120bf6',
- 'timeout': 1500,
- 'refererInfo': {
- 'numIframes': 0,
- 'reachedTop': true,
- 'page': 'https://example.com/index.html?pbjs_debug=true',
- 'domain': 'example.com',
- 'ref': 'https://referrer.com'
- },
- 'bids': [{
- 'bidder': 'cadent_aperture_mx',
- 'params': {
- 'tagid': '25251'
- },
- 'adUnitCode': 'adunit-code',
- 'mediaTypes': {
- 'banner': {
- 'sizes': [
- [300, 250],
- [300, 600]
- ]
- }
- },
- 'sizes': [
- [300, 250],
- [300, 600]
- ],
- 'bidId': '30b31c2501de1e',
- 'auctionId': 'e19f1eff-8b27-42a6-888d-9674e5a6130c',
- 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec',
- 'ortb2Imp': {
- 'ext': {
- 'tid': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ed',
- },
- },
- }]
- };
- let request = spec.buildRequests(bidderRequest.bids, bidderRequest);
-
- describe('non-gpp tests', function() {
- it('sends bid request to ENDPOINT via POST', function () {
- expect(request.method).to.equal('POST');
- });
-
- it('contains the correct options', function () {
- expect(request.options.withCredentials).to.equal(true);
- });
-
- it('contains a properly formatted endpoint url', function () {
- const url = request.url.split('?');
- const queryParams = url[1].split('&');
- expect(queryParams[0]).to.match(new RegExp('^t=\d*', 'g'));
- expect(queryParams[1]).to.match(new RegExp('^ts=\d*', 'g'));
- });
-
- it('builds bidfloor value from bid param when getFloor function does not exist', function () {
- const bidRequestWithFloor = utils.deepClone(bidderRequest.bids);
- bidRequestWithFloor[0].params.bidfloor = 1;
- const requestWithFloor = spec.buildRequests(bidRequestWithFloor, bidderRequest);
- const data = JSON.parse(requestWithFloor.data);
- expect(data.imp[0].bidfloor).to.equal(bidRequestWithFloor[0].params.bidfloor);
- });
-
- it('builds bidfloor value from getFloor function when it exists', function () {
- const floorResponse = { currency: 'USD', floor: 3 };
- const bidRequestWithGetFloor = utils.deepClone(bidderRequest.bids);
- bidRequestWithGetFloor[0].getFloor = () => floorResponse;
- const requestWithGetFloor = spec.buildRequests(bidRequestWithGetFloor, bidderRequest);
- const data = JSON.parse(requestWithGetFloor.data);
- expect(data.imp[0].bidfloor).to.equal(3);
- });
-
- it('builds bidfloor value from getFloor when both floor and getFloor function exists', function () {
- const floorResponse = { currency: 'USD', floor: 3 };
- const bidRequestWithBothFloors = utils.deepClone(bidderRequest.bids);
- bidRequestWithBothFloors[0].params.bidfloor = 1;
- bidRequestWithBothFloors[0].getFloor = () => floorResponse;
- const requestWithBothFloors = spec.buildRequests(bidRequestWithBothFloors, bidderRequest);
- const data = JSON.parse(requestWithBothFloors.data);
- expect(data.imp[0].bidfloor).to.equal(3);
- });
-
- it('empty bidfloor value when floor and getFloor is not defined', function () {
- const bidRequestWithoutFloor = utils.deepClone(bidderRequest.bids);
- const requestWithoutFloor = spec.buildRequests(bidRequestWithoutFloor, bidderRequest);
- const data = JSON.parse(requestWithoutFloor.data);
- expect(data.imp[0].bidfloor).to.not.exist;
- });
-
- it('builds request properly', function () {
- const data = JSON.parse(request.data);
- expect(Array.isArray(data.imp)).to.equal(true);
- expect(data.id).to.equal(bidderRequest.auctionId);
- expect(data.imp.length).to.equal(1);
- expect(data.imp[0].id).to.equal('30b31c2501de1e');
- expect(data.imp[0].tid).to.equal('d7b773de-ceaa-484d-89ca-d9f51b8d61ed');
- expect(data.imp[0].tagid).to.equal('25251');
- expect(data.imp[0].secure).to.equal(0);
- expect(data.imp[0].vastXml).to.equal(undefined);
- });
-
- it('populates id even when auctionId is not available', function () {
- // addressing https://github.com/prebid/Prebid.js/issues/9781
- bidderRequest.auctionId = null;
- request = spec.buildRequests(bidderRequest.bids, bidderRequest);
-
- const data = JSON.parse(request.data);
- expect(data.id).not.to.be.null;
- expect(data.id).not.to.equal(bidderRequest.auctionId);
- });
-
- it('properly sends site information and protocol', function () {
- request = spec.buildRequests(bidderRequest.bids, bidderRequest);
- request = JSON.parse(request.data);
- expect(request.site).to.have.property('domain', 'example.com');
- expect(request.site).to.have.property('page', 'https://example.com/index.html?pbjs_debug=true');
- expect(request.site).to.have.property('ref', 'https://referrer.com');
- });
-
- it('builds correctly formatted request banner object', function () {
- const bidRequestWithBanner = utils.deepClone(bidderRequest.bids);
- const request = spec.buildRequests(bidRequestWithBanner, bidderRequest);
- const data = JSON.parse(request.data);
- expect(data.imp[0].video).to.equal(undefined);
- expect(data.imp[0].banner).to.exist.and.to.be.a('object');
- expect(data.imp[0].banner.w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][0]);
- expect(data.imp[0].banner.h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][1]);
- expect(data.imp[0].banner.format[0].w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][0]);
- expect(data.imp[0].banner.format[0].h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][1]);
- expect(data.imp[0].banner.format[1].w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[1][0]);
- expect(data.imp[0].banner.format[1].h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[1][1]);
- });
-
- it('builds correctly formatted request video object for instream', function () {
- const bidRequestWithVideo = utils.deepClone(bidderRequest.bids);
- bidRequestWithVideo[0].mediaTypes = {
- video: {
- context: 'instream',
- playerSize: [[640, 480]]
- },
- };
- bidRequestWithVideo[0].params.video = {};
- const request = spec.buildRequests(bidRequestWithVideo, bidderRequest);
- const data = JSON.parse(request.data);
- expect(data.imp[0].video).to.exist.and.to.be.a('object');
- expect(data.imp[0].video.w).to.equal(bidRequestWithVideo[0].mediaTypes.video.playerSize[0][0]);
- expect(data.imp[0].video.h).to.equal(bidRequestWithVideo[0].mediaTypes.video.playerSize[0][1]);
- });
-
- it('builds correctly formatted request video object for outstream', function () {
- const bidRequestWithOutstreamVideo = utils.deepClone(bidderRequest.bids);
- bidRequestWithOutstreamVideo[0].mediaTypes = {
- video: {
- context: 'outstream',
- playerSize: [[640, 480]]
- },
- };
- bidRequestWithOutstreamVideo[0].params.video = {};
- const request = spec.buildRequests(bidRequestWithOutstreamVideo, bidderRequest);
- const data = JSON.parse(request.data);
- expect(data.imp[0].video).to.exist.and.to.be.a('object');
- expect(data.imp[0].video.w).to.equal(bidRequestWithOutstreamVideo[0].mediaTypes.video.playerSize[0][0]);
- expect(data.imp[0].video.h).to.equal(bidRequestWithOutstreamVideo[0].mediaTypes.video.playerSize[0][1]);
- });
-
- it('shouldn\'t contain a user obj without GDPR information', function () {
- let request = spec.buildRequests(bidderRequest.bids, bidderRequest)
- request = JSON.parse(request.data)
- expect(request).to.not.have.property('user');
- });
-
- it('should have the right gdpr info when enabled', function () {
- const consentString = 'OIJSZsOAFsABAB8EMXZZZZZ+A==';
- const gdprBidderRequest = utils.deepClone(bidderRequest);
- gdprBidderRequest.gdprConsent = {
- 'consentString': consentString,
- 'gdprApplies': true
- };
- let request = spec.buildRequests(gdprBidderRequest.bids, gdprBidderRequest);
-
- request = JSON.parse(request.data)
- expect(request.regs.ext).to.have.property('gdpr', 1);
- expect(request.user.ext).to.have.property('consent', consentString);
- });
-
- it('should\'t contain consent string if gdpr isn\'t applied', function () {
- const nonGdprBidderRequest = utils.deepClone(bidderRequest);
- nonGdprBidderRequest.gdprConsent = {
- 'gdprApplies': false
- };
- let request = spec.buildRequests(nonGdprBidderRequest.bids, nonGdprBidderRequest);
- request = JSON.parse(request.data)
- expect(request.regs.ext).to.have.property('gdpr', 0);
- expect(request).to.not.have.property('user');
- });
-
- it('should add us privacy info to request', function() {
- const uspBidderRequest = utils.deepClone(bidderRequest);
- const consentString = '1YNN';
- uspBidderRequest.uspConsent = consentString;
- let request = spec.buildRequests(uspBidderRequest.bids, uspBidderRequest);
- request = JSON.parse(request.data);
- expect(request.us_privacy).to.exist;
- expect(request.us_privacy).to.exist.and.to.equal(consentString);
- });
-
- it('should add schain object to request', function() {
- const schainBidderRequest = utils.deepClone(bidderRequest);
- schainBidderRequest.bids[0].ortb2 = {
- source: {
- ext: {
- schain: {
- 'complete': 1,
- 'ver': '1.0',
- 'nodes': [
- {
- 'asi': 'testing.com',
- 'sid': 'abc',
- 'hp': 1
- }
- ]
- }
- }
- }
- };
- let request = spec.buildRequests(schainBidderRequest.bids, schainBidderRequest);
- request = JSON.parse(request.data);
- expect(request.source.ext.schain).to.exist;
- expect(request.source.ext.schain).to.have.property('complete', 1);
- expect(request.source.ext.schain).to.have.property('ver', '1.0');
- expect(request.source.ext.schain.nodes[0].asi).to.equal(schainBidderRequest.bids[0].ortb2.source.ext.schain.nodes[0].asi);
- });
-
- it('should add liveramp identitylink id to request', () => {
- const idl_env = '123';
- const bidRequestWithID = utils.deepClone(bidderRequest);
- bidRequestWithID.userId = { idl_env };
- let requestWithID = spec.buildRequests(bidRequestWithID.bids, bidRequestWithID);
- requestWithID = JSON.parse(requestWithID.data);
- expect(requestWithID.user.ext.eids[0]).to.deep.equal({
- source: 'liveramp.com',
- uids: [{
- id: idl_env,
- ext: {
- rtiPartner: 'idl'
- }
- }]
- });
- });
-
- it('should add gpid to request if present in ext.gpid', () => {
- const gpid = '/12345/my-gpt-tag-0';
- const bid = utils.deepClone(bidderRequest.bids[0]);
- bid.ortb2Imp = { ext: { gpid, data: { adserver: { adslot: gpid + '1' }, pbadslot: gpid + '2' } } };
- let requestWithGPID = spec.buildRequests([bid], bidderRequest);
- requestWithGPID = JSON.parse(requestWithGPID.data);
- expect(requestWithGPID.imp[0].ext.gpid).to.exist.and.equal(gpid);
- });
-
- it('should add gpid to request if present in ext.data.adserver.adslot', () => {
- const gpid = '/12345/my-gpt-tag-0';
- const bid = utils.deepClone(bidderRequest.bids[0]);
- bid.ortb2Imp = { ext: { data: { adserver: { adslot: gpid }, pbadslot: gpid + '1' } } };
- let requestWithGPID = spec.buildRequests([bid], bidderRequest);
- requestWithGPID = JSON.parse(requestWithGPID.data);
- expect(requestWithGPID.imp[0].ext.gpid).to.exist.and.equal(gpid);
- });
-
- it('should add gpid to request if present in ext.data.pbadslot', () => {
- const gpid = '/12345/my-gpt-tag-0';
- const bid = utils.deepClone(bidderRequest.bids[0]);
- bid.ortb2Imp = { ext: { data: {}, gpid } };
- let requestWithGPID = spec.buildRequests([bid], bidderRequest);
- requestWithGPID = JSON.parse(requestWithGPID.data);
- expect(requestWithGPID.imp[0].ext.gpid).to.exist.and.equal(gpid);
- });
-
- it('should add UID 2.0 to request', () => {
- const uid2 = { id: '456' };
- const bidRequestWithUID = utils.deepClone(bidderRequest);
- bidRequestWithUID.userId = { uid2 };
- let requestWithUID = spec.buildRequests(bidRequestWithUID.bids, bidRequestWithUID);
- requestWithUID = JSON.parse(requestWithUID.data);
- expect(requestWithUID.user.ext.eids[0]).to.deep.equal({
- source: 'uidapi.com',
- uids: [{
- id: uid2.id,
- ext: {
- rtiPartner: 'UID2'
- }
- }]
- });
- });
- });
-
- describe('gpp tests', function() {
- describe('when gppConsent is not present on bid request', () => {
- it('should return request with no gpp or gpp_sid properties', function() {
- const gppCompliantBidderRequest = utils.deepClone(bidderRequest);
-
- let request = spec.buildRequests(gppCompliantBidderRequest.bids, gppCompliantBidderRequest);
- request = JSON.parse(request.data);
- expect(request?.regs?.gpp).to.be.undefined;
- expect(request?.regs?.gpp_sid).to.be.undefined;
- });
- });
-
- describe('when gppConsent is present on bid request', () => {
- describe('gppString', () => {
- describe('is not defined on request', () => {
- it('should return request with gpp undefined', () => {
- const gppCompliantBidderRequest = utils.deepClone(bidderRequest);
-
- let request = spec.buildRequests(gppCompliantBidderRequest.bids, gppCompliantBidderRequest);
- request = JSON.parse(request.data);
- expect(request?.regs?.gpp).to.be.undefined;
- });
- });
-
- describe('is defined on request', () => {
- it('should return request with gpp set correctly', () => {
- const gppCompliantBidderRequest = utils.deepClone(bidderRequest);
- const gppString = 'abcdefgh';
- gppCompliantBidderRequest.gppConsent = {
- gppString
- }
-
- let request = spec.buildRequests(gppCompliantBidderRequest.bids, gppCompliantBidderRequest);
- request = JSON.parse(request.data);
- expect(request.regs.gpp).to.exist.and.to.equal(gppString);
- });
- });
- });
-
- describe('applicableSections', () => {
- describe('is not defined on request', () => {
- it('should return request with gpp_sid undefined', () => {
- const gppCompliantBidderRequest = utils.deepClone(bidderRequest);
-
- let request = spec.buildRequests(gppCompliantBidderRequest.bids, gppCompliantBidderRequest);
- request = JSON.parse(request.data);
- expect(request?.regs?.gpp_sid).to.be.undefined;
- });
- });
-
- describe('is defined on request', () => {
- it('should return request with gpp_sid set correctly', () => {
- const gppCompliantBidderRequest = utils.deepClone(bidderRequest);
- const applicableSections = [8];
- gppCompliantBidderRequest.gppConsent = {
- applicableSections
- }
-
- let request = spec.buildRequests(gppCompliantBidderRequest.bids, gppCompliantBidderRequest);
- request = JSON.parse(request.data);
- expect(request.regs.gpp_sid).to.deep.equal(applicableSections);
- });
- });
- });
- });
- });
- });
-
- describe('interpretResponse', function () {
- const bid = {
- 'bidder': 'cadent_aperture_mx',
- 'params': {
- 'tagid': '25251',
- 'video': {}
- },
- 'mediaTypes': {
- 'video': {
- 'context': 'instream',
- 'playerSize': [640, 480]
- }
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [
- [300, 250],
- [300, 600]
- ],
- 'bidId': '30b31c2501de1e',
- 'bidderRequestId': '22edbae3120bf6',
- 'auctionId': '1d1a01234a475'
- };
-
- const bid_outstream = {
- 'bidderRequest': {
- 'bids': [{
- 'bidder': 'cadent_aperture_mx',
- 'params': {
- 'tagid': '25251',
- 'video': {}
- },
- 'mediaTypes': {
- 'video': {
- 'context': 'outstream',
- 'playerSize': [640, 480]
- }
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [
- [300, 250],
- [300, 600]
- ],
- 'bidId': '987654321cba',
- 'bidderRequestId': '22edbae3120bf6',
- 'auctionId': '1d1a01234a475'
- }, {
- 'bidder': 'cadent_aperture_mx',
- 'params': {
- 'tagid': '25252',
- 'video': {}
- },
- 'mediaTypes': {
- 'video': {
- 'context': 'instream',
- 'playerSize': [640, 480]
- }
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [
- [300, 250],
- [300, 600]
- ],
- 'bidId': '987654321dcb',
- 'bidderRequestId': '22edbae3120bf6',
- 'auctionId': '1d1a01234a475'
- }]
- }
- };
-
- const serverResponse = {
- 'id': '12819a18-56e1-4256-b836-b69a10202668',
- 'seatbid': [{
- 'bid': [{
- 'adid': '123456abcde',
- 'adm': '',
- 'crid': '3434abab34',
- 'h': 250,
- 'id': '987654321cba',
- 'price': 0.5,
- 'ttl': 300,
- 'w': 300,
- 'adomain': ['example.com']
- }],
- 'seat': '1356'
- }, {
- 'bid': [{
- 'adid': '123456abcdf',
- 'adm': '',
- 'crid': '3434abab35',
- 'h': 600,
- 'id': '987654321dcb',
- 'price': 0.5,
- 'ttl': 300,
- 'w': 300
- }]
- }]
- };
-
- const expectedResponse = [{
- 'requestId': '12819a18-56e1-4256-b836-b69a10202668',
- 'cpm': 0.5,
- 'width': 300,
- 'height': 250,
- 'creativeId': '3434abab34',
- 'dealId': null,
- 'currency': 'USD',
- 'netRevneue': true,
- 'mediaType': 'banner',
- 'ad': '',
- 'ttl': 300,
- 'meta': {
- 'advertiserDomains': ['example.com']
- }
- }, {
- 'requestId': '12819a18-56e1-4256-b836-b69a10202668',
- 'cpm': 0.7,
- 'width': 300,
- 'height': 600,
- 'creativeId': '3434abab35',
- 'dealId': null,
- 'currency': 'USD',
- 'netRevneue': true,
- 'mediaType': 'banner',
- 'ad': '',
- 'ttl': 300
- }];
-
- it('should properly format bid response', function () {
- const result = spec.interpretResponse({
- body: serverResponse
- });
- expect(Object.keys(result[0]).length).to.equal(Object.keys(expectedResponse[0]).length);
- expect(Object.keys(result[0]).requestId).to.equal(Object.keys(expectedResponse[0]).requestId);
- expect(Object.keys(result[0]).bidderCode).to.equal(Object.keys(expectedResponse[0]).bidderCode);
- expect(Object.keys(result[0]).cpm).to.equal(Object.keys(expectedResponse[0]).cpm);
- expect(Object.keys(result[0]).creativeId).to.equal(Object.keys(expectedResponse[0]).creativeId);
- expect(Object.keys(result[0]).width).to.equal(Object.keys(expectedResponse[0]).width);
- expect(Object.keys(result[0]).height).to.equal(Object.keys(expectedResponse[0]).height);
- expect(Object.keys(result[0]).ttl).to.equal(Object.keys(expectedResponse[0]).ttl);
- expect(Object.keys(result[0]).adId).to.equal(Object.keys(expectedResponse[0]).adId);
- expect(Object.keys(result[0]).currency).to.equal(Object.keys(expectedResponse[0]).currency);
- expect(Object.keys(result[0]).netRevenue).to.equal(Object.keys(expectedResponse[0]).netRevenue);
- expect(Object.keys(result[0]).ad).to.equal(Object.keys(expectedResponse[0]).ad);
- });
-
- it('should return multiple bids', function () {
- const result = spec.interpretResponse({
- body: serverResponse
- });
- expect(Array.isArray(result.seatbid))
-
- const ad0 = result[0];
- const ad1 = result[1];
- expect(ad0.ad).to.equal(serverResponse.seatbid[0].bid[0].adm);
- expect(ad0.cpm).to.equal(serverResponse.seatbid[0].bid[0].price);
- expect(ad0.creativeId).to.equal(serverResponse.seatbid[0].bid[0].crid);
- expect(ad0.currency).to.equal('USD');
- expect(ad0.netRevenue).to.equal(true);
- expect(ad0.requestId).to.equal(serverResponse.seatbid[0].bid[0].id);
- expect(ad0.ttl).to.equal(300);
-
- expect(ad1.ad).to.equal(serverResponse.seatbid[1].bid[0].adm);
- expect(ad1.cpm).to.equal(serverResponse.seatbid[1].bid[0].price);
- expect(ad1.creativeId).to.equal(serverResponse.seatbid[1].bid[0].crid);
- expect(ad1.currency).to.equal('USD');
- expect(ad1.netRevenue).to.equal(true);
- expect(ad1.requestId).to.equal(serverResponse.seatbid[1].bid[0].id);
- expect(ad1.ttl).to.equal(300);
- });
-
- it('returns a banner bid for non-xml creatives', function () {
- const result = spec.interpretResponse({
- body: serverResponse
- }, { bidRequest: bid }
- );
- const ad0 = result[0];
- const ad1 = result[1];
- expect(ad0.mediaType).to.equal('banner');
- expect(ad0.ad.indexOf('';
- vastServerResponse.seatbid[1].bid[0].adm = '';
-
- const result = spec.interpretResponse({
- body: vastServerResponse
- }, { bidRequest: bid }
- );
- const ad0 = result[0];
- const ad1 = result[1];
- expect(ad0.mediaType).to.equal('video');
- expect(ad0.ad.indexOf(' -1).to.equal(true);
- expect(ad0.vastXml).to.equal(vastServerResponse.seatbid[0].bid[0].adm);
- expect(ad0.ad).to.exist.and.to.be.a('string');
- expect(ad1.mediaType).to.equal('video');
- expect(ad1.ad.indexOf(' -1).to.equal(true);
- expect(ad1.vastXml).to.equal(vastServerResponse.seatbid[1].bid[0].adm);
- expect(ad1.ad).to.exist.and.to.be.a('string');
- });
-
- it('returns a renderer for outstream video creatives', function () {
- const vastServerResponse = utils.deepClone(serverResponse);
- vastServerResponse.seatbid[0].bid[0].adm = '';
- vastServerResponse.seatbid[1].bid[0].adm = '';
- const result = spec.interpretResponse({body: vastServerResponse}, bid_outstream);
- const ad0 = result[0];
- const ad1 = result[1];
- expect(ad0.renderer).to.exist.and.to.be.a('object');
- expect(ad0.renderer.url).to.equal('https://js.brealtime.com/outstream/1.30.0/bundle.js');
- expect(ad0.renderer.id).to.equal('987654321cba');
- expect(ad1.renderer).to.equal(undefined);
- });
-
- it('handles nobid responses', function () {
- const serverResponse = {
- 'bids': []
- };
-
- const result = spec.interpretResponse({
- body: serverResponse
- });
- expect(result.length).to.equal(0);
- });
-
- it('should not throw an error when decoding an improperly encoded adm', function () {
- const badAdmServerResponse = utils.deepClone(serverResponse);
- badAdmServerResponse.seatbid[0].bid[0].adm = '',
- adomain: ['clickonometrics.com'],
- crid: '221',
- w: 300,
- h: 250,
- ext: {
- type: 'standard'
- }
- },
- {
- id: '2e56e1af51a5d8_222',
- impid: '2e56e1af51a5d8',
- price: 5.68,
- adid: '222',
- adm: '',
- adomain: ['clickonometrics.com'],
- crid: '222',
- w: 640,
- h: 480,
- ext: {
- type: 'video'
- }
- }
- ]
- }
- ],
- cur: 'PLN',
- ext: {
- ttl: 5,
- usersync: [
- {
- type: 'image',
- url: 'http://foo.sync?param=1'
- },
- {
- type: 'iframe',
- url: 'http://foo.sync?param=2'
- }
- ]
- }
- };
-
- describe('interpretResponse', function () {
- it('Valid bid response - multi', function () {
- const bidResponses = [
- {
- requestId: '2e56e1af51a5d7',
- cpm: 8.1,
- width: 300,
- height: 250,
- creativeId: '221',
- netRevenue: false,
- ttl: 5,
- currency: 'PLN',
- ad: '',
- meta: {
- advertiserDomains: ['clickonometrics.com']
- }
- },
- {
- requestId: '2e56e1af51a5d8',
- cpm: 5.68,
- width: 640,
- height: 480,
- creativeId: '222',
- netRevenue: false,
- ttl: 5,
- currency: 'PLN',
- vastXml: '',
- meta: {
- advertiserDomains: ['clickonometrics.com']
- }
- }
- ];
- expect(spec.interpretResponse({body: response})).to.deep.have.same.members(bidResponses);
- });
-
- it('Valid bid response - single', function () {
- delete response.seatbid[0].bid[1];
- const bidResponses = [
- {
- requestId: '2e56e1af51a5d7',
- cpm: 8.1,
- width: 300,
- height: 250,
- creativeId: '221',
- netRevenue: false,
- ttl: 5,
- currency: 'PLN',
- ad: '',
- meta: {
- advertiserDomains: ['clickonometrics.com']
- }
- }
- ];
- expect(spec.interpretResponse({body: response})).to.deep.have.same.members(bidResponses);
- });
-
- it('Empty bid response', function () {
- expect(spec.interpretResponse({})).to.be.empty;
- });
- });
-
- describe('getUserSyncs', function () {
- it('Valid syncs - all', function () {
- const syncOptions = {
- iframeEnabled: true,
- pixelEnabled: true
- };
-
- const expectedSyncs = [
- {
- type: 'image',
- url: 'http://foo.sync?param=1'
- },
- {
- type: 'iframe',
- url: 'http://foo.sync?param=2'
- }
- ];
- expect(spec.getUserSyncs(syncOptions, [{body: response}])).to.deep.have.same.members(expectedSyncs);
- });
-
- it('Valid syncs - only image', function () {
- const syncOptions = {
- iframeEnabled: false,
- pixelEnabled: true
- };
- const expectedSyncs = [
- {
- type: 'image', url: 'http://foo.sync?param=1'
- }
- ];
- expect(spec.getUserSyncs(syncOptions, [{body: response}])).to.deep.have.same.members(expectedSyncs);
- });
-
- it('Valid syncs - only iframe', function () {
- const syncOptions = {iframeEnabled: true, pixelEnabled: false};
- const expectedSyncs = [
- {
- type: 'iframe', url: 'http://foo.sync?param=2'
- }
- ];
- expect(spec.getUserSyncs(syncOptions, [{body: response}])).to.deep.have.same.members(expectedSyncs);
- });
-
- it('Valid syncs - empty', function () {
- const syncOptions = {iframeEnabled: true, pixelEnabled: true};
- response.ext.usersync = {};
- expect(spec.getUserSyncs(syncOptions, [{body: response}])).to.be.empty;
- });
- });
-
- describe('mediaTypesVideoParams', function () {
- it('Valid video mediaTypes', function () {
- const bids = [
- {
- adUnitCode: 'video',
- auctionId: '0b9de793-8eda-481e-a548-c187d58b28d9',
- bidId: '3u94t90ut39tt3t',
- bidder: 'ccx',
- bidderRequestId: '23ur20r239r2r',
- mediaTypes: {
- video: {
- playerSize: [[640, 480]],
- protocols: [2, 3, 5, 6],
- mimes: ['video/mp4', 'video/x-flv'],
- playbackmethod: [1, 2, 3, 4],
- skip: 1,
- skipafter: 5
- }
- },
- params: {
- placementId: 608
- },
- sizes: [[640, 480]],
- transactionId: 'aefddd38-cfa0-48ab-8bdd-325de4bab5f9'
- }
- ];
-
- const imps = [
- {
- video: {
- w: 640,
- h: 480,
- protocols: [2, 3, 5, 6],
- mimes: ['video/mp4', 'video/x-flv'],
- playbackmethod: [1, 2, 3, 4],
- skip: 1,
- skipafter: 5
- },
- id: '3u94t90ut39tt3t',
- secure: 1,
- ext: {
- pid: 608
- }
- }
- ];
-
- const bidsClone = utils.deepClone(bids);
-
- const response = spec.buildRequests(bidsClone, {'bids': bidsClone});
- const data = JSON.parse(response.data);
-
- expect(data.imp).to.deep.have.same.members(imps);
- });
- });
-
- describe('FLEDGE', function () {
- it('should properly build a request when FLEDGE is enabled', async function () {
- const bidderRequest = {
- paapi: {
- enabled: true
- }
- };
- const bids = [
- {
- adUnitCode: 'banner',
- auctionId: '0b9de793-8eda-481e-a548-aaaaaaaaaaa1',
- bidId: '2e56e1af51ccc1',
- bidder: 'ccx',
- bidderRequestId: '17e7b9f58accc1',
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
- },
- params: {
- placementId: 609
- },
- sizes: [[300, 250]],
- transactionId: 'befddd38-cfa0-48ab-8bdd-bbbbbbbbbbb1',
- ortb2Imp: {
- ext: {
- ae: 1
- }
- }
- }
- ];
-
- const ortbRequest = spec.buildRequests(bids, await addFPDToBidderRequest(bidderRequest));
- const data = JSON.parse(ortbRequest.data);
- expect(data.imp[0].ext.ae).to.equal(1);
- });
-
- it('should properly build a request when FLEDGE is disabled', async function () {
- const bidderRequest = {
- paapi: {
- enabled: false
- }
- };
- const bids = [
- {
- adUnitCode: 'banner',
- auctionId: '0b9de793-8eda-481e-a548-aaaaaaaaaaa2',
- bidId: '2e56e1af51ccc2',
- bidder: 'ccx',
- bidderRequestId: '17e7b9f58accc2',
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
- },
- params: {
- placementId: 610
- },
- sizes: [[300, 250]],
- transactionId: 'befddd38-cfa0-48ab-8bdd-bbbbbbbbbbb2',
- ortb2Imp: {
- ext: {
- ae: 1
- }
- }
- }
- ];
-
- const ortbRequest = spec.buildRequests(bids, await addFPDToBidderRequest(bidderRequest));
- const data = JSON.parse(ortbRequest.data);
- expect(data.imp[0].ext.ae).to.be.undefined;
- });
- });
-});
diff --git a/test/spec/modules/chromeAiRtdProvider_spec.js b/test/spec/modules/chromeAiRtdProvider_spec.js
deleted file mode 100644
index c723eac63..000000000
--- a/test/spec/modules/chromeAiRtdProvider_spec.js
+++ /dev/null
@@ -1,393 +0,0 @@
-import * as chromeAiRtdProvider from 'modules/chromeAiRtdProvider.js';
-import * as utils from 'src/utils.js';
-import { config } from 'src/config.js';
-import * as storageManager from 'src/storageManager.js';
-
-describe('Chrome AI RTD Provider', function() {
- // Set up sandbox for all stubs
- const sandbox = sinon.createSandbox();
- // Mock storage manager
- const mockStorage = {
- hasLocalStorage: sinon.stub(),
- localStorageIsEnabled: sinon.stub(),
- getDataFromLocalStorage: sinon.stub(),
- setDataInLocalStorage: sinon.stub()
- };
-
- // Mock page URL for testing
- const mockPageUrl = 'https://example.com/test-page';
-
- // Mock Chrome AI API instances
- let mockLanguageDetectorInstance;
- let mockSummarizerInstance;
-
- // Mock API availability status
- let mockLanguageDetectorAvailability;
- let mockSummarizerAvailability;
-
- // Original globals
- let originalLanguageDetector;
- let originalSummarizer;
-
- // Stubs
- let logMessageStub, logErrorStub; // Removed deepAccessStub, deepSetValueStub
- let mockTopDocument;
- let querySelectorStub;
-
- beforeEach(function() {
- // Reset sandbox for each test
- sandbox.reset();
-
- // Save original globals
- originalLanguageDetector = self.LanguageDetector;
- originalSummarizer = self.Summarizer;
-
- // Create stubs
- logMessageStub = sandbox.stub(utils, 'logMessage');
- logErrorStub = sandbox.stub(utils, 'logError');
-
- // Stub storage manager
- sandbox.stub(chromeAiRtdProvider, 'storage').get(() => mockStorage);
- mockStorage.hasLocalStorage.returns(true);
- mockStorage.localStorageIsEnabled.returns(true);
- mockStorage.getDataFromLocalStorage.returns(null); // Default to no data
- mockStorage.setDataInLocalStorage.returns(true);
-
- // Stub document properties
- querySelectorStub = sandbox.stub();
- mockTopDocument = {
- body: { textContent: 'Default page body text for testing.' },
- title: 'Test Page Title',
- querySelector: querySelectorStub
- };
- querySelectorStub.withArgs('article').returns(null); // Default: no article found
-
- sandbox.stub(utils, 'getWindowTop').returns({
- location: { href: mockPageUrl },
- document: mockTopDocument
- });
-
- // Create mock instances
- mockLanguageDetectorInstance = {
- detect: sandbox.stub().resolves([{ detectedLanguage: 'en', confidence: 0.9 }]),
- ready: Promise.resolve(),
- addEventListener: sandbox.stub()
- };
-
- mockSummarizerInstance = {
- summarize: sandbox.stub().resolves('Test summary'),
- ready: Promise.resolve(),
- addEventListener: sandbox.stub()
- };
-
- // Reset mock availability to default values
- mockLanguageDetectorAvailability = 'available';
- mockSummarizerAvailability = 'available';
-
- // Mock global Chrome AI API constructors and their methods
- // LanguageDetector
- const MockLanguageDetectorFn = function() { /* This constructor body isn't called by the module */ };
- Object.defineProperty(MockLanguageDetectorFn, 'name', { value: 'LanguageDetector', configurable: true });
- MockLanguageDetectorFn.availability = sandbox.stub().resolves('available'); // Default to 'available'
- MockLanguageDetectorFn.create = sandbox.stub().resolves(mockLanguageDetectorInstance);
- self.LanguageDetector = MockLanguageDetectorFn;
-
- // Summarizer
- const MockSummarizerFn = function() { /* This constructor body isn't called by the module */ };
- Object.defineProperty(MockSummarizerFn, 'name', { value: 'Summarizer', configurable: true });
- MockSummarizerFn.availability = sandbox.stub().resolves('available'); // Default to 'available'
- MockSummarizerFn.create = sandbox.stub().resolves(mockSummarizerInstance);
- self.Summarizer = MockSummarizerFn;
- });
-
- afterEach(function() {
- // Restore original globals
- if (originalLanguageDetector) {
- self.LanguageDetector = originalLanguageDetector;
- } else {
- delete self.LanguageDetector;
- }
-
- if (originalSummarizer) {
- self.Summarizer = originalSummarizer;
- } else {
- delete self.Summarizer;
- }
-
- // Restore sandbox
- sandbox.restore();
- });
-
- // Test basic module structure
- describe('Module Structure', function() {
- it('should have required methods', function() {
- expect(chromeAiRtdProvider.chromeAiSubmodule.name).to.equal('chromeAi');
- expect(typeof chromeAiRtdProvider.chromeAiSubmodule.init).to.equal('function');
- expect(typeof chromeAiRtdProvider.chromeAiSubmodule.getBidRequestData).to.equal('function');
- });
-
- it('should have the correct module name', function() {
- expect(chromeAiRtdProvider.chromeAiSubmodule.name).to.equal('chromeAi');
- });
-
- it('should have the correct constants', function() {
- expect(chromeAiRtdProvider.CONSTANTS).to.be.an('object');
- expect(chromeAiRtdProvider.CONSTANTS.SUBMODULE_NAME).to.equal('chromeAi');
- expect(chromeAiRtdProvider.CONSTANTS.STORAGE_KEY).to.equal('chromeAi_detected_data');
- expect(chromeAiRtdProvider.CONSTANTS.MIN_TEXT_LENGTH).to.be.a('number');
- });
- });
-
- // Test initialization
- describe('Initialization (init function)', function() {
- beforeEach(function() {
- // Simulate empty localStorage for init tests
- mockStorage.getDataFromLocalStorage.withArgs(chromeAiRtdProvider.CONSTANTS.STORAGE_KEY).returns(null);
- // Reset call history for setDataInLocalStorage if needed, or ensure it's clean
- mockStorage.setDataInLocalStorage.resetHistory();
- });
-
- afterEach(function() {
- // Clean up localStorage stubs if necessary, or reset to default behavior
- mockStorage.getDataFromLocalStorage.withArgs(chromeAiRtdProvider.CONSTANTS.STORAGE_KEY).returns(null); // Reset to default for other describe blocks
- mockStorage.setDataInLocalStorage.resetHistory();
- });
-
- it('should handle LanguageDetector API unavailability (when availability() returns unavailable)', function() {
- // Ensure LanguageDetector constructor itself is available (which it is by beforeEach setup)
- // Configure its availability() method to return 'unavailable' for this test
- sandbox.stub(chromeAiRtdProvider, 'getPrioritizedLanguageData').returns(null);
- self.LanguageDetector.availability.resolves('unavailable');
- return chromeAiRtdProvider.chromeAiSubmodule.init({ params: { languageDetector: { enabled: true } } }).then(function(result) {
- // The init might still resolve to true if other features (like summarizer if enabled & available) initialize successfully.
- // We are checking that the specific error for LanguageDetector being unavailable is logged.
- expect(logErrorStub.calledWith(sinon.match('ChromeAI-Rtd-Provider: LanguageDetector is unavailable.'))).to.be.true;
- });
- });
-
- it('should attempt language detection if no prior language data (default config)', async function() {
- // Ensure getPrioritizedLanguageData returns null to force detection path
- sandbox.stub(chromeAiRtdProvider, 'getPrioritizedLanguageData').returns(null);
-
- // Ensure getPageText returns valid text for detection
- mockTopDocument.querySelector.withArgs('article').returns(null);
- mockTopDocument.body.textContent = 'Sufficiently long text for detection.';
-
- await chromeAiRtdProvider.chromeAiSubmodule.init({}); // Initialize with default config
-
- expect(logMessageStub.calledWith(sinon.match('Initializing with config'))).to.be.true;
- // Check that the actual language detection was attempted
- expect(mockLanguageDetectorInstance.detect.called).to.be.true;
- });
-
- it('should handle Summarizer API unavailability (when availability() returns unavailable)', function() {
- self.Summarizer.availability.resolves('unavailable');
-
- return chromeAiRtdProvider.chromeAiSubmodule.init({ params: { summarizer: { enabled: true } } }).then(function(result) {
- expect(logErrorStub.calledWith(sinon.match('ChromeAI-Rtd-Provider: Summarizer is unavailable.'))).to.be.true;
- // Init might still resolve to true if other features initialize successfully.
- });
- });
-
- it('should attempt model download if Summarizer availability is "after-download"', function() {
- self.Summarizer.availability.resolves('after-download');
-
- return chromeAiRtdProvider.chromeAiSubmodule.init({ params: { summarizer: { enabled: true } } }).then(() => {
- expect(self.Summarizer.create.called).to.be.true;
- expect(mockSummarizerInstance.addEventListener.calledWith('downloadprogress', sinon.match.func)).to.be.true;
- });
- });
-
- it('should return a promise', function() {
- const result = chromeAiRtdProvider.chromeAiSubmodule.init({});
- expect(result).to.be.an.instanceof(Promise);
- return result; // Ensure Mocha waits for the promise
- });
-
- it('should initialize with custom config', function() {
- const customConfig = {
- params: {
- languageDetector: {
- enabled: true,
- ortb2Path: 'custom.language.path',
- confidence: 0.7
- },
- summarizer: {
- enabled: true,
- ortb2Path: 'custom.keywords.path',
- cacheInLocalStorage: true
- }
- }
- };
-
- return chromeAiRtdProvider.chromeAiSubmodule.init(customConfig).then(function(result) {
- expect(typeof result).to.equal('boolean');
- expect(logMessageStub.calledWith(sinon.match('Initializing with config'))).to.be.true;
- });
- });
-
- it('should handle disabled features in config', function() {
- const disabledConfig = {
- params: {
- languageDetector: { enabled: false },
- summarizer: { enabled: false }
- }
- };
-
- return chromeAiRtdProvider.chromeAiSubmodule.init(disabledConfig).then(function(result) {
- expect(result).to.be.true;
- expect(logMessageStub.calledWith(sinon.match('Language detection disabled by config'))).to.be.true;
- expect(logMessageStub.calledWith(sinon.match('Summarizer disabled by config.'))).to.be.true;
- });
- });
- });
-
- // Test storage functions
- describe('Storage Functions', function() {
- beforeEach(function() {
- mockStorage.getDataFromLocalStorage.resetHistory();
- mockStorage.setDataInLocalStorage.resetHistory();
- mockStorage.setDataInLocalStorage.returns(true); // Default success
- });
-
- describe('chromeAiRtdProvider._getChromeAiDataFromLocalStorage', function() {
- it('should return null if localStorage is not available', function() {
- mockStorage.hasLocalStorage.returns(false);
- expect(chromeAiRtdProvider._getChromeAiDataFromLocalStorage(mockPageUrl)).to.be.null;
- });
-
- it('should return null if localStorage is not enabled', function() {
- mockStorage.localStorageIsEnabled.returns(false);
- expect(chromeAiRtdProvider._getChromeAiDataFromLocalStorage(mockPageUrl)).to.be.null;
- });
-
- it('should return null if no data in localStorage for the URL', function() {
- mockStorage.getDataFromLocalStorage.withArgs(chromeAiRtdProvider.CONSTANTS.STORAGE_KEY).returns(JSON.stringify({ 'other/url': {} }));
- expect(chromeAiRtdProvider._getChromeAiDataFromLocalStorage(mockPageUrl)).to.be.null;
- });
- });
- describe('chromeAiRtdProvider.storeDetectedKeywords', function() {
- it('should return false if keywords are not provided or empty', function() {
- expect(chromeAiRtdProvider.storeDetectedKeywords(null, mockPageUrl)).to.be.false;
- expect(chromeAiRtdProvider.storeDetectedKeywords([], mockPageUrl)).to.be.false;
- expect(logMessageStub.calledWith(sinon.match('No valid keywords array to store'))).to.be.true;
- });
- });
- });
-
- // Test language detection main function
- describe('chromeAiRtdProvider.detectLanguage (main function)', function() {
- it('should detect language using Chrome AI API', async function() {
- const result = await chromeAiRtdProvider.detectLanguage('This is a test text');
- expect(result).to.deep.equal({ language: 'en', confidence: 0.9 });
- expect(mockLanguageDetectorInstance.detect.calledOnceWith('This is a test text')).to.be.true;
- });
-
- it('should return null if API is not available', async function() {
- self.LanguageDetector.create.resolves(null); // Simulate API creation failure
- const result = await chromeAiRtdProvider.detectLanguage('This is a test text');
- expect(result).to.be.null;
- });
-
- it('should return null if confidence is below threshold', async function() {
- mockLanguageDetectorInstance.detect.resolves([{ detectedLanguage: 'en', confidence: 0.5 }]);
- // Need to re-init to pick up the new default config confidence if it changed, or set it explicitly
- await chromeAiRtdProvider.chromeAiSubmodule.init({ params: { languageDetector: { confidence: 0.8 } } });
- const result = await chromeAiRtdProvider.detectLanguage('This is a test text');
- expect(result).to.be.null;
- });
- });
- // Test getBidRequestData
- describe('getBidRequestData', function() {
- let reqBidsConfigObj;
- let onDoneSpy;
-
- beforeEach(async function() {
- // Initialize the module with a config that enables both features for these tests
- await chromeAiRtdProvider.chromeAiSubmodule.init({
- params: {
- languageDetector: { enabled: true, ortb2Path: 'site.content.language' },
- summarizer: { enabled: true, ortb2Path: 'site.content.ext.keywords', cacheInLocalStorage: false }
- }
- });
-
- reqBidsConfigObj = {
- adUnits: [{ code: 'adunit1' }],
- ortb2Fragments: {
- global: {}
- }
- };
- onDoneSpy = sinon.spy();
- // Reset stubs that might be called by getBidRequestData indirectly via init or helper functions
- logMessageStub.resetHistory();
- });
-
- it('should call the callback function', function() {
- chromeAiRtdProvider.chromeAiSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy);
- expect(onDoneSpy.calledOnce).to.be.true;
- });
-
- it('should ensure ortb2Fragments.global exists', function() {
- delete reqBidsConfigObj.ortb2Fragments.global;
- chromeAiRtdProvider.chromeAiSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy);
- expect(reqBidsConfigObj.ortb2Fragments.global).to.be.an('object');
- });
-
- it('should not enrich language if already present in auction ORTB2', function() {
- // Set language directly in ortb2Fragments for this test case
- utils.deepSetValue(reqBidsConfigObj.ortb2Fragments.global, 'site.content.language', 'es');
-
- chromeAiRtdProvider.chromeAiSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy);
-
- // Verify that the language was not changed
- expect(utils.deepAccess(reqBidsConfigObj.ortb2Fragments.global, 'site.content.language')).to.equal('es');
- expect(logMessageStub.calledWith(sinon.match('Lang already in auction ORTB2 at path'))).to.be.true;
- });
-
- it('should enrich with detected keywords if not in auction ORTB2', async function() {
- mockSummarizerInstance.summarize.resolves('newly detected summary');
- await chromeAiRtdProvider.chromeAiSubmodule.init({ // Re-init to trigger summarizer with mocks
- params: {
- summarizer: { enabled: true, ortb2Path: 'site.content.ext.keywords', cacheInLocalStorage: false },
- languageDetector: { enabled: false } // Disable lang to isolate test
- }
- });
-
- chromeAiRtdProvider.chromeAiSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy);
- expect(utils.deepAccess(reqBidsConfigObj.ortb2Fragments.global, 'site.content.ext.keywords')).to.deep.equal(['newly detected summary']);
- });
-
- it('should not enrich keywords if already present in auction ORTB2', function() {
- // Set keywords directly in ortb2Fragments for this test case
- utils.deepSetValue(reqBidsConfigObj.ortb2Fragments.global, 'site.content.ext.keywords', ['existing', 'keywords']);
-
- chromeAiRtdProvider.chromeAiSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy);
-
- // Verify that keywords were not changed
- expect(utils.deepAccess(reqBidsConfigObj.ortb2Fragments.global, 'site.content.ext.keywords')).to.deep.equal(['existing', 'keywords']);
- expect(logMessageStub.calledWith(sinon.match('Keywords already present in auction_ortb2 at path'))).to.be.true;
- });
-
- it('should handle language detection disabled', function() {
- chromeAiRtdProvider.chromeAiSubmodule.init({ params: { languageDetector: { enabled: false } } }); // Re-init with lang disabled
- chromeAiRtdProvider.chromeAiSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy);
- expect(logMessageStub.calledWith(sinon.match('Language detection disabled, no lang enrichment.'))).to.be.true;
- const langPath = chromeAiRtdProvider.CONSTANTS.DEFAULT_CONFIG.languageDetector.ortb2Path;
- // Check that language was not set by trying to access it; it should be undefined or its original value if any
- // This is a bit indirect. If we could spy on deepSetValue, it would be cleaner.
- // For now, we assume if it's not set to the detected value, the non-enrichment path was taken.
- // A more robust check would be to ensure no new properties were added if it was initially empty.
- expect(utils.deepAccess(reqBidsConfigObj.ortb2Fragments.global, langPath)).to.be.undefined;
- });
-
- it('should handle summarizer disabled', function() {
- chromeAiRtdProvider.chromeAiSubmodule.init({ params: { summarizer: { enabled: false } } }); // Re-init with summarizer disabled
- chromeAiRtdProvider.chromeAiSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy);
- expect(logMessageStub.calledWith(sinon.match('Summarizer disabled, no keyword enrichment.'))).to.be.true;
- // Check that no keyword enrichment was attempted
- const keywordPath = chromeAiRtdProvider.CONSTANTS.DEFAULT_CONFIG.summarizer.ortb2Path; // or the configured one
- // Verify that keywords were not set by checking the path
- expect(utils.deepAccess(reqBidsConfigObj.ortb2Fragments.global, keywordPath)).to.be.undefined;
- });
- });
-});
diff --git a/test/spec/modules/chtnwBidAdapter_spec.js b/test/spec/modules/chtnwBidAdapter_spec.js
deleted file mode 100644
index 70e39c440..000000000
--- a/test/spec/modules/chtnwBidAdapter_spec.js
+++ /dev/null
@@ -1,108 +0,0 @@
-import { expect } from 'chai';
-import { spec } from '../../../modules/chtnwBidAdapter.js';
-import * as utils from '../../../src/utils.js';
-
-describe('ChtnwAdapter', function () {
- describe('isBidRequestValid', function () {
- const bid = {
- code: 'adunit-code',
- bidder: 'chtnw',
- params: {
- placementId: '38EL412LO82XR9O6'
- },
- sizes: [
- [300, 250]
- ],
- };
-
- it('should return true when required params found', function () {
- const bidRequest = utils.deepClone(bid);
- expect(spec.isBidRequestValid(bidRequest)).to.equal(true);
- });
-
- it('should return false when required params are missing', function () {
- const bidRequest = utils.deepClone(bid);
- delete bidRequest.params;
- expect(spec.isBidRequestValid(bidRequest)).to.equal(false);
- });
- });
-
- describe('buildRequests', function () {
- const bidRequests = [{
- code: 'adunit-code',
- bidder: 'chtnw',
- params: {
- placementId: '38EL412LO82XR9O6'
- },
- sizes: [
- [300, 250]
- ],
- }];
-
- let request;
- before(() => {
- request = spec.buildRequests(bidRequests);
- })
-
- it('Returns POST method', function () {
- expect(request.method).to.equal('POST');
- });
-
- it('Returns general data valid', function () {
- const data = request.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('bids');
- expect(data).to.have.property('uuid');
- expect(data).to.have.property('device');
- expect(data).to.have.property('site');
- });
- });
-
- describe('interpretResponse', function () {
- const responseBody = [{
- 'requestId': 'test',
- 'cpm': 0.5,
- 'currency': 'USD',
- 'width': 300,
- 'height': 250,
- 'netRevenue': true,
- 'ttl': 60,
- 'creativeId': 'AD',
- 'ad': 'AD',
- 'mediaType': 'banner',
- 'meta': {
- 'advertiserDomains': [
- 'www.example.com'
- ]
- }
- }];
-
- it('handles empty bid response', function () {
- const response = {
- body: responseBody
- };
- const result = spec.interpretResponse(response);
- expect(result.length).to.not.equal(0);
- expect(result[0].meta.advertiserDomains).to.be.an('array');
- });
-
- it('handles empty bid response', function () {
- const response = {
- body: []
- };
- const result = spec.interpretResponse(response);
- expect(result.length).to.equal(0);
- });
- });
-
- describe('getUserSyncs', function () {
- it('should register type is image', function () {
- const syncOptions = {
- 'pixelEnabled': 'true'
- }
- const userSync = spec.getUserSyncs(syncOptions);
- expect(userSync[0].type).to.equal('image');
- expect(userSync[0].url).to.have.string('ssp');
- });
- });
-});
diff --git a/test/spec/modules/cleanioRtdProvider_spec.js b/test/spec/modules/cleanioRtdProvider_spec.js
deleted file mode 100644
index 99e52c154..000000000
--- a/test/spec/modules/cleanioRtdProvider_spec.js
+++ /dev/null
@@ -1,211 +0,0 @@
-import { loadExternalScriptStub } from 'test/mocks/adloaderStub.js';
-import * as utils from '../../../src/utils.js';
-import * as hook from '../../../src/hook.js'
-import * as events from '../../../src/events.js';
-import { EVENTS } from '../../../src/constants.js';
-
-import { __CLEANIO_TEST__ } from '../../../modules/cleanioRtdProvider.js';
-import { MODULE_TYPE_RTD } from '../../../src/activities/modules.js';
-
-const {
- readConfig,
- ConfigError,
- pageInitStepPreloadScript,
- pageInitStepProtectPage,
- bidWrapStepAugmentHtml,
- bidWrapStepProtectByWrapping,
- beforeInit,
-} = __CLEANIO_TEST__;
-
-sinon.assert.expose(chai.assert, { prefix: 'sinon' });
-
-const fakeScriptURL = 'https://example.com/script.js';
-
-function makeFakeBidResponse() {
- return {
- ad: 'hello ad',
- bidderCode: 'BIDDER',
- creativeId: 'CREATIVE',
- cpm: 1.23,
- };
-}
-
-describe('clean.io RTD module', function () {
- describe('readConfig()', function() {
- it('should throw ConfigError on invalid configurations', function() {
- expect(() => readConfig({})).to.throw(ConfigError);
- expect(() => readConfig({ params: {} })).to.throw(ConfigError);
- expect(() => readConfig({ params: { protectionMode: 'bids' } })).to.throw(ConfigError);
- expect(() => readConfig({ params: { cdnUrl: 'abc' } })).to.throw(ConfigError);
- expect(() => readConfig({ params: { cdnUrl: 'abc', protectionMode: 'bids' } })).to.throw(ConfigError);
- expect(() => readConfig({ params: { cdnUrl: 'https://abc1234567890.cloudfront.net/script.js', protectionMode: '123' } })).to.throw(ConfigError);
- });
-
- it('should accept valid configurations', function() {
- expect(() => readConfig({ params: { cdnUrl: 'https://abc1234567890.cloudfront.net/script.js', protectionMode: 'full' } })).to.not.throw();
- expect(() => readConfig({ params: { cdnUrl: 'https://abc1234567890.cloudfront.net/script.js', protectionMode: 'bids' } })).to.not.throw();
- expect(() => readConfig({ params: { cdnUrl: 'https://abc1234567890.cloudfront.net/script.js', protectionMode: 'bids-nowait' } })).to.not.throw();
- });
- });
-
- describe('Module initialization step', function() {
- let insertElementStub;
- beforeEach(function() {
- insertElementStub = sinon.stub(utils, 'insertElement');
- });
- afterEach(function() {
- utils.insertElement.restore();
- });
-
- it('pageInitStepPreloadScript() should insert link/preload element', function() {
- pageInitStepPreloadScript(fakeScriptURL);
-
- sinon.assert.calledOnce(insertElementStub);
- sinon.assert.calledWith(insertElementStub, sinon.match(elem => elem.tagName === 'LINK'));
- sinon.assert.calledWith(insertElementStub, sinon.match(elem => elem.rel === 'preload'));
- sinon.assert.calledWith(insertElementStub, sinon.match(elem => elem.as === 'script'));
- sinon.assert.calledWith(insertElementStub, sinon.match(elem => elem.href === fakeScriptURL));
- });
-
- it('pageInitStepProtectPage() should insert script element', function() {
- pageInitStepProtectPage(fakeScriptURL, 'clean.io');
-
- sinon.assert.calledOnce(loadExternalScriptStub);
- sinon.assert.calledWith(loadExternalScriptStub, fakeScriptURL, MODULE_TYPE_RTD, 'clean.io');
- });
- });
-
- function ensurePrependToBidResponse(fakeBidResponse) {
- expect(fakeBidResponse).to.have.own.property('ad').which.is.a('string');
- expect(fakeBidResponse.ad).to.contain('');
- }
-
- function ensureWrapBidResponse(fakeBidResponse, scriptUrl) {
- expect(fakeBidResponse).to.have.own.property('ad').which.is.a('string');
- expect(fakeBidResponse.ad).to.contain(`src="${scriptUrl}"`);
- expect(fakeBidResponse.ad).to.contain('agent.put(ad)');
- }
-
- describe('Bid processing step', function() {
- it('bidWrapStepAugmentHtml() should prepend bid-specific information in a comment', function() {
- const fakeBidResponse = makeFakeBidResponse();
- bidWrapStepAugmentHtml(fakeBidResponse);
- ensurePrependToBidResponse(fakeBidResponse);
- });
-
- it('bidWrapStepProtectByWrapping() should wrap payload into a script tag', function() {
- const fakeBidResponse = makeFakeBidResponse();
- bidWrapStepProtectByWrapping(fakeScriptURL, 0, fakeBidResponse);
- ensureWrapBidResponse(fakeBidResponse, fakeScriptURL);
- });
- });
-
- describe('Submodule execution', function() {
- let submoduleStub;
- let insertElementStub;
- beforeEach(function () {
- submoduleStub = sinon.stub(hook, 'submodule');
- insertElementStub = sinon.stub(utils, 'insertElement');
- });
- afterEach(function () {
- utils.insertElement.restore();
- submoduleStub.restore();
- });
-
- function getModule() {
- beforeInit();
-
- expect(submoduleStub.calledOnceWith('realTimeData')).to.equal(true);
-
- const registeredSubmoduleDefinition = submoduleStub.getCall(0).args[1];
- expect(registeredSubmoduleDefinition).to.be.an('object');
- expect(registeredSubmoduleDefinition).to.have.own.property('name', 'clean.io');
- expect(registeredSubmoduleDefinition).to.have.own.property('init').that.is.a('function');
- expect(registeredSubmoduleDefinition).to.have.own.property('onBidResponseEvent').that.is.a('function');
-
- return registeredSubmoduleDefinition;
- }
-
- it('should register clean.io RTD submodule provider', function () {
- getModule();
- });
-
- it('should refuse initialization with incorrect parameters', function () {
- const { init } = getModule();
- expect(init({ params: { cdnUrl: 'abc', protectionMode: 'full' } }, {})).to.equal(false); // too short distribution name
- sinon.assert.notCalled(loadExternalScriptStub);
- });
-
- it('should initialize in full (page) protection mode', function () {
- const { init, onBidResponseEvent } = getModule();
- expect(init({ params: { cdnUrl: 'https://abc1234567890.cloudfront.net/script.js', protectionMode: 'full' } }, {})).to.equal(true);
- sinon.assert.calledOnce(loadExternalScriptStub);
- sinon.assert.calledWith(loadExternalScriptStub, 'https://abc1234567890.cloudfront.net/script.js', MODULE_TYPE_RTD, 'clean.io');
-
- const fakeBidResponse = makeFakeBidResponse();
- onBidResponseEvent(fakeBidResponse, {}, {});
- ensurePrependToBidResponse(fakeBidResponse);
- });
-
- it('should iniitalize in bids (frame) protection mode', function () {
- const { init, onBidResponseEvent } = getModule();
- expect(init({ params: { cdnUrl: 'https://abc1234567890.cloudfront.net/script.js', protectionMode: 'bids' } }, {})).to.equal(true);
- sinon.assert.calledOnce(insertElementStub);
- sinon.assert.calledWith(insertElementStub, sinon.match(elem => elem.tagName === 'LINK'));
-
- const fakeBidResponse = makeFakeBidResponse();
- onBidResponseEvent(fakeBidResponse, {}, {});
- ensureWrapBidResponse(fakeBidResponse, 'https://abc1234567890.cloudfront.net/script.js');
- });
-
- it('should respect preload status in bids-nowait protection mode', function () {
- const { init, onBidResponseEvent } = getModule();
- expect(init({ params: { cdnUrl: 'https://abc1234567890.cloudfront.net/script.js', protectionMode: 'bids-nowait' } }, {})).to.equal(true);
- sinon.assert.calledOnce(insertElementStub);
- sinon.assert.calledWith(insertElementStub, sinon.match(elem => elem.tagName === 'LINK'));
- const preloadLink = insertElementStub.getCall(0).args[0];
- expect(preloadLink).to.have.property('onload').which.is.a('function');
- expect(preloadLink).to.have.property('onerror').which.is.a('function');
-
- const fakeBidResponse1 = makeFakeBidResponse();
- onBidResponseEvent(fakeBidResponse1, {}, {});
- ensurePrependToBidResponse(fakeBidResponse1);
-
- // Simulate successful preloading
- preloadLink.onload();
-
- const fakeBidResponse2 = makeFakeBidResponse();
- onBidResponseEvent(fakeBidResponse2, {}, {});
- ensureWrapBidResponse(fakeBidResponse2, 'https://abc1234567890.cloudfront.net/script.js');
-
- // Simulate error
- preloadLink.onerror();
-
- // Now we should fallback to just prepending
- const fakeBidResponse3 = makeFakeBidResponse();
- onBidResponseEvent(fakeBidResponse3, {}, {});
- ensurePrependToBidResponse(fakeBidResponse3);
- });
-
- it('should send billable event per bid won event', function () {
- const { init } = getModule();
- expect(init({ params: { cdnUrl: 'https://abc1234567890.cloudfront.net/script.js', protectionMode: 'full' } }, {})).to.equal(true);
-
- const eventCounter = { registerCleanioBillingEvent: function() {} };
- sinon.spy(eventCounter, 'registerCleanioBillingEvent');
-
- events.on(EVENTS.BILLABLE_EVENT, (evt) => {
- if (evt.vendor === 'clean.io') {
- eventCounter.registerCleanioBillingEvent()
- }
- });
-
- events.emit(EVENTS.BID_WON, {});
- events.emit(EVENTS.BID_WON, {});
- events.emit(EVENTS.BID_WON, {});
- events.emit(EVENTS.BID_WON, {});
-
- sinon.assert.callCount(eventCounter.registerCleanioBillingEvent, 4);
- });
- });
-});
diff --git a/test/spec/modules/clickforceBidAdapter_spec.js b/test/spec/modules/clickforceBidAdapter_spec.js
deleted file mode 100644
index 42b0f6e50..000000000
--- a/test/spec/modules/clickforceBidAdapter_spec.js
+++ /dev/null
@@ -1,201 +0,0 @@
-import { expect } from 'chai';
-import { spec } from 'modules/clickforceBidAdapter.js';
-import { newBidder } from 'src/adapters/bidderFactory.js';
-
-describe('ClickforceAdapter', function () {
- const adapter = newBidder(spec);
-
- describe('inherited functions', function () {
- it('exists and is a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('isBidRequestValid', function () {
- const bid = {
- 'bidder': 'clickforce',
- 'params': {
- 'zone': '6682'
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [
- [300, 250]
- ],
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475'
- };
-
- it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should return false when required params are not passed', function () {
- const invalidBid = Object.assign({}, bid);
- delete invalidBid.params;
- invalidBid.params = {
- 'someIncorrectParam': 0
- };
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
- });
-
- describe('buildRequests', function () {
- const bidRequests = [{
- 'bidder': 'clickforce',
- 'params': {
- 'zone': '6682'
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [
- [300, 250]
- ],
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475'
- }];
-
- const request = spec.buildRequests(bidRequests);
-
- it('sends bid request to our endpoint via POST', function () {
- expect(request.method).to.equal('POST');
- });
- });
-
- describe('interpretResponse', function () {
- const response = [{
- 'cpm': 0.5,
- 'width': '300',
- 'height': '250',
- 'callback_uid': '220ed41385952a',
- 'type': 'Default Ad',
- 'tag': '',
- 'creativeId': '1f99ac5c3ef10a4097499a5686b30aff-6682',
- 'requestId': '220ed41385952a',
- 'currency': 'USD',
- 'ttl': 60,
- 'netRevenue': true,
- 'zone': '6682',
- 'adomain': [
- 'www.example.com'
- ]
- }];
-
- const response1 = [{
- 'cpm': 0.0625,
- 'width': '3',
- 'height': '3',
- 'callback_uid': '2e27ec595bf1a',
- 'type': 'public Bid',
- 'tag': {
- 'content': {
- 'title': 'title',
- 'content': 'content',
- 'advertiser': 'advertiser',
- 'button_text': 'button_text',
- 'image': 'image',
- 'icon': 'icon'
- },
- 'cu': ['cu'],
- 'iu': ['iu'],
- 'p': '6878:11062:32586:8380573788dad9b9fc17edde444c4dcf:2795'
- },
- 'creativeId': '8380573788dad9b9fc17edde444c4dcf-6878',
- 'requestId': '2e27ec595bf1a',
- 'currency': 'USD',
- 'ttl': 60,
- 'netRevenue': true,
- 'zone': '6878'
- }];
-
- const expectedResponse = [{
- 'requestId': '220ed41385952a',
- 'cpm': 0.5,
- 'width': '300',
- 'height': '250',
- 'creativeId': '1f99ac5c3ef10a4097499a5686b30aff-6682',
- 'currency': 'USD',
- 'netRevenue': true,
- 'ttl': 60,
- 'ad': '',
- 'mediaType': 'banner',
- 'meta': {
- 'advertiserDomains': [
- 'www.example.com'
- ]
- }
- }];
-
- const expectedResponse1 = [{
- 'requestId': '2e27ec595bf1a',
- 'cpm': 0.0625,
- 'width': '3',
- 'height': '3',
- 'creativeId': '8380573788dad9b9fc17edde444c4dcf-6878',
- 'currency': 'USD',
- 'netRevenue': true,
- 'ttl': 60,
- 'mediaType': 'native',
- 'native': {
- 'image': {
- 'url': 'image',
- 'width': 1600,
- 'height': 900
- },
- 'title': 'title',
- 'sponsoredBy': 'advertiser',
- 'body': 'content',
- 'icon': {
- 'url': 'icon',
- 'width': 900,
- 'height': 900
- },
- 'clickUrl': 'cu',
- 'impressionTrackers': ['iu']
- },
- 'meta': {
- 'advertiserDomains': []
- }
- }];
-
- it('should get the correct bid response by display ad', function () {
- let bidderRequest;
- const result = spec.interpretResponse({ body: response }, {bidderRequest});
- expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0]));
- });
-
- it('should get the correct bid response by native ad', function () {
- let bidderRequest;
- const result = spec.interpretResponse({ body: response1 }, {bidderRequest});
- expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse1[0]));
- });
-
- it('handles empty bid response', function () {
- const response = {
- body: {}
- };
- const result = spec.interpretResponse(response);
- expect(result.length).to.equal(0);
- });
- });
-
- describe('getUserSyncs function', function () {
- it('should register type is iframe', function () {
- const syncOptions = {
- 'iframeEnabled': 'true'
- }
- const userSync = spec.getUserSyncs(syncOptions);
- expect(userSync[0].type).to.equal('iframe');
- expect(userSync[0].url).to.equal('https://cdn.holmesmind.com/js/capmapping.htm');
- });
-
- it('should register type is image', function () {
- const syncOptions = {
- 'pixelEnabled': 'true'
- }
- const userSync = spec.getUserSyncs(syncOptions);
- expect(userSync[0].type).to.equal('image');
- expect(userSync[0].url).to.equal('https://c.holmesmind.com/cm');
- });
- });
-});
diff --git a/test/spec/modules/codefuelBidAdapter_spec.js b/test/spec/modules/codefuelBidAdapter_spec.js
deleted file mode 100644
index 4e891c8ce..000000000
--- a/test/spec/modules/codefuelBidAdapter_spec.js
+++ /dev/null
@@ -1,326 +0,0 @@
-import {expect} from 'chai';
-import {spec} from 'modules/codefuelBidAdapter.js';
-import {config} from 'src/config.js';
-import * as utils from 'src/utils.js';
-import {server} from 'test/mocks/xhr';
-
-const USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/92.0.4515.159 Safari/537.36';
-const DEFAULT_USER_AGENT = window.navigator.userAgent;
-const setUADefault = () => { window.navigator.__defineGetter__('userAgent', function () { return DEFAULT_USER_AGENT }) };
-const setUAMock = () => { window.navigator.__defineGetter__('userAgent', function () { return USER_AGENT }) };
-
-describe('Codefuel Adapter', function () {
- let sandbox;
- beforeEach(() => {
- sandbox = sinon.createSandbox();
- });
- afterEach(() => {
- sandbox.restore();
- })
- describe('Bid request and response', function () {
- const commonBidRequest = {
- bidder: 'codefuel',
- params: {
- publisher: {
- id: 'publisher-id'
- },
- },
- bidId: '2d6815a92ba1ba',
- auctionId: '12043683-3254-4f74-8934-f941b085579e',
- }
- const nativeBidRequestParams = {
- nativeParams: {
- image: {
- required: true,
- sizes: [
- 120,
- 100
- ],
- sendId: true
- },
- title: {
- required: true,
- sendId: true
- },
- sponsoredBy: {
- required: false
- }
- },
- }
-
- const displayBidRequestParams = {
- sizes: [
- [
- 300,
- 250
- ]
- ]
- }
-
- describe('isBidRequestValid', function () {
- before(() => {
- config.setConfig({
- codefuel: {
- bidderUrl: 'https://bidder-url.com',
- }
- }
- )
- })
- after(() => {
- config.resetConfig()
- })
-
- it('should fail when bid is invalid', function () {
- const bid = {
- bidder: 'codefuel',
- params: {
- publisher: {
- id: 'publisher-id',
- }
- },
- }
- expect(spec.isBidRequestValid(bid)).to.equal(false)
- })
- it('should not succeed when bid contains native params', function () {
- const bid = {
- bidder: 'codefuel',
- params: {
- publisher: {
- id: 'publisher-id',
- }
- },
- ...nativeBidRequestParams,
- }
- expect(spec.isBidRequestValid(bid)).to.equal(false)
- })
- it('should not succeed when bid contains only sizes', function () {
- const bid = {
- bidder: 'codefuel',
- params: {
- publisher: {
- id: 'publisher-id',
- }
- },
- ...displayBidRequestParams,
- }
- expect(spec.isBidRequestValid(bid)).to.equal(false)
- })
- it('should fail if publisher id is not set', function () {
- const bid = {
- bidder: 'codefuel',
- ...nativeBidRequestParams,
- }
- expect(spec.isBidRequestValid(bid)).to.equal(false)
- })
-
- it('should fail if bidder url is not set', function () {
- const bid = {
- bidder: 'codefuel',
- params: {
- publisher: {
- id: 'publisher-id',
- }
- },
- ...nativeBidRequestParams,
- }
- config.resetConfig()
- expect(spec.isBidRequestValid(bid)).to.equal(false)
- })
- })
-
- describe('buildRequests', function () {
- before(() => {
- setUAMock()
- config.setConfig({
- codefuel: {
- bidderUrl: 'https://bidder-url.com',
- }
- }
- )
- })
- after(() => {
- config.resetConfig()
- setUADefault()
- })
-
- const commonBidderRequest = {
- timeout: 500,
- bidderRequestId: 'mock-uuid',
- auctionId: '12043683-3254-4f74-8934-f941b085579e',
- refererInfo: {
- page: 'https://example.com/',
- domain: 'example.com'
- }
- }
-
- it('should build display request', function () {
- const bidRequest = {
- ...commonBidRequest,
- ...displayBidRequestParams,
- }
- const expectedData = {
- cur: [
- 'USD'
- ],
- device: {
- devicetype: 2,
- ua: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/92.0.4515.159 Safari/537.36'
- },
- id: 'mock-uuid',
- imp: [
- {
- banner: {
- format: [
- {
- h: 250,
- w: 300
- }
- ]
- },
- id: '1'
- }
- ],
- site: {
- domain: 'example.com',
- page: 'https://example.com/',
- publisher: {
- id: 'publisher-id'
- }
- },
- source: {
- fd: 1
- },
- tmax: 500
- }
- const res = spec.buildRequests([bidRequest], commonBidderRequest)
- expect(res.url).to.equal('https://ai-p-codefuel-ds-rtb-us-east-1-k8s.seccint.com/prebid')
- expect(res.data).to.deep.equal(expectedData)
- })
-
- it('should pass bidder timeout', function () {
- const bidRequest = {
- ...commonBidRequest,
- }
- const bidderRequest = {
- ...commonBidderRequest,
- timeout: 500
- }
- const res = spec.buildRequests([bidRequest], bidderRequest)
- const resData = res.data
- expect(resData.tmax).to.equal(500)
- });
- })
-
- describe('interpretResponse', function () {
- it('should return empty array if no valid bids', function () {
- const res = spec.interpretResponse({}, [])
- expect(res).to.be.an('array').that.is.empty
- });
-
- it('should interpret display response', function () {
- const serverResponse = {
- body: {
- id: '6b2eedc8-8ff5-46ef-adcf-e701b508943e',
- seatbid: [
- {
- bid: [
- {
- id: 'd90fe7fa-28d7-11eb-8ce4-462a842a7cf9',
- impid: '1',
- price: 1.1,
- nurl: 'http://example.com/win/${AUCTION_PRICE}',
- adm: '
ad
',
- adomain: [
- 'example.com'
- ],
- cid: '3865084',
- crid: '29998660',
- cat: [
- 'IAB10-2'
- ],
- w: 300,
- h: 250
- }
- ],
- seat: 'acc-6536'
- }
- ],
- bidid: 'd90fe7fa-28d7-11eb-8ce4-13d94bfa26f9',
- cur: 'USD'
- }
- }
- const request = {
- bids: [
- {
- ...commonBidRequest,
- ...displayBidRequestParams
- }
- ]
- }
- const expectedRes = [
- {
- requestId: request.bids[0].bidId,
- cpm: 1.1,
- creativeId: '29998660',
- ttl: 360,
- netRevenue: true,
- currency: 'USD',
- mediaType: 'banner',
- ad: 'ad
',
- width: 300,
- height: 250,
- meta: {'advertiserDomains': []}
- }
- ]
-
- const res = spec.interpretResponse(serverResponse, request)
- expect(res).to.deep.equal(expectedRes)
- });
- })
- })
-
- describe('getUserSyncs', function () {
- const usersyncUrl = 'https://usersync-url.com';
- beforeEach(() => {
- config.setConfig({
- codefuel: {
- usersyncUrl: usersyncUrl,
- }
- }
- )
- })
- after(() => {
- config.resetConfig()
- })
-
- it('should not return user sync if pixel enabled with codefuel config', function () {
- const ret = spec.getUserSyncs({pixelEnabled: true})
- expect(ret).to.be.an('array').that.is.empty
- })
-
- it('should not return user sync if pixel disabled', function () {
- const ret = spec.getUserSyncs({pixelEnabled: false})
- expect(ret).to.be.an('array').that.is.empty
- })
-
- it('should not return user sync if url is not set', function () {
- config.resetConfig()
- const ret = spec.getUserSyncs({pixelEnabled: true})
- expect(ret).to.be.an('array').that.is.empty
- })
-
- it('should not pass GDPR consent', function() {
- expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, undefined)).to.to.be.an('array').that.is.empty
- expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: false, consentString: 'foo'}, undefined)).to.be.an('array').that.is.empty
- expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: undefined}, undefined)).to.be.an('array').that.is.empty
- });
-
- it('should not pass US consent', function() {
- expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined, '1NYN')).to.be.an('array').that.is.empty
- });
-
- it('should pass GDPR and US consent', function() {
- expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, '1NYN')).to.be.an('array').that.is.empty
- });
- })
-})
diff --git a/test/spec/modules/cointrafficBidAdapter_spec.js b/test/spec/modules/cointrafficBidAdapter_spec.js
deleted file mode 100644
index e90216d96..000000000
--- a/test/spec/modules/cointrafficBidAdapter_spec.js
+++ /dev/null
@@ -1,341 +0,0 @@
-import sinon from 'sinon'
-import { expect } from 'chai';
-import { spec } from 'modules/cointrafficBidAdapter.js';
-import { config } from 'src/config.js'
-import * as utils from 'src/utils.js'
-
-/**
- * @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest
- * @typedef {import('../src/adapters/bidderFactory.js').BidderRequest} BidderRequest
- */
-
-const ENDPOINT_URL = 'https://apps-pbd.ctraffic.io/pb/tmp';
-
-describe('cointrafficBidAdapter', function () {
- describe('isBidRequestValid', function () {
- /** @type {BidRequest} */
- const bidRequest = {
- bidder: 'cointraffic',
- params: {
- placementId: 'testPlacementId'
- },
- adUnitCode: 'adunit-code',
- sizes: [
- [300, 250]
- ],
- bidId: 'bidId12345',
- bidderRequestId: 'bidderRequestId12345',
- auctionId: 'auctionId12345'
- };
-
- it('should return true where required params found', function () {
- expect(spec.isBidRequestValid(bidRequest)).to.equal(true);
- });
- });
-
- describe('buildRequests', function () {
- /** @type {BidRequest[]} */
- const bidRequests = [
- {
- bidder: 'cointraffic',
- params: {
- placementId: 'testPlacementId'
- },
- adUnitCode: 'adunit-code',
- sizes: [
- [300, 250]
- ],
- bidId: 'bidId12345',
- bidderRequestId: 'bidderRequestId12345',
- auctionId: 'auctionId12345'
- },
- {
- bidder: 'cointraffic',
- params: {
- placementId: 'testPlacementId'
- },
- adUnitCode: 'adunit-code2',
- sizes: [
- [300, 250]
- ],
- bidId: 'bidId67890"',
- bidderRequestId: 'bidderRequestId67890',
- auctionId: 'auctionId12345'
- }
- ];
-
- /** @type {BidderRequest} */
- const bidderRequest = {
- refererInfo: {
- numIframes: 0,
- reachedTop: true,
- referer: 'https://example.com',
- stack: [
- 'https://example.com'
- ]
- }
- };
-
- it('replaces currency with EUR if there is no currency provided', function () {
- const request = spec.buildRequests(bidRequests, bidderRequest);
-
- expect(request[0].data.currency).to.equal('EUR');
- expect(request[1].data.currency).to.equal('EUR');
- });
-
- it('replaces currency with EUR if there is no currency provided', function () {
- const getConfigStub = sinon.stub(config, 'getConfig').callsFake(
- arg => arg === 'currency.bidderCurrencyDefault.cointraffic' ? 'USD' : 'EUR'
- );
-
- const request = spec.buildRequests(bidRequests, bidderRequest);
-
- expect(request[0].data.currency).to.equal('USD');
- expect(request[1].data.currency).to.equal('USD');
-
- getConfigStub.restore();
- });
-
- it('throws an error if currency provided in params is not allowed', function () {
- const utilsMock = sinon.mock(utils)
- utilsMock.expects('logError').twice()
- const getConfigStub = sinon.stub(config, 'getConfig').callsFake(
- arg => arg === 'currency.bidderCurrencyDefault.cointraffic' ? 'BTC' : 'EUR'
- );
-
- const request = spec.buildRequests(bidRequests, bidderRequest);
-
- expect(request[0]).to.undefined;
- expect(request[1]).to.undefined;
-
- utilsMock.restore()
- getConfigStub.restore();
- });
-
- it('sends bid request to our endpoint via POST', function () {
- const request = spec.buildRequests(bidRequests, bidderRequest);
-
- expect(request[0].method).to.equal('POST');
- expect(request[1].method).to.equal('POST');
- });
-
- it('attaches source and version to endpoint URL as query params', function () {
- const request = spec.buildRequests(bidRequests, bidderRequest);
-
- expect(request[0].url).to.equal(ENDPOINT_URL);
- expect(request[1].url).to.equal(ENDPOINT_URL);
- });
- });
-
- describe('interpretResponse', function () {
- it('should get the correct bid response', function () {
- /** @type {BidRequest[]} */
- const bidRequest = [{
- method: 'POST',
- url: ENDPOINT_URL,
- data: {
- placementId: 'testPlacementId',
- device: 'desktop',
- currency: 'EUR',
- sizes: ['300x250'],
- bidId: 'bidId12345',
- referer: 'www.example.com'
- }
- }];
-
- const serverResponse = {
- body: {
- requestId: 'bidId12345',
- cpm: 3.9,
- currency: 'EUR',
- netRevenue: true,
- width: 300,
- height: 250,
- creativeId: 'creativeId12345',
- ttl: 90,
- ad: 'I am an ad
',
- mediaType: 'banner',
- adomain: ['test.com']
- }
- };
-
- const expectedResponse = [{
- requestId: 'bidId12345',
- cpm: 3.9,
- currency: 'EUR',
- netRevenue: true,
- width: 300,
- height: 250,
- creativeId: 'creativeId12345',
- ttl: 90,
- ad: 'I am an ad
',
- meta: {
- mediaType: 'banner',
- advertiserDomains: [
- 'test.com',
- ]
- }
- }];
-
- const result = spec.interpretResponse(serverResponse, bidRequest[0]);
- expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse));
- });
-
- it('should get the correct bid response without advertiser domains specified', function () {
- /** @type {BidRequest[]} */
- const bidRequest = [{
- method: 'POST',
- url: ENDPOINT_URL,
- data: {
- placementId: 'testPlacementId',
- device: 'desktop',
- currency: 'EUR',
- sizes: ['300x250'],
- bidId: 'bidId12345',
- referer: 'www.example.com'
- }
- }];
-
- const serverResponse = {
- body: {
- requestId: 'bidId12345',
- cpm: 3.9,
- currency: 'EUR',
- netRevenue: true,
- width: 300,
- height: 250,
- creativeId: 'creativeId12345',
- ttl: 90,
- ad: 'I am an ad
',
- mediaType: 'banner',
- }
- };
-
- const expectedResponse = [{
- requestId: 'bidId12345',
- cpm: 3.9,
- currency: 'EUR',
- netRevenue: true,
- width: 300,
- height: 250,
- creativeId: 'creativeId12345',
- ttl: 90,
- ad: 'I am an ad
',
- meta: {
- mediaType: 'banner',
- advertiserDomains: []
- }
- }];
-
- const result = spec.interpretResponse(serverResponse, bidRequest[0]);
- expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse));
- });
-
- it('should get the correct bid response with different currency', function () {
- /** @type {BidRequest[]} */
- const bidRequest = [{
- method: 'POST',
- url: ENDPOINT_URL,
- data: {
- placementId: 'testPlacementId',
- device: 'desktop',
- currency: 'USD',
- sizes: ['300x250'],
- bidId: 'bidId12345',
- referer: 'www.example.com'
- }
- }];
-
- const serverResponse = {
- body: {
- requestId: 'bidId12345',
- cpm: 3.9,
- currency: 'USD',
- netRevenue: true,
- width: 300,
- height: 250,
- creativeId: 'creativeId12345',
- ttl: 90,
- ad: 'I am an ad
',
- mediaType: 'banner',
- adomain: ['test.com']
- }
- };
-
- const expectedResponse = [{
- requestId: 'bidId12345',
- cpm: 3.9,
- currency: 'USD',
- netRevenue: true,
- width: 300,
- height: 250,
- creativeId: 'creativeId12345',
- ttl: 90,
- ad: 'I am an ad
',
- meta: {
- mediaType: 'banner',
- advertiserDomains: [
- 'test.com',
- ]
- }
- }];
-
- const getConfigStub = sinon.stub(config, 'getConfig').returns('USD');
-
- const result = spec.interpretResponse(serverResponse, bidRequest[0]);
- expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse));
-
- getConfigStub.restore();
- });
-
- it('should get empty bid response requested currency is not available', function () {
- /** @type {BidRequest[]} */
- const bidRequest = [{
- method: 'POST',
- url: ENDPOINT_URL,
- data: {
- placementId: 'testPlacementId',
- device: 'desktop',
- currency: 'BTC',
- sizes: ['300x250'],
- bidId: 'bidId12345',
- referer: 'www.example.com'
- }
- }];
-
- const serverResponse = {};
-
- const expectedResponse = [];
-
- const getConfigStub = sinon.stub(config, 'getConfig').returns('BTC');
-
- const result = spec.interpretResponse(serverResponse, bidRequest[0]);
- expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse));
-
- getConfigStub.restore();
- });
-
- it('should get empty bid response if no server response', function () {
- /** @type {BidRequest[]} */
- const bidRequest = [{
- method: 'POST',
- url: ENDPOINT_URL,
- data: {
- placementId: 'testPlacementId',
- device: 'desktop',
- currency: 'EUR',
- sizes: ['300x250'],
- bidId: 'bidId12345',
- referer: 'www.example.com'
- }
- }];
-
- const serverResponse = {};
-
- const expectedResponse = [];
-
- const result = spec.interpretResponse(serverResponse, bidRequest[0]);
- expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse));
- });
- });
-});
diff --git a/test/spec/modules/coinzillaBidAdapter_spec.js b/test/spec/modules/coinzillaBidAdapter_spec.js
deleted file mode 100644
index 08d6c8aed..000000000
--- a/test/spec/modules/coinzillaBidAdapter_spec.js
+++ /dev/null
@@ -1,123 +0,0 @@
-import {assert, expect} from 'chai';
-import {spec} from 'modules/coinzillaBidAdapter.js';
-import {newBidder} from 'src/adapters/bidderFactory.js';
-
-const ENDPOINT_URL = 'https://request.czilladx.com/serve/request.php';
-
-describe('coinzillaBidAdapter', function () {
- const adapter = newBidder(spec);
- describe('isBidRequestValid', function () {
- const bid = {
- 'bidder': 'coinzilla',
- 'params': {
- placementId: 'testPlacementId'
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [
- [300, 250]
- ],
- 'bidId': '1234asdf1234',
- 'bidderRequestId': '1234asdf1234asdf',
- 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf120'
- };
- it('should return true where required params found', function () {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
- });
- describe('buildRequests', function () {
- const bidRequests = [
- {
- 'bidder': 'coinzilla',
- 'params': {
- placementId: 'testPlacementId'
- },
- 'sizes': [
- [300, 250]
- ],
- 'bidId': '23beaa6af6cdde',
- 'bidderRequestId': '19c0c1efdf37e7',
- 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1',
- },
- {
- 'bidder': 'coinzilla',
- 'params': {
- placementId: 'testPlacementId'
- },
- 'adUnitCode': 'adunit-code2',
- 'sizes': [
- [300, 250]
- ],
- 'bidId': '382091349b149f"',
- 'bidderRequestId': '1f9c98192de251',
- 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1',
- }
- ];
-
- const bidderRequests = {
- 'refererInfo': {
- 'numIframes': 0,
- 'reachedTop': true,
- 'referer': 'https://example.com',
- 'stack': ['https://example.com']
- }
- };
-
- const request = spec.buildRequests(bidRequests, bidderRequests);
- it('sends bid request to our endpoint via POST', function () {
- expect(request[0].method).to.equal('POST');
- expect(request[1].method).to.equal('POST');
- });
- it('attaches source and version to endpoint URL as query params', function () {
- expect(request[0].url).to.equal(ENDPOINT_URL);
- expect(request[1].url).to.equal(ENDPOINT_URL);
- });
- });
-
- describe('interpretResponse', function () {
- const bidRequest = [
- {
- 'method': 'POST',
- 'url': ENDPOINT_URL,
- 'data': {
- 'placementId': 'testPlacementId',
- 'width': '300',
- 'height': '200',
- 'bidId': 'bidId123',
- 'referer': 'www.example.com'
- }
- }
- ];
- const serverResponse = {
- body: {
- 'ad': 'I am an ad
',
- 'cpm': 4.2,
- 'creativeId': '12345asdfg',
- 'currency': 'EUR',
- 'statusMessage': 'Bid available',
- 'requestId': 'bidId123',
- 'width': 300,
- 'height': 250,
- 'netRevenue': true,
- 'mediaType': 'banner',
- 'advertiserDomain': ['none.com']
- }
- };
- it('should get the correct bid response', function () {
- const expectedResponse = [{
- 'requestId': 'bidId123',
- 'cpm': 4.2,
- 'width': 300,
- 'height': 250,
- 'creativeId': '12345asdfg',
- 'currency': 'EUR',
- 'netRevenue': true,
- 'ttl': 3000,
- 'ad': 'I am an ad
',
- 'mediaType': 'banner',
- 'meta': {'advertiserDomains': ['none.com']}
- }];
- const result = spec.interpretResponse(serverResponse, bidRequest[0]);
- expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse));
- });
- });
-});
diff --git a/test/spec/modules/colombiaBidAdapter_spec.js b/test/spec/modules/colombiaBidAdapter_spec.js
deleted file mode 100644
index c4e00351f..000000000
--- a/test/spec/modules/colombiaBidAdapter_spec.js
+++ /dev/null
@@ -1,278 +0,0 @@
-import { expect } from 'chai';
-import { spec } from 'modules/colombiaBidAdapter';
-import { newBidder } from 'src/adapters/bidderFactory';
-import * as ajaxLib from 'src/ajax.js';
-
-const HOST_NAME = document.location.protocol + '//' + window.location.host;
-const ENDPOINT = 'https://ade.clmbtech.com/cde/prebid.htm';
-
-describe('colombiaBidAdapter', function () {
- const adapter = newBidder(spec);
-
- describe('isBidRequestValid', function () {
- const bid = {
- 'bidder': 'colombia',
- 'params': {
- placementId: '307466'
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [
- [300, 250]
- ],
- 'bidId': '23beaa6af6cdde',
- 'bidderRequestId': '19c0c1efdf37e7',
- 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1',
- };
-
- it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should return false when placementId not passed correctly', function () {
- bid.params.placementId = '';
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should return false when require params are not passed', function () {
- const invalidBid = Object.assign({}, bid);
- invalidBid.params = {};
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
- });
-
- describe('buildRequests', function () {
- const bidRequests = [
- {
- 'bidder': 'colombia',
- 'params': {
- placementId: '307466'
- },
- 'adUnitCode': 'adunit-code1',
- 'sizes': [
- [300, 250]
- ],
- 'bidId': '23beaa6af6cdde',
- 'bidderRequestId': '19c0c1efdf37e7',
- 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1',
- },
- {
- 'bidder': 'colombia',
- 'params': {
- placementId: '307466'
- },
- 'adUnitCode': 'adunit-code2',
- 'sizes': [
- [300, 250]
- ],
- 'bidId': '382091349b149f"',
- 'bidderRequestId': '"1f9c98192de2511"',
- 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1',
- }
- ];
- const bidderRequest = {
- refererInfo: {
- numIframes: 0,
- reachedTop: true,
- referer: 'http://example.com',
- stack: ['http://example.com']
- }
- };
-
- const request = spec.buildRequests(bidRequests);
- it('sends bid request to our endpoint via POST', function () {
- expect(request[0].method).to.equal('POST');
- });
-
- it('attaches source and version to endpoint URL as query params', function () {
- expect(request[0].url).to.equal(ENDPOINT);
- });
- });
-
- describe('interpretResponse', function () {
- const bidRequest = [
- {
- 'method': 'POST',
- 'url': 'https://ade.clmbtech.com/cde/prebid.htm',
- 'data': {
- 'v': 'hb1',
- 'p': '307466',
- 'w': '300',
- 'h': '250',
- 'cb': 12892917383,
- 'r': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836',
- 'uid': '23beaa6af6cdde',
- 't': 'i',
- }
- }
- ];
-
- const serverResponse = [{
- 'ad': 'This is test case for colombia adapter
',
- 'cpm': 3.14,
- 'creativeId': '6b958110-612c-4b03-b6a9-7436c9f746dc-1sk24',
- 'currency': 'USD',
- 'requestId': '23beaa6af6cdde',
- 'width': 728,
- 'height': 90,
- 'netRevenue': true,
- 'ttl': 600,
- 'dealid': '',
- 'referrer': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836'
- }];
-
- it('should get the correct bid response', function () {
- const expectedResponse = [{
- 'requestId': '23beaa6af6cdde',
- 'cpm': 3.14,
- 'width': 728,
- 'height': 90,
- 'creativeId': '6b958110-612c-4b03-b6a9-7436c9f746dc-1sk24',
- 'dealId': '',
- 'currency': 'USD',
- 'netRevenue': true,
- 'ttl': 300,
- 'referrer': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836',
- 'ad': 'This is test case for colombia adapter
'
- }];
- const result = spec.interpretResponse(serverResponse, bidRequest[0]);
- expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0]));
- });
-
- it('handles empty bid response', function () {
- const response = {
- body: {
- 'uid': '23beaa6af6cdde',
- 'height': 0,
- 'creativeId': '',
- 'statusMessage': 'Bid returned empty or error response',
- 'width': 0,
- 'cpm': 0
- }
- };
- const result = spec.interpretResponse(response, bidRequest[0]);
- expect(result.length).to.equal(0);
- });
- });
- describe('onBidWon', function () {
- let ajaxStub;
- beforeEach(() => {
- ajaxStub = sinon.stub(ajaxLib, 'ajax');
- });
-
- afterEach(() => {
- ajaxStub.restore();
- });
-
- it('should call ajax with correct URL and encoded evtData when event 500 is present', function () {
- const bid = {
- eventTrackers: [{
- event: 500,
- method: 500,
- url: 'https://ade.clmbtech.com/cde/bidNotify.htm'
- }],
- ext: {
- evtData: 'd_1_%7B%22iId%22%3A%22abc123-impr-id%22%2C%22aId%22%3A%22ad5678%22%2C%22ci%22%3A%22call-id-789%22%2C%22fpc%22%3A%22some-fpc-value%22%2C%22prebid%22%3A1%7D'
- }
- };
- spec.onBidWon(bid);
- expect(ajaxStub.calledOnce).to.be.true;
- const [url, , data, options] = ajaxStub.firstCall.args;
- expect(url).to.equal('https://ade.clmbtech.com/cde/bidNotify.htm');
- const parsedPayload = JSON.parse(data);
- expect(parsedPayload).to.deep.equal({
- bidNotifyType: 1,
- evt: 'd_1_%7B%22iId%22%3A%22abc123-impr-id%22%2C%22aId%22%3A%22ad5678%22%2C%22ci%22%3A%22call-id-789%22%2C%22fpc%22%3A%22some-fpc-value%22%2C%22prebid%22%3A1%7D'
- });
- expect(options).to.deep.include({
- method: 'POST',
- withCredentials: false
- });
- });
- it('should not call ajax if eventTrackers is missing or event 500 not present', function () {
- spec.onBidWon({});
- spec.onBidWon({ eventTrackers: [{ event: 200 }] });
-
- expect(ajaxStub.notCalled).to.be.true;
- });
- });
- describe('onTimeout', function () {
- let ajaxStub;
-
- beforeEach(function () {
- ajaxStub = sinon.stub(ajaxLib, 'ajax');
- });
-
- afterEach(function () {
- ajaxStub.restore();
- });
-
- it('should call ajax with correct payload and pubAdCodeNames from gpid', function () {
- const timeoutData = [
- {
- ortb2Imp: {
- ext: {
- gpid: 'abc#123'
- }
- }
- },
- {
- ortb2Imp: {
- ext: {
- gpid: 'def#456'
- }
- }
- },
- {
- ortb2Imp: {
- ext: {
- gpid: 'ghi#789'
- }
- }
- }
- ];
-
- spec.onTimeout(timeoutData);
-
- expect(ajaxStub.calledOnce).to.be.true;
-
- const [url, , data, options] = ajaxStub.firstCall.args;
-
- expect(url).to.equal('https://ade.clmbtech.com/cde/bidNotify.htm');
-
- const parsedPayload = JSON.parse(data);
- expect(parsedPayload).to.deep.equal({
- bidNotifyType: 2,
- pubAdCodeNames: 'abc,def,ghi'
- });
-
- expect(options).to.deep.include({
- method: 'POST',
- withCredentials: false
- });
- });
-
- it('should not call ajax if timeoutData is null or empty', function () {
- spec.onTimeout(null);
- spec.onTimeout([]);
-
- expect(ajaxStub.notCalled).to.be.true;
- });
-
- it('should skip entries without valid gpid', function () {
- const timeoutData = [
- { ortb2Imp: { ext: { gpid: 'valid#123' } } },
- { ortb2Imp: { ext: {} } },
- { ortb2Imp: {} },
- {},
- ];
-
- spec.onTimeout(timeoutData);
-
- expect(ajaxStub.calledOnce).to.be.true;
- const [, , data] = ajaxStub.firstCall.args;
- const parsed = JSON.parse(data);
-
- expect(parsed.pubAdCodeNames).to.equal('valid');
- });
- });
-});
diff --git a/test/spec/modules/colossussspBidAdapter_spec.js b/test/spec/modules/colossussspBidAdapter_spec.js
deleted file mode 100644
index 9c92661fd..000000000
--- a/test/spec/modules/colossussspBidAdapter_spec.js
+++ /dev/null
@@ -1,459 +0,0 @@
-import { expect } from 'chai';
-import { spec } from '../../../modules/colossussspBidAdapter.js';
-
-describe('ColossussspAdapter', function () {
- const bid = {
- bidId: '2dd581a2b6281d',
- bidder: 'colossusssp',
- bidderRequestId: '145e1d6a7837c9',
- params: {
- placement_id: 0,
- group_id: 0
- },
- placementCode: 'placementid_0',
- auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2',
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
- },
- ortb2Imp: {
- ext: {
- tid: '3bb2f6da-87a6-4029-aeb0-bfe951372e62',
- gpid: '/19968336/prebid_cache_video_adunit',
- data: {}
- }
- },
- ortb2: {
- source: {
- ext: {
- schain: {
- ver: '1.0',
- complete: 1,
- nodes: [
- {
- asi: 'example.com',
- sid: '0',
- hp: 1,
- rid: 'bidrequestid',
- // name: 'alladsallthetime',
- domain: 'example.com'
- }
- ]
- }
- }
- }
- }
- };
- const bidderRequest = {
- bidderCode: 'colossus',
- auctionId: 'fffffff-ffff-ffff-ffff-ffffffffffff',
- bidderRequestId: 'ffffffffffffff',
- start: 1472239426002,
- auctionStart: 1472239426000,
- timeout: 5000,
- uspConsent: '1YN-',
- gdprConsent: {
- consentString: 'xxx',
- gdprApplies: 1
- },
- refererInfo: {
- referer: 'http://www.example.com',
- reachedTop: true,
- },
- ortb2: {
- app: {
- name: 'myappname',
- keywords: 'power tools, drills',
- content: {
- data: [
- {
- name: 'www.dataprovider1.com',
- ext: {
- segtax: 6
- },
- segment: [
- {
- id: '687'
- },
- {
- id: '123'
- }
- ]
- },
- {
- name: 'www.dataprovider1.com',
- ext: {
- segtax: 7
- },
- segment: [
- {
- id: '456'
- },
- {
- id: '789'
- }
- ]
- }
- ]
- }
- },
- site: {
- name: 'example',
- domain: 'page.example.com',
- cat: ['IAB2'],
- sectioncat: ['IAB2-2'],
- pagecat: ['IAB2-2'],
- page: 'https://page.example.com/here.html',
- ref: 'https://ref.example.com',
- keywords: 'power tools, drills',
- search: 'drill',
- content: {
- userrating: '4',
- data: [{
- name: 'www.dataprovider1.com',
- ext: {
- segtax: 7,
- cids: ['iris_c73g5jq96mwso4d8']
- },
- segment: [
- { id: '687' },
- { id: '123' }
- ]
- }]
- },
- ext: {
- data: {
- pageType: 'article',
- category: 'repair'
- }
- }
- },
- user: {
- yob: 1985,
- gender: 'm',
- keywords: 'a,b',
- data: [{
- name: 'dataprovider.com',
- ext: { segtax: 4 },
- segment: [
- { id: '1' }
- ]
- }],
- ext: {
- data: {
- registered: true,
- interests: ['cars']
- }
- }
- }
- },
- bids: [bid]
- }
-
- describe('isBidRequestValid', function () {
- it('Should return true when placement_id can be cast to a number', function () {
- expect(spec.isBidRequestValid(bid)).to.be.true;
- });
- it('Should return false when placement_id is not a number', function () {
- bid.params.placement_id = 'aaa';
- delete bid.params.group_id;
- expect(spec.isBidRequestValid(bid)).to.be.false;
- });
- });
-
- describe('buildRequests', function () {
- let serverRequest = spec.buildRequests([bid], bidderRequest);
- it('Creates a ServerRequest object with method, URL and data', function () {
- expect(serverRequest).to.exist;
- expect(serverRequest.method).to.exist;
- expect(serverRequest.url).to.exist;
- expect(serverRequest.data).to.exist;
- });
- it('Returns POST method', function () {
- expect(serverRequest.method).to.equal('POST');
- });
- it('Returns valid URL', function () {
- expect(serverRequest.url).to.equal('https://colossusssp.com/?c=o&m=multi');
- });
- it('Should contain ccpa', function () {
- expect(serverRequest.data.ccpa).to.be.an('string')
- })
-
- it('Returns valid data if array of bids is valid', function () {
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'ccpa', 'gdpr_consent', 'gdpr_require', 'userObj', 'siteObj', 'appObj');
- expect(data.deviceWidth).to.be.a('number');
- expect(data.deviceHeight).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');
- expect(data.page).to.be.a('string');
- const placements = data['placements'];
- for (let i = 0; i < placements.length; i++) {
- const placement = placements[i];
- expect(placement).to.have.all.keys('placementId', 'groupId', 'eids', 'bidId', 'traffic', 'sizes', 'schain', 'floor', 'gpid', 'tid');
- expect(placement.schain).to.be.an('object')
- expect(placement.placementId).to.be.a('number');
- expect(placement.groupId).to.be.a('number');
- expect(placement.bidId).to.be.a('string');
- expect(placement.traffic).to.be.a('string');
- expect(placement.sizes).to.be.an('array');
- expect(placement.floor).to.be.an('object');
- expect(placement.gpid).to.be.an('string');
- expect(placement.tid).to.be.an('string');
- }
- });
-
- it('Returns valid video data if array of bids is valid', function () {
- const videoBid = {
- ...bid,
- params: {
- placement_id: 0,
- },
- mediaTypes: {
- video: {
- playerSize: [[300, 300]],
- minduration: 5,
- maxduration: 60
- }
- }
- }
- const serverRequest = spec.buildRequests([videoBid], bidderRequest);
-
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'ccpa', 'gdpr_consent', 'gdpr_require', 'userObj', 'siteObj', 'appObj');
- expect(data.deviceWidth).to.be.a('number');
- expect(data.deviceHeight).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');
- expect(data.page).to.be.a('string');
- const placements = data['placements'];
- for (let i = 0; i < placements.length; i++) {
- const placement = placements[i];
- expect(placement).to.have.all.keys('placementId', 'groupId', 'eids', 'bidId', 'traffic', 'schain', 'floor', 'gpid', 'sizes',
- 'playerSize', 'minduration', 'maxduration', 'mimes', 'protocols', 'startdelay', 'placement', 'skip', 'skipafter',
- 'minbitrate', 'maxbitrate', 'delivery', 'playbackmethod', 'api', 'linearity', 'tid'
- );
- expect(placement.schain).to.be.an('object')
- expect(placement.placementId).to.be.a('number');
- expect(placement.bidId).to.be.a('string');
- expect(placement.traffic).to.be.a('string');
- expect(placement.floor).to.be.an('object');
- expect(placement.gpid).to.be.an('string');
- expect(placement.sizes).to.be.an('array');
- expect(placement.playerSize).to.be.an('array');
- expect(placement.minduration).to.be.an('number');
- expect(placement.maxduration).to.be.an('number');
- expect(placement.tid).to.be.an('string');
- }
- });
-
- it('Returns empty data if no valid requests are passed', function () {
- serverRequest = spec.buildRequests([], bidderRequest);
- const data = serverRequest.data;
- expect(data.placements).to.be.an('array').that.is.empty;
- });
- });
-
- describe('buildRequests with user ids', function () {
- var clonedBid = JSON.parse(JSON.stringify(bid));
- clonedBid.userId = {}
- clonedBid.userId.idl_env = 'idl_env123';
- clonedBid.userId.tdid = 'tdid123';
- clonedBid.userId.id5id = { uid: 'id5id123' };
- clonedBid.userId.uid2 = { id: 'uid2id123' };
- clonedBid.userIdAsEids = [
- {
- 'source': 'pubcid.org',
- 'uids': [
- {
- 'id': '4679e98e-1d83-4718-8aba-aa88hhhaaa',
- 'atype': 1
- }
- ]
- },
- {
- 'source': 'adserver.org',
- 'uids': [
- {
- 'id': 'e804908e-57b4-4f46-a097-08be44321e79',
- 'atype': 1,
- 'ext': {
- 'rtiPartner': 'TDID'
- }
- }
- ]
- },
- {
- 'source': 'neustar.biz',
- 'uids': [
- {
- 'id': 'E1:Bvss1x8hXM2zHeqiqj2umJUziavSvLT6E_ORri5fDCsZb-5sfD18oNWycTmdx6QBNdbURBVv466hLJiKSwHCaTxvROo8smjqj6GfvlKfzQI',
- 'atype': 1
- }
- ]
- }
- ];
- const serverRequest = spec.buildRequests([clonedBid], bidderRequest);
- it('Returns valid data if array of bids is valid', function () {
- const data = serverRequest.data;
- const placements = data['placements'];
- expect(data).to.be.an('object');
- for (let i = 0; i < placements.length; i++) {
- const placement = placements[i];
- expect(placement).to.have.property('eids')
- expect(placement.eids).to.be.an('array')
- expect(placement.eids.length).to.be.equal(7)
- for (const index in placement.eids) {
- const v = placement.eids[index];
- expect(v).to.have.all.keys('source', 'uids')
- expect(v.source).to.be.oneOf(['pubcid.org', 'adserver.org', 'neustar.biz', 'identityLink', 'id5-sync.com', 'adserver.org', 'uidapi.com'])
- expect(v.uids).to.be.an('array');
- expect(v.uids.length).to.be.equal(1)
- expect(v.uids[0]).to.have.property('id')
- }
- }
- });
- });
-
- describe('gpp consent', function () {
- it('bidderRequest.gppConsent', () => {
- bidderRequest.gppConsent = {
- gppString: 'abc123',
- applicableSections: [8]
- };
-
- const serverRequest = spec.buildRequests([bid], bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
-
- delete bidderRequest.gppConsent;
- })
-
- it('bidderRequest.ortb2.regs.gpp', () => {
- bidderRequest.ortb2.regs = bidderRequest.ortb2.regs || {};
- bidderRequest.ortb2.regs.gpp = 'abc123';
- bidderRequest.ortb2.regs.gpp_sid = [8];
-
- const serverRequest = spec.buildRequests([bid], bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
- })
- });
-
- describe('interpretResponse', function () {
- const resObject = {
- body: [{
- requestId: '123',
- mediaType: 'banner',
- cpm: 0.3,
- width: 320,
- height: 50,
- ad: 'Hello ad
',
- ttl: 1000,
- creativeId: '123asd',
- netRevenue: true,
- currency: 'USD',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- let serverResponses = spec.interpretResponse(resObject);
- it('Returns an array of valid server responses if response object is valid', function () {
- expect(serverResponses).to.be.an('array').that.is.not.empty;
- for (let i = 0; i < serverResponses.length; i++) {
- const dataItem = serverResponses[i];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'mediaType', 'meta');
- expect(dataItem.requestId).to.be.a('string');
- expect(dataItem.cpm).to.be.a('number');
- expect(dataItem.width).to.be.a('number');
- expect(dataItem.height).to.be.a('number');
- expect(dataItem.ad).to.be.a('string');
- expect(dataItem.ttl).to.be.a('number');
- expect(dataItem.creativeId).to.be.a('string');
- expect(dataItem.netRevenue).to.be.a('boolean');
- expect(dataItem.currency).to.be.a('string');
- expect(dataItem.mediaType).to.be.a('string');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- }
- it('Returns an empty array if invalid response is passed', function () {
- serverResponses = spec.interpretResponse('invalid_response');
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- });
-
- const videoResObject = {
- body: [{
- requestId: '123',
- mediaType: 'video',
- cpm: 0.3,
- width: 320,
- height: 50,
- vastUrl: '',
- ttl: 1000,
- creativeId: '123asd',
- netRevenue: true,
- currency: 'USD',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- let videoServerResponses = spec.interpretResponse(videoResObject);
- it('Returns an array of valid server video responses if response object is valid', function () {
- expect(videoServerResponses).to.be.an('array').that.is.not.empty;
- for (let i = 0; i < videoServerResponses.length; i++) {
- const dataItem = videoServerResponses[i];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'vastUrl', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'mediaType', 'meta');
- expect(dataItem.requestId).to.be.a('string');
- expect(dataItem.cpm).to.be.a('number');
- expect(dataItem.width).to.be.a('number');
- expect(dataItem.height).to.be.a('number');
- expect(dataItem.vastUrl).to.be.a('string');
- expect(dataItem.ttl).to.be.a('number');
- expect(dataItem.creativeId).to.be.a('string');
- expect(dataItem.netRevenue).to.be.a('boolean');
- expect(dataItem.currency).to.be.a('string');
- expect(dataItem.mediaType).to.be.a('string');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- }
- it('Returns an empty array if invalid response is passed', function () {
- videoServerResponses = spec.interpretResponse('invalid_response');
- expect(videoServerResponses).to.be.an('array').that.is.empty;
- });
- });
- });
-
- describe('onBidWon', function () {
- it('should make an ajax call', function () {
- const bid = {
- nurl: 'http://example.com/win',
- };
- expect(spec.onBidWon(bid)).to.equals(undefined);
- });
- })
-
- describe('getUserSyncs', function () {
- const userSync = spec.getUserSyncs({}, {}, { consentString: 'xxx', gdprApplies: 1 }, { consentString: '1YN-' });
- it('Returns valid URL and type', function () {
- expect(userSync).to.be.an('array').with.lengthOf(1);
- expect(userSync[0].type).to.exist;
- expect(userSync[0].url).to.exist;
- expect(userSync[0].type).to.be.equal('image');
- expect(userSync[0].url).to.be.equal('https://sync.colossusssp.com/image?pbjs=1&gdpr=0&gdpr_consent=xxx&ccpa_consent=1YN-&coppa=0');
- });
- });
-});
diff --git a/test/spec/modules/compassBidAdapter_spec.js b/test/spec/modules/compassBidAdapter_spec.js
deleted file mode 100644
index 8d0e1cc57..000000000
--- a/test/spec/modules/compassBidAdapter_spec.js
+++ /dev/null
@@ -1,517 +0,0 @@
-import { expect } from 'chai';
-import { spec } from '../../../modules/compassBidAdapter.js';
-import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js';
-import { getUniqueIdentifierStr } from '../../../src/utils.js';
-import { config } from '../../../src/config.js';
-
-const bidder = 'compass';
-
-describe('CompassBidAdapter', function () {
- const userIdAsEids = [{
- source: 'test.org',
- uids: [{
- id: '01**********',
- atype: 1,
- ext: {
- third: '01***********'
- }
- }]
- }];
- const bids = [
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
- placementId: 'testBanner'
- },
- userIdAsEids
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [VIDEO]: {
- playerSize: [[300, 300]],
- minduration: 5,
- maxduration: 60
- }
- },
- params: {
- placementId: 'testVideo'
- },
- userIdAsEids
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [NATIVE]: {
- native: {
- title: {
- required: true
- },
- body: {
- required: true
- },
- icon: {
- required: true,
- size: [64, 64]
- }
- }
- }
- },
- params: {
- placementId: 'testNative'
- },
- userIdAsEids
- }
- ];
-
- const invalidBid = {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
-
- }
- }
-
- const bidderRequest = {
- uspConsent: '1---',
- gdprConsent: {
- consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw',
- vendorData: {}
- },
- refererInfo: {
- referer: 'https://test.com',
- page: 'https://test.com'
- },
- ortb2: {
- device: {
- w: 1512,
- h: 982,
- language: 'en-UK'
- }
- },
- timeout: 500
- };
-
- describe('isBidRequestValid', function () {
- it('Should return true if there are bidId, params and key parameters present', function () {
- expect(spec.isBidRequestValid(bids[0])).to.be.true;
- });
- it('Should return false if at least one of parameters is not present', function () {
- expect(spec.isBidRequestValid(invalidBid)).to.be.false;
- });
- });
-
- describe('buildRequests', function () {
- let serverRequest = spec.buildRequests(bids, bidderRequest);
-
- it('Creates a ServerRequest object with method, URL and data', function () {
- expect(serverRequest).to.exist;
- expect(serverRequest.method).to.exist;
- expect(serverRequest.url).to.exist;
- expect(serverRequest.data).to.exist;
- });
-
- it('Returns POST method', function () {
- expect(serverRequest.method).to.equal('POST');
- });
-
- it('Returns valid URL', function () {
- expect(serverRequest.url).to.equal('https://sa-lb.deliverimp.com/pbjs');
- });
-
- it('Returns general data valid', function () {
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.all.keys('deviceWidth',
- 'deviceHeight',
- 'device',
- 'language',
- 'secure',
- 'host',
- 'page',
- 'placements',
- 'coppa',
- 'ccpa',
- 'gdpr',
- 'tmax',
- 'bcat',
- 'badv',
- 'bapp',
- 'battr'
- );
- expect(data.deviceWidth).to.be.a('number');
- expect(data.deviceHeight).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');
- expect(data.page).to.be.a('string');
- expect(data.coppa).to.be.a('number');
- expect(data.gdpr).to.be.a('object');
- expect(data.ccpa).to.be.a('string');
- expect(data.tmax).to.be.a('number');
- expect(data.placements).to.have.lengthOf(3);
- });
-
- it('Returns valid placements', function () {
- const { placements } = serverRequest.data;
- for (let i = 0, len = placements.length; i < len; i++) {
- const placement = placements[i];
- expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']);
- expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]);
- expect(placement.bidId).to.be.a('string');
- expect(placement.schain).to.be.an('object');
- expect(placement.bidfloor).to.exist.and.to.equal(0);
- expect(placement.type).to.exist.and.to.equal('publisher');
- expect(placement.eids).to.exist.and.to.be.deep.equal(userIdAsEids);
-
- if (placement.adFormat === BANNER) {
- expect(placement.sizes).to.be.an('array');
- }
- switch (placement.adFormat) {
- case BANNER:
- expect(placement.sizes).to.be.an('array');
- break;
- case VIDEO:
- expect(placement.playerSize).to.be.an('array');
- expect(placement.minduration).to.be.an('number');
- expect(placement.maxduration).to.be.an('number');
- break;
- case NATIVE:
- expect(placement.native).to.be.an('object');
- break;
- }
- }
- });
-
- it('Returns valid endpoints', function () {
- const bids = [
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
- endpointId: 'testBanner',
- },
- userIdAsEids
- }
- ];
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
-
- const { placements } = serverRequest.data;
- for (let i = 0, len = placements.length; i < len; i++) {
- const placement = placements[i];
- expect(placement.endpointId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']);
- expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]);
- expect(placement.bidId).to.be.a('string');
- expect(placement.schain).to.be.an('object');
- expect(placement.bidfloor).to.exist.and.to.equal(0);
- expect(placement.type).to.exist.and.to.equal('network');
- expect(placement.eids).to.exist.and.to.be.deep.equal(userIdAsEids);
-
- if (placement.adFormat === BANNER) {
- expect(placement.sizes).to.be.an('array');
- }
- switch (placement.adFormat) {
- case BANNER:
- expect(placement.sizes).to.be.an('array');
- break;
- case VIDEO:
- expect(placement.playerSize).to.be.an('array');
- expect(placement.minduration).to.be.an('number');
- expect(placement.maxduration).to.be.an('number');
- break;
- case NATIVE:
- expect(placement.native).to.be.an('object');
- break;
- }
- }
- });
-
- it('Returns data with gdprConsent and without uspConsent', function () {
- delete bidderRequest.uspConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.gdpr).to.exist;
- expect(data.gdpr).to.be.a('object');
- expect(data.gdpr).to.have.property('consentString');
- expect(data.gdpr).to.not.have.property('vendorData');
- expect(data.gdpr.consentString).to.equal(bidderRequest.gdprConsent.consentString);
- expect(data.ccpa).to.not.exist;
- delete bidderRequest.gdprConsent;
- });
-
- it('Returns data with uspConsent and without gdprConsent', function () {
- bidderRequest.uspConsent = '1---';
- delete bidderRequest.gdprConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.ccpa).to.exist;
- expect(data.ccpa).to.be.a('string');
- expect(data.ccpa).to.equal(bidderRequest.uspConsent);
- expect(data.gdpr).to.not.exist;
- });
- });
-
- describe('gpp consent', function () {
- it('bidderRequest.gppConsent', () => {
- bidderRequest.gppConsent = {
- gppString: 'abc123',
- applicableSections: [8]
- };
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
-
- delete bidderRequest.gppConsent;
- })
-
- it('bidderRequest.ortb2.regs.gpp', () => {
- bidderRequest.ortb2 = bidderRequest.ortb2 || {};
- bidderRequest.ortb2.regs = bidderRequest.ortb2.regs || {};
- bidderRequest.ortb2.regs.gpp = 'abc123';
- bidderRequest.ortb2.regs.gpp_sid = [8];
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
- })
- });
-
- describe('interpretResponse', function () {
- it('Should interpret banner response', function () {
- const banner = {
- body: [{
- mediaType: 'banner',
- width: 300,
- height: 250,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const bannerResponses = spec.interpretResponse(banner);
- expect(bannerResponses).to.be.an('array').that.is.not.empty;
- const dataItem = bannerResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal(banner.body[0].requestId);
- expect(dataItem.cpm).to.equal(banner.body[0].cpm);
- expect(dataItem.width).to.equal(banner.body[0].width);
- expect(dataItem.height).to.equal(banner.body[0].height);
- expect(dataItem.ad).to.equal(banner.body[0].ad);
- expect(dataItem.ttl).to.equal(banner.body[0].ttl);
- expect(dataItem.creativeId).to.equal(banner.body[0].creativeId);
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal(banner.body[0].currency);
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should interpret video response', function () {
- const video = {
- body: [{
- vastUrl: 'test.com',
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const videoResponses = spec.interpretResponse(video);
- expect(videoResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = videoResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.5);
- expect(dataItem.vastUrl).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should interpret native response', function () {
- const native = {
- body: [{
- mediaType: 'native',
- native: {
- clickUrl: 'test.com',
- title: 'Test',
- image: 'test.com',
- impressionTrackers: ['test.com'],
- },
- ttl: 120,
- cpm: 0.4,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const nativeResponses = spec.interpretResponse(native);
- expect(nativeResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = nativeResponses[0];
- expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta');
- expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image')
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.4);
- expect(dataItem.native.clickUrl).to.equal('test.com');
- expect(dataItem.native.title).to.equal('Test');
- expect(dataItem.native.image).to.equal('test.com');
- expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty;
- expect(dataItem.native.impressionTrackers[0]).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should return an empty array if invalid banner response is passed', function () {
- const invBanner = {
- body: [{
- width: 300,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
-
- const serverResponses = spec.interpretResponse(invBanner);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid video response is passed', function () {
- const invVideo = {
- body: [{
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invVideo);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid native response is passed', function () {
- const invNative = {
- body: [{
- mediaType: 'native',
- clickUrl: 'test.com',
- title: 'Test',
- impressionTrackers: ['test.com'],
- ttl: 120,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- }]
- };
- const serverResponses = spec.interpretResponse(invNative);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid response is passed', function () {
- const invalid = {
- body: [{
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invalid);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- });
-
- describe('getUserSyncs', function() {
- it('Should return array of objects with proper sync config , include GDPR', function() {
- const syncData = config.runWithBidder(bidder, () => spec.getUserSyncs({}, {}, {
- consentString: 'ALL',
- gdprApplies: true,
- }, {}));
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://sa-cs.deliverimp.com/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0')
- });
- it('Should return array of objects with proper sync config , include CCPA', function() {
- const syncData = config.runWithBidder(bidder, () => spec.getUserSyncs({}, {}, {}, {
- consentString: '1---'
- }));
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://sa-cs.deliverimp.com/image?pbjs=1&ccpa_consent=1---&coppa=0')
- });
- it('Should return array of objects with proper sync config , include GPP', function() {
- const syncData = config.runWithBidder(bidder, () => spec.getUserSyncs({}, {}, {}, {}, {
- gppString: 'abc123',
- applicableSections: [8]
- }));
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://sa-cs.deliverimp.com/image?pbjs=1&gpp=abc123&gpp_sid=8&coppa=0')
- });
- });
-});
diff --git a/test/spec/modules/conceptxBidAdapter_spec.js b/test/spec/modules/conceptxBidAdapter_spec.js
deleted file mode 100644
index 8e9bd2f8c..000000000
--- a/test/spec/modules/conceptxBidAdapter_spec.js
+++ /dev/null
@@ -1,124 +0,0 @@
-// import or require modules necessary for the test, e.g.:
-import { expect } from 'chai'; // may prefer 'assert' in place of 'expect'
-import { spec } from 'modules/conceptxBidAdapter.js';
-import { newBidder } from 'src/adapters/bidderFactory.js';
-// import { config } from 'src/config.js';
-
-describe('conceptxBidAdapter', function () {
- const URL = 'https://conceptx.cncpt-central.com/openrtb';
-
- const ENDPOINT_URL = `${URL}`;
- const ENDPOINT_URL_CONSENT = `${URL}?gdpr_applies=true&consentString=ihaveconsented`;
- const adapter = newBidder(spec);
-
- const bidderRequests = [
- {
- bidId: '123',
- bidder: 'conceptx',
- params: {
- site: 'example',
- adunit: 'some-id-3'
- },
- mediaTypes: {
- banner: {
- sizes: [[930, 180]],
- }
- },
- }
- ]
-
- const singleBidRequest = {
- bid: [
- {
- bidId: '123',
- }
- ]
- }
-
- const serverResponse = {
- body: {
- 'bidResponses': [
- {
- 'ads': [
- {
- 'referrer': 'http://localhost/prebidpage_concept_bidder.html',
- 'ttl': 360,
- 'html': 'DUMMY
',
- 'requestId': '214dfadd1f8826',
- 'cpm': 46,
- 'currency': 'DKK',
- 'width': 930,
- 'height': 180,
- 'creativeId': 'FAKE-ID',
- 'meta': {
- 'mediaType': 'banner'
- },
- 'netRevenue': true,
- 'destinationUrls': {
- 'destination': 'https://concept.dk'
- }
- }
- ],
- 'matchedAdCount': 1,
- 'targetId': '214dfadd1f8826'
- }
- ]
- }
- }
-
- describe('inherited functions', function () {
- it('exists and is a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('isBidRequestValid', function () {
- it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(bidderRequests[0])).to.equal(true);
- });
- });
-
- describe('buildRequests', function () {
- it('Test requests', function () {
- const request = spec.buildRequests(bidderRequests, {});
- expect(request.length).to.equal(1);
- expect(request[0]).to.have.property('data');
- const bid = JSON.parse(request[0].data).adUnits[0]
- expect(bid.site).to.equal('example');
- expect(bid.adunit).to.equal('some-id-3');
- expect(JSON.stringify(bid.dimensions)).to.equal(JSON.stringify([
- [930, 180]]));
- });
- });
-
- describe('user privacy', function () {
- it('should NOT send GDPR Consent data if gdprApplies equals undefined', function () {
- const request = spec.buildRequests(bidderRequests, { gdprConsent: { gdprApplies: undefined, consentString: 'iDoNotConsent' } });
- expect(request.length).to.equal(1);
- expect(request[0]).to.have.property('url')
- expect(request[0].url).to.equal(ENDPOINT_URL);
- });
- it('should send GDPR Consent data if gdprApplies', function () {
- const request = spec.buildRequests(bidderRequests, { gdprConsent: { gdprApplies: true, consentString: 'ihaveconsented' } });
- expect(request.length).to.equal(1);
- expect(request[0]).to.have.property('url')
- expect(request[0].url).to.equal(ENDPOINT_URL_CONSENT);
- });
- });
-
- describe('interpretResponse', function () {
- it('should return valid response when passed valid server response', function () {
- const interpretedResponse = spec.interpretResponse(serverResponse, singleBidRequest);
- const ad = serverResponse.body.bidResponses[0].ads[0]
- expect(interpretedResponse).to.have.lengthOf(1);
- expect(interpretedResponse[0].cpm).to.equal(ad.cpm);
- expect(interpretedResponse[0].width).to.equal(Number(ad.width));
- expect(interpretedResponse[0].height).to.equal(Number(ad.height));
- expect(interpretedResponse[0].creativeId).to.equal(ad.creativeId);
- expect(interpretedResponse[0].currency).to.equal(ad.currency);
- expect(interpretedResponse[0].netRevenue).to.equal(true);
- expect(interpretedResponse[0].ad).to.equal(ad.html);
- expect(interpretedResponse[0].ttl).to.equal(360);
- });
- });
-});
diff --git a/test/spec/modules/concertAnalyticsAdapter_spec.js b/test/spec/modules/concertAnalyticsAdapter_spec.js
deleted file mode 100644
index 639011ac4..000000000
--- a/test/spec/modules/concertAnalyticsAdapter_spec.js
+++ /dev/null
@@ -1,151 +0,0 @@
-import concertAnalytics from 'modules/concertAnalyticsAdapter.js';
-import { expect } from 'chai';
-import {expectEvents} from '../../helpers/analytics.js';
-import { EVENTS } from 'src/constants.js';
-import { server } from 'test/mocks/xhr.js';
-
-import sinon from 'sinon';
-const adapterManager = require('src/adapterManager').default;
-const events = require('src/events');
-
-describe('ConcertAnalyticsAdapter', function() {
- let sandbox;
- let clock;
- const timestamp = 1896134400;
- const auctionId = '9f894496-10fe-4652-863d-623462bf82b8';
- const timeout = 1000;
-
- before(function () {
- sandbox = sinon.createSandbox();
- clock = sandbox.useFakeTimers(1896134400);
- });
-
- after(function () {
- clock.restore();
- sandbox.restore();
- });
-
- describe('track', function() {
- beforeEach(function () {
- sandbox.stub(events, 'getEvents').returns([]);
-
- adapterManager.enableAnalytics({
- provider: 'concert'
- });
- });
-
- afterEach(function () {
- events.getEvents.restore();
- concertAnalytics.eventsStorage = [];
- concertAnalytics.disableAnalytics();
- });
-
- it('should catch all events', function() {
- sandbox.spy(concertAnalytics, 'track');
- expectEvents().to.beTrackedBy(concertAnalytics.track);
- });
-
- it('should report data for BID_RESPONSE, BID_WON events', function() {
- fireBidEvents(events);
- clock.tick(3000 + 1000);
-
- const eventsToReport = ['bidResponse', 'bidWon'];
- for (let i = 0; i < concertAnalytics.eventsStorage.length; i++) {
- expect(eventsToReport.indexOf(concertAnalytics.eventsStorage[i].event)).to.be.above(-1);
- }
-
- for (let i = 0; i < eventsToReport.length; i++) {
- expect(concertAnalytics.eventsStorage.some(function(event) {
- return event.event === eventsToReport[i]
- })).to.equal(true);
- }
- });
-
- it('should report data in the shape expected by analytics endpoint', function() {
- fireBidEvents(events);
- clock.tick(3000 + 1000);
-
- const requiredFields = ['event', 'concert_rid', 'adId', 'auctionId', 'creativeId', 'position', 'url', 'cpm', 'width', 'height', 'timeToRespond'];
-
- for (var i = 0; i < requiredFields.length; i++) {
- expect(concertAnalytics.eventsStorage[0]).to.have.property(requiredFields[i]);
- }
- });
- });
-
- const adUnits = [{
- code: 'desktop_leaderboard_variable',
- sizes: [[1030, 590]],
- mediaTypes: {
- banner: {
- sizes: [[1030, 590]]
- }
- },
- bids: [
- {
- bidder: 'concert',
- params: {
- partnerId: 'test_partner'
- }
- }
- ]
- }];
-
- const bidResponse = {
- 'bidderCode': 'concert',
- 'width': 1030,
- 'height': 590,
- 'statusMessage': 'Bid available',
- 'adId': '642f13fe18ab7dc',
- 'requestId': '4062fba2e039919',
- 'mediaType': 'banner',
- 'source': 'client',
- 'cpm': 6,
- 'ad': '',
- 'ttl': 360,
- 'creativeId': '138308483085|62bac030-a5d3-11ea-b3be-55590c8153a5',
- 'netRevenue': false,
- 'currency': 'USD',
- 'originalCpm': 6,
- 'originalCurrency': 'USD',
- 'auctionId': '9f894496-10fe-4652-863d-623462bf82b8',
- 'responseTimestamp': 1591213790366,
- 'requestTimestamp': 1591213790017,
- 'bidder': 'concert',
- 'adUnitCode': 'desktop_leaderboard_variable',
- 'timeToRespond': 349,
- 'status': 'rendered',
- 'params': [
- {
- 'partnerId': 'cst'
- }
- ]
- }
-
- const bidWon = {
- 'adId': '642f13fe18ab7dc',
- 'mediaType': 'banner',
- 'requestId': '4062fba2e039919',
- 'cpm': 6,
- 'creativeId': '138308483085|62bac030-a5d3-11ea-b3be-55590c8153a5',
- 'currency': 'USD',
- 'netRevenue': false,
- 'ttl': 360,
- 'auctionId': '9f894496-10fe-4652-863d-623462bf82b8',
- 'statusMessage': 'Bid available',
- 'responseTimestamp': 1591213790366,
- 'requestTimestamp': 1591213790017,
- 'bidder': 'concert',
- 'adUnitCode': 'desktop_leaderboard_variable',
- 'sizes': [[1030, 590]],
- 'size': [1030, 590]
- }
-
- function fireBidEvents(events) {
- events.emit(EVENTS.AUCTION_INIT, { timestamp, auctionId, timeout, adUnits });
- events.emit(EVENTS.BID_REQUESTED, { bidder: 'concert' });
- events.emit(EVENTS.BID_RESPONSE, bidResponse);
- events.emit(EVENTS.AUCTION_END, {});
- events.emit(EVENTS.BID_WON, bidWon);
- }
-});
diff --git a/test/spec/modules/concertBidAdapter_spec.js b/test/spec/modules/concertBidAdapter_spec.js
deleted file mode 100644
index 6c842e58d..000000000
--- a/test/spec/modules/concertBidAdapter_spec.js
+++ /dev/null
@@ -1,308 +0,0 @@
-import { expect } from 'chai';
-import sinon from 'sinon';
-import { spec, storage } from 'modules/concertBidAdapter.js';
-import { hook } from 'src/hook.js';
-import {getGlobal} from '../../../src/prebidGlobal.js';
-
-describe('ConcertAdapter', function () {
- let bidRequests;
- let bidRequest;
- let bidResponse;
- let element;
- let sandbox;
-
- before(function () {
- hook.ready();
- });
-
- beforeEach(function () {
- element = {
- x: 0,
- y: 0,
- width: 0,
- height: 0,
- getBoundingClientRect: () => {
- return {
- width: element.width,
- height: element.height,
-
- left: element.x,
- top: element.y,
- right: element.x + element.width,
- bottom: element.y + element.height
- };
- }
- };
-
- getGlobal().bidderSettings = {
- concert: {
- storageAllowed: true
- }
- };
-
- bidRequests = [
- {
- bidder: 'concert',
- params: {
- partnerId: 'foo',
- slotType: 'fizz'
- },
- adUnitCode: 'desktop_leaderboard_variable',
- bidId: 'foo',
- ortb2Imp: {
- ext: {
- tid: ''
- }
- },
- sizes: [[1030, 590]]
- }
- ];
-
- bidRequest = {
- refererInfo: {
- page: 'https://www.google.com'
- },
- uspConsent: '1YN-',
- gdprConsent: {},
- gppConsent: {}
- };
-
- bidResponse = {
- body: {
- bids: [
- {
- bidId: '16d2e73faea32d9',
- cpm: '6',
- width: '1030',
- height: '590',
- ad: '',
- ttl: '360',
- creativeId: '123349|a7d62700-a4bf-11ea-829f-ad3b0b7a9383',
- netRevenue: false,
- currency: 'USD'
- }
- ]
- }
- }
-
- sandbox = sinon.createSandbox();
- sandbox.stub(document, 'getElementById').withArgs('desktop_leaderboard_variable').returns(element)
- });
-
- afterEach(function () {
- getGlobal().bidderSettings = {};
- sandbox.restore();
- });
-
- describe('spec.isBidRequestValid', function() {
- it('should return when it received all the required params', function() {
- const bid = bidRequests[0];
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should return false when partner id is missing', function() {
- const bid = {
- bidder: 'concert',
- params: {}
- }
-
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
- });
-
- describe('spec.buildRequests', function() {
- it('should build a payload object with the shape expected by server', function() {
- const request = spec.buildRequests(bidRequests, bidRequest);
- const payload = JSON.parse(request.data);
- expect(payload).to.have.property('meta');
- expect(payload).to.have.property('slots');
-
- const metaRequiredFields = [
- 'prebidVersion',
- 'pageUrl',
- 'screen',
- 'debug',
- 'uid',
- 'optedOut',
- 'adapterVersion',
- 'uspConsent',
- 'gdprConsent',
- 'gppConsent',
- 'browserLanguage',
- 'tdid'
- ];
- const slotsRequiredFields = ['name', 'bidId', 'transactionId', 'sizes', 'partnerId', 'slotType'];
-
- metaRequiredFields.forEach(function(field) {
- expect(payload.meta).to.have.property(field);
- });
- slotsRequiredFields.forEach(function(field) {
- expect(payload.slots[0]).to.have.property(field);
- });
- });
-
- it('should not generate uid if the user has opted out', function() {
- storage.setDataInLocalStorage('c_nap', 'true');
- const request = spec.buildRequests(bidRequests, bidRequest);
- const payload = JSON.parse(request.data);
-
- expect(payload.meta.uid).to.equal(false);
- });
-
- it('should generate uid if the user has not opted out', function() {
- storage.removeDataFromLocalStorage('c_nap');
- const request = spec.buildRequests(bidRequests, bidRequest);
- const payload = JSON.parse(request.data);
-
- expect(payload.meta.uid).to.not.equal(false);
- });
-
- it('should not generate uid if USP consent disallows', function() {
- storage.removeDataFromLocalStorage('c_nap');
- const request = spec.buildRequests(bidRequests, { ...bidRequest, uspConsent: '1YY' });
- const payload = JSON.parse(request.data);
-
- expect(payload.meta.uid).to.equal(false);
- });
-
- it('should use sharedid if it exists', function() {
- storage.removeDataFromLocalStorage('c_nap');
- const bidRequestsWithSharedId = [{
- ...bidRequests[0],
- userIdAsEids: [{
- source: 'sharedid.org',
- uids: [{ id: '123abc' }]
- }]
- }];
- const request = spec.buildRequests(bidRequestsWithSharedId, bidRequest);
- const payload = JSON.parse(request.data);
-
- expect(payload.meta.uid).to.equal('123abc');
- });
-
- it('should grab uid from local storage if it exists and sharedid does not', function() {
- storage.setDataInLocalStorage('vmconcert_uid', 'foo');
- storage.removeDataFromLocalStorage('c_nap');
- const request = spec.buildRequests(bidRequests, bidRequest);
- const payload = JSON.parse(request.data);
-
- expect(payload.meta.uid).to.equal('foo');
- });
-
- it('should add uid2 to eids list if available', function() {
- bidRequests[0].userIdAsEids = [{
- source: 'uidapi.com',
- uids: [{ id: 'uid123', atype: 3 }]
- }];
-
- const request = spec.buildRequests(bidRequests, bidRequest);
- const payload = JSON.parse(request.data);
- const meta = payload.meta
-
- expect(meta.eids.length).to.equal(1);
- expect(meta.eids[0].uids[0].id).to.equal('uid123')
- expect(meta.eids[0].uids[0].atype).to.equal(3)
- })
-
- it('should return empty eids list if none are available', function() {
- const request = spec.buildRequests(bidRequests, bidRequest);
- const payload = JSON.parse(request.data);
- const meta = payload.meta
-
- expect(meta.eids.length).to.equal(0);
- });
-
- it('should return x/y offset coordiantes when element is present', function() {
- Object.assign(element, { x: 100, y: 0, width: 400, height: 400 })
- const request = spec.buildRequests(bidRequests, bidRequest);
- const payload = JSON.parse(request.data);
- const slot = payload.slots[0];
-
- expect(slot.offsetCoordinates.x).to.equal(100)
- expect(slot.offsetCoordinates.y).to.equal(0)
- })
-
- it('should not pass along tdid if the user has opted out', function() {
- storage.setDataInLocalStorage('c_nap', 'true');
- const request = spec.buildRequests(bidRequests, bidRequest);
- const payload = JSON.parse(request.data);
-
- expect(payload.meta.tdid).to.be.null;
- });
-
- it('should not pass along tdid if USP consent disallows', function() {
- storage.removeDataFromLocalStorage('c_nap');
- const request = spec.buildRequests(bidRequests, { ...bidRequest, uspConsent: '1YY' });
- const payload = JSON.parse(request.data);
-
- expect(payload.meta.tdid).to.be.null;
- });
-
- it('should pass along tdid if the user has not opted out', function() {
- storage.removeDataFromLocalStorage('c_nap', 'true');
- const tdid = '123abc';
- const bidRequestsWithTdid = [{
- ...bidRequests[0],
- userIdAsEids: [{
- source: 'adserver.org',
- uids: [{ id: tdid }]
- }]
- }];
- const request = spec.buildRequests(bidRequestsWithTdid, bidRequest);
- const payload = JSON.parse(request.data);
- expect(payload.meta.tdid).to.equal(tdid);
- });
-
- it('should use pubcId if it exists and sharedId does not', function() {
- storage.removeDataFromLocalStorage('c_nap');
- const bidRequestsWithPubcId = [{
- ...bidRequests[0],
- userIdAsEids: [{
- source: 'pubcid.org',
- uids: [{ id: 'pubcid123' }]
- }]
- }];
- const request = spec.buildRequests(bidRequestsWithPubcId, bidRequest);
- const payload = JSON.parse(request.data);
-
- expect(payload.meta.uid).to.equal('pubcid123');
- });
- });
-
- describe('spec.interpretResponse', function() {
- it('should return bids in the shape expected by prebid', function() {
- const bids = spec.interpretResponse(bidResponse, bidRequest);
- const requiredFields = ['requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'meta', 'creativeId', 'netRevenue', 'currency'];
-
- requiredFields.forEach(function(field) {
- expect(bids[0]).to.have.property(field);
- });
- });
-
- it('should include dealId when present in bidResponse', function() {
- const bids = spec.interpretResponse({
- body: {
- bids: [
- { ...bidResponse.body.bids[0], dealid: 'CON-123' }
- ]
- }
- }, bidRequest);
- expect(bids[0]).to.have.property('dealId');
- });
-
- it('should exclude dealId when absent in bidResponse', function() {
- const bids = spec.interpretResponse(bidResponse, bidRequest);
- expect(bids[0]).to.not.have.property('dealId');
- });
-
- it('should return empty bids if there is no response from server', function() {
- const bids = spec.interpretResponse({ body: null }, bidRequest);
- expect(bids).to.have.lengthOf(0);
- });
-
- it('should return empty bids if there are no bids from the server', function() {
- const bids = spec.interpretResponse({ body: {bids: []} }, bidRequest);
- expect(bids).to.have.lengthOf(0);
- });
- });
-});
diff --git a/test/spec/modules/condorxBidAdapter_spec.js b/test/spec/modules/condorxBidAdapter_spec.js
deleted file mode 100644
index 62dfb631b..000000000
--- a/test/spec/modules/condorxBidAdapter_spec.js
+++ /dev/null
@@ -1,553 +0,0 @@
-import { expect } from 'chai';
-import { bidderSpec as adapterSpec } from 'modules/condorxBidAdapter.js';
-import * as utils from 'src/utils.js';
-
-describe('CondorX Bid Adapter Tests', function () {
- let basicBidRequests;
- let nativeBidData;
- let ortbBidRequests;
- const defaultRequestParams = {
- widget: 274572,
- website: 195491,
- url: 'current url'
- };
-
- beforeEach(function () {
- basicBidRequests = [
- {
- bidder: 'condorx',
- params: defaultRequestParams,
- bidId: 'test-bid-id-1',
- sizes: [[300, 250]]
- }
- ];
-
- nativeBidData = [
- {
- bidder: 'condorx',
- params: defaultRequestParams,
- bidId: 'test-bid-id-2',
- sizes: [[100, 100]],
- nativeParams: {
- title: {
- required: true,
- len: 100
- },
- image: {
- required: true,
- sizes: [100, 100]
- },
- sponsoredBy: {
- required: true
- }
- }
- }
- ];
-
- ortbBidRequests = [
- {
- bidder: 'condorx',
- params: {
- ...defaultRequestParams,
- useOpenRTB: true
- },
- bidId: 'test-bid-id-3',
- sizes: [[300, 250]]
- }
- ];
- });
-
- describe('Bid Size Validation', function () {
- const bid = {
- bidder: 'condorx',
- params: defaultRequestParams
- };
-
- it('should accept 300x250 size', function () {
- bid.sizes = [[300, 250]];
- const isValid = adapterSpec.isBidRequestValid(bid);
- expect(isValid).to.be.true;
- });
-
- it('should accept 100x100 size', function () {
- bid.sizes = [[100, 100]];
- const isValid = adapterSpec.isBidRequestValid(bid);
- expect(isValid).to.be.true;
- });
-
- it('should accept 600x600 size', function () {
- bid.sizes = [[600, 600]];
- const isValid = adapterSpec.isBidRequestValid(bid);
- expect(isValid).to.be.true;
- });
-
- it('should accept any valid size', function () {
- bid.sizes = [[728, 90]];
- const isValid = adapterSpec.isBidRequestValid(bid);
- expect(isValid).to.be.true;
- });
-
- it('should reject invalid size', function () {
- bid.sizes = [[0, 0]];
- const isValid = adapterSpec.isBidRequestValid(bid);
- expect(isValid).to.be.false;
- });
-
- it('should reject negative size', function () {
- bid.sizes = [[-1, -1]];
- const isValid = adapterSpec.isBidRequestValid(bid);
- expect(isValid).to.be.false;
- });
- });
-
- describe('Bid Request Validation', function () {
- it('should validate a correct bid request', function () {
- const validBid = {
- bidder: 'condorx',
- params: defaultRequestParams,
- sizes: [[300, 250]]
- };
- const isValid = adapterSpec.isBidRequestValid(validBid);
- expect(isValid).to.be.true;
- });
-
- it('should validate a correct OpenRTB bid request', function () {
- const validOrtbBid = {
- bidder: 'condorx',
- params: {
- ...defaultRequestParams,
- useOpenRTB: true
- },
- sizes: [[300, 250]]
- };
- const isValid = adapterSpec.isBidRequestValid(validOrtbBid);
- expect(isValid).to.be.true;
- });
-
- it('should invalidate an empty params bid request', function () {
- const invalidBid = {
- bidder: 'condorx',
- params: {}
- };
- const isValid = adapterSpec.isBidRequestValid(invalidBid);
- expect(isValid).to.be.false;
- });
-
- it('should invalidate a bid request with invalid parameters', function () {
- const invalidBid = {
- bidder: 'condorx',
- params: {
- widget: '55765a',
- website: 195491,
- url: 'current url'
- },
- sizes: [[300, 250]]
- };
- const isValid = adapterSpec.isBidRequestValid(invalidBid);
- expect(isValid).to.be.false;
- });
- });
-
- describe('OpenRTB Format Support', function () {
- let bidderRequest;
-
- beforeEach(function () {
- bidderRequest = {
- auctionId: 'test-auction-id',
- bids: ortbBidRequests,
- ortb2: {
- site: {
- page: 'https://condorx.io'
- }
- },
- refererInfo: {
- page: 'https://condorx.io'
- }
- };
- });
-
- it('should build OpenRTB request when useOpenRTB is true', function () {
- const request = adapterSpec.buildRequests(ortbBidRequests, bidderRequest)[0];
- expect(request.method).to.equal('POST');
- expect(request.url).to.include('/openrtb.json');
- expect(request.data).to.be.an('object');
- });
-
- it('should build correct OpenRTB endpoint URL', function () {
- const request = adapterSpec.buildRequests(ortbBidRequests, bidderRequest)[0];
- const expectedBase64 = btoa('195491_274572');
- expect(request.url).to.equal(`https://api.condorx.io/cxb/${expectedBase64}/openrtb.json`);
- });
-
- it('should include ortbRequest in request object', function () {
- const request = adapterSpec.buildRequests(ortbBidRequests, bidderRequest)[0];
- expect(request.ortbRequest).to.exist;
- expect(request.ortbRequest).to.be.an('object');
- });
-
- it('should parse JSON data in OpenRTB request', function () {
- const request = adapterSpec.buildRequests(ortbBidRequests, bidderRequest)[0];
- const ortbData = request.data;
- expect(ortbData).to.have.property('id');
- expect(ortbData).to.have.property('imp');
- expect(ortbData.imp).to.be.an('array');
- expect(ortbData.imp[0]).to.have.property('ext');
- expect(ortbData.imp[0].ext).to.have.property('widget', 274572);
- expect(ortbData.imp[0].ext).to.have.property('website', 195491);
- });
-
- it('should use legacy format when useOpenRTB is false', function () {
- const request = adapterSpec.buildRequests(basicBidRequests, bidderRequest)[0];
- expect(request.method).to.equal('GET');
- expect(request.url).to.include('https://api.condorx.io/cxb/get.json');
- expect(request.data).to.equal('');
- });
-
- it('should return OpenRTB request format when useOpenRTB is true', function () {
- const request = adapterSpec.buildRequests(ortbBidRequests, bidderRequest)[0];
- expect(request.method).to.equal('POST');
- expect(request.url).to.include('/openrtb.json');
- expect(request.data).to.be.an('object');
- expect(request.ortbRequest).to.exist;
- });
- });
-
- describe('First Party Data (ORTB2)', function () {
- let bidderRequest;
-
- beforeEach(function () {
- bidderRequest = {
- auctionId: 'test-auction-id',
- bids: ortbBidRequests,
- ortb2: {
- site: {
- page: 'https://condorx.io'
- }
- },
- refererInfo: {
- page: 'https://condorx.io'
- }
- };
- });
-
- it('should pass user data in OpenRTB request', function () {
- bidderRequest.ortb2.user = {
- id: 'user123',
- buyeruid: 'buyer456',
- yob: 1990
- };
-
- const request = adapterSpec.buildRequests(ortbBidRequests, bidderRequest)[0];
- const ortbData = request.data;
-
- expect(ortbData.user.id).to.equal('user123');
- expect(ortbData.user.buyeruid).to.equal('buyer456');
- expect(ortbData.user.yob).to.equal(1990);
- });
-
- it('should pass device data in OpenRTB request', function () {
- bidderRequest.ortb2.device = {
- ua: 'Mozilla/5.0 Test Browser',
- language: 'en-US',
- devicetype: 1,
- make: 'Apple',
- model: 'iPhone'
- };
-
- const request = adapterSpec.buildRequests(ortbBidRequests, bidderRequest)[0];
- const ortbData = request.data;
-
- expect(ortbData.device.ua).to.equal('Mozilla/5.0 Test Browser');
- expect(ortbData.device.language).to.equal('en-US');
- expect(ortbData.device.devicetype).to.equal(1);
- expect(ortbData.device.make).to.equal('Apple');
- expect(ortbData.device.model).to.equal('iPhone');
- });
-
- it('should pass site data in OpenRTB request', function () {
- bidderRequest.ortb2.site = {
- page: 'https://condorx.io/test-page',
- domain: 'condorx.io',
- cat: ['IAB1'],
- keywords: 'test,keywords'
- };
-
- const request = adapterSpec.buildRequests(ortbBidRequests, bidderRequest)[0];
- const ortbData = request.data;
-
- expect(ortbData.site.page).to.equal('https://condorx.io/test-page');
- expect(ortbData.site.domain).to.equal('condorx.io');
- expect(ortbData.site.cat).to.deep.equal(['IAB1']);
- expect(ortbData.site.keywords).to.equal('test,keywords');
- });
-
- it('should pass custom extensions in OpenRTB request', function () {
- bidderRequest.ortb2.ext = {
- pageType: 'article',
- customData: 'test-value'
- };
-
- const request = adapterSpec.buildRequests(ortbBidRequests, bidderRequest)[0];
- const ortbData = request.data;
-
- expect(ortbData.ext.pageType).to.equal('article');
- expect(ortbData.ext.customData).to.equal('test-value');
- });
-
- it('should pass blocked categories and domains', function () {
- bidderRequest.ortb2.bcat = ['IAB25', 'IAB26'];
- bidderRequest.ortb2.badv = ['blocked-advertiser.com'];
-
- const request = adapterSpec.buildRequests(ortbBidRequests, bidderRequest)[0];
- const ortbData = request.data;
-
- expect(ortbData.bcat).to.deep.equal(['IAB25', 'IAB26']);
- expect(ortbData.badv).to.deep.equal(['blocked-advertiser.com']);
- });
- });
-
- describe('Bid Floor Support', function () {
- it('should include bid floor in request URL when provided in params', function () {
- const bidWithFloor = {
- bidder: 'condorx',
- params: {
- ...defaultRequestParams,
- bidfloor: 0.75
- },
- sizes: [[300, 250]]
- };
- const request = adapterSpec.buildRequests([bidWithFloor])[0];
- const urlParams = new URL(request.url).searchParams;
- expect(urlParams.get('bf')).to.equal('0.75');
- });
-
- it('should include -1 bid floor when no floor is provided', function () {
- const bidWithoutFloor = {
- bidder: 'condorx',
- params: defaultRequestParams,
- sizes: [[300, 250]]
- };
- const request = adapterSpec.buildRequests([bidWithoutFloor])[0];
- const urlParams = new URL(request.url).searchParams;
- expect(urlParams.get('bf')).to.equal('-1');
- });
-
- it('should prioritize params.bidfloor over getFloor function', function () {
- const bidWithBothFloors = {
- bidder: 'condorx',
- params: {
- ...defaultRequestParams,
- bidfloor: 0.5
- },
- sizes: [[300, 250]],
- getFloor: function() {
- return { floor: 1.25 };
- }
- };
- const request = adapterSpec.buildRequests([bidWithBothFloors])[0];
- const urlParams = new URL(request.url).searchParams;
- expect(urlParams.get('bf')).to.equal('0.5');
- });
-
- it('should handle getFloor function errors gracefully', function () {
- const bidWithErrorFloor = {
- bidder: 'condorx',
- params: defaultRequestParams,
- sizes: [[300, 250]],
- getFloor: function() {
- throw new Error('Floor error');
- }
- };
- const request = adapterSpec.buildRequests([bidWithErrorFloor])[0];
- const urlParams = new URL(request.url).searchParams;
- expect(urlParams.get('bf')).to.equal('-1');
- });
-
- it('should handle invalid bidfloor params', function () {
- const bidWithInvalidFloor = {
- bidder: 'condorx',
- params: {
- ...defaultRequestParams,
- bidfloor: 'invalid'
- },
- sizes: [[300, 250]]
- };
- const request = adapterSpec.buildRequests([bidWithInvalidFloor])[0];
- const urlParams = new URL(request.url).searchParams;
- expect(urlParams.get('bf')).to.equal('-1');
- });
- });
-
- describe('Request Building and HTTP Calls', function () {
- it('should verify the API HTTP method', function () {
- const request = adapterSpec.buildRequests(basicBidRequests)[0];
- expect(request.url).to.include('https://api.condorx.io/cxb/get.json');
- expect(request.method).to.equal('GET');
- });
-
- it('should not mutate the original bid object', function () {
- const originalBidRequests = utils.deepClone(basicBidRequests);
- const request = adapterSpec.buildRequests(basicBidRequests);
- expect(basicBidRequests).to.deep.equal(originalBidRequests);
- });
-
- it('should maintain the integrity of the native bid object', function () {
- const originalBidRequests = utils.deepClone(nativeBidData);
- const request = adapterSpec.buildRequests(nativeBidData);
- expect(nativeBidData).to.deep.equal(originalBidRequests);
- });
-
- it('should correctly extract and validate request parameters', function () {
- const request = adapterSpec.buildRequests(basicBidRequests)[0];
- const urlParams = new URL(request.url).searchParams;
- expect(parseInt(urlParams.get('wg'))).to.exist.and.to.equal(basicBidRequests[0].params.widget);
- expect(parseInt(urlParams.get('w'))).to.exist.and.to.equal(basicBidRequests[0].params.website);
- });
-
- it('should validate the custom URL parameter', function () {
- const customUrl = 'https://condorx.io/custom-page';
- basicBidRequests[0].params.url = customUrl;
- const request = adapterSpec.buildRequests(basicBidRequests)[0];
- const urlParams = new URL(request.url).searchParams;
- expect(urlParams.get('u')).to.exist.and.to.equal(customUrl);
- });
- });
-
- describe('Response Validation', function () {
- let nativeResponseData;
- let bannerResponseData;
- let ortbResponseData;
-
- beforeEach(() => {
- const baseResponse = {
- tiles: [
- {
- postId: '12345',
- imageUrl: 'https://cdn.condorx.io/img/condorx_logo_500.jpg',
- domain: 'condorx.test',
- title: 'Test title',
- clickUrl: '//click.test',
- pcpm: 0.5,
- url: '//url.test',
- displayName: 'Test sponsoredBy',
- trackers: {
- impressionPixels: ['//impression.test'],
- viewPixels: ['//view.test'],
- }
- }
- ],
- imageWidth: 300,
- imageHeight: 250,
- ireqId: 'condorx121212',
- widgetViewPixel: '//view.pixel',
- };
-
- nativeResponseData = {
- ...baseResponse,
- pbtypeId: 1,
- };
-
- bannerResponseData = {
- ...baseResponse,
- pbtypeId: 2,
- widget: {
- config: '{"css":".__condorx_banner_title{display:block!important;}"}'
- },
- };
-
- ortbResponseData = {
- id: 'response-123',
- seatbid: [{
- bid: [{
- id: 'bid-123',
- impid: 'condorx121212',
- price: 0.5,
- adm: 'Test Banner Ad
',
- w: 300,
- h: 250,
- crid: '12345',
- adomain: ['condorx.test']
- }]
- }],
- cur: 'USD'
- };
- });
-
- it('should return an empty array for missing response', function () {
- const result = adapterSpec.interpretResponse({}, []);
- expect(result).to.be.an('array').that.is.empty;
- });
-
- it('should return an empty array for no bids', function () {
- const noBidsResponse = {
- tiles: [],
- imageWidth: 300,
- imageHeight: 250,
- ireqId: 'condorx121212',
- pbtypeId: 2,
- widgetViewPixel: '//view.pixel',
- };
- const request = adapterSpec.buildRequests(basicBidRequests)[0];
- const result = adapterSpec.interpretResponse({ body: noBidsResponse }, request);
- expect(result).to.be.an('array').that.is.empty;
- });
-
- it('should correctly interpret a native response', function () {
- const expectedNativeResult = [
- {
- requestId: 'condorx121212',
- cpm: 0.5,
- width: 300,
- height: 250,
- netRevenue: true,
- currency: 'USD',
- creativeId: '12345',
- ttl: 360,
- meta: {
- advertiserDomains: ['condorx.test']
- },
- native: {
- title: 'Test title',
- body: '',
- image: {
- url: 'https://cdn.condorx.io/img/condorx_logo_500.jpg',
- width: 300,
- height: 250
- },
- privacyLink: '',
- clickUrl: '//click.test',
- displayUrl: '//url.test',
- cta: '',
- sponsoredBy: 'Test sponsoredBy',
- impressionTrackers: ['//impression.test', '//view.test', '//view.pixel'],
- },
- }
- ];
- const request = adapterSpec.buildRequests(basicBidRequests)[0];
- const result = adapterSpec.interpretResponse({ body: nativeResponseData }, request);
- expect(result).to.deep.equal(expectedNativeResult);
- });
-
- it('should correctly interpret a banner response', function () {
- const expectedBannerResult = [
- {
- requestId: 'condorx121212',
- cpm: 0.5,
- width: 300,
- height: 250,
- netRevenue: true,
- currency: 'USD',
- creativeId: '12345',
- ttl: 360,
- meta: {
- advertiserDomains: ['condorx.test']
- },
- ad: ``,
- }
- ];
- const request = adapterSpec.buildRequests(basicBidRequests)[0];
- const result = adapterSpec.interpretResponse({ body: bannerResponseData }, request);
- expect(result).to.deep.equal(expectedBannerResult);
- });
- });
-});
diff --git a/test/spec/modules/confiantRtdProvider_spec.js b/test/spec/modules/confiantRtdProvider_spec.js
deleted file mode 100644
index 4557d79cf..000000000
--- a/test/spec/modules/confiantRtdProvider_spec.js
+++ /dev/null
@@ -1,120 +0,0 @@
-import * as utils from '../../../src/utils.js';
-import * as hook from '../../../src/hook.js'
-import * as events from '../../../src/events.js';
-import { EVENTS } from '../../../src/constants.js';
-
-import confiantModule from '../../../modules/confiantRtdProvider.js';
-
-const {
- injectConfigScript,
- setupPage,
- subscribeToConfiantCommFrame,
- registerConfiantSubmodule
-} = confiantModule;
-
-describe('Confiant RTD module', function () {
- describe('setupPage()', function() {
- let logErrorStub;
- beforeEach(function() {
- logErrorStub = sinon.stub(utils, 'logError');
- });
- afterEach(function() {
- logErrorStub.restore();
- });
-
- it('should return false if propertId is not present in config', function() {
- expect(setupPage({})).to.be.false;
- expect(setupPage({ params: {} })).to.be.false;
- expect(setupPage({ params: { propertyId: '' } })).to.be.false;
- expect(logErrorStub.callCount).to.equal(3);
- });
-
- it('should return true if expected parameters are present', function() {
- expect(setupPage({ params: { propertyId: 'clientId' } })).to.be.true;
- expect(logErrorStub.callCount).to.equal(0);
- });
- });
-
- describe('Module initialization', function() {
- let insertElementStub;
- beforeEach(function() {
- insertElementStub = sinon.stub(utils, 'insertElement');
- });
- afterEach(function() {
- utils.insertElement.restore();
- });
-
- it('should subscribe to rovided Window object', function () {
- const mockWindow = { addEventListener: sinon.spy() };
-
- subscribeToConfiantCommFrame(mockWindow);
-
- sinon.assert.calledOnce(mockWindow.addEventListener);
- });
-
- it('should fire BillableEvent as a result for message in comm window', function() {
- let listenerCallback;
- const mockWindow = { addEventListener: (a, cb) => (listenerCallback = cb) };
- let billableEventsCounter = 0;
- const propertyId = 'fff';
-
- events.on(EVENTS.BILLABLE_EVENT, (e) => {
- if (e.vendor === 'confiant') {
- billableEventsCounter++;
- expect(e.type).to.equal('impression');
- expect(e.billingId).to.be.a('number');
- expect(e.auctionId).to.equal('auctionId');
- expect(e.transactionId).to.equal('transactionId');
- }
- });
-
- subscribeToConfiantCommFrame(mockWindow, propertyId);
- listenerCallback({
- data: {
- type: 'cnft:reportBillableEvent:' + propertyId,
- auctionId: 'auctionId',
- transactionId: 'transactionId'
- }
- });
- listenerCallback({
- data: {
- type: 'cnft:reportBillableEvent:' + propertyId,
- auctionId: 'auctionId',
- transactionId: 'transactionId'
- }
- });
-
- expect(billableEventsCounter).to.equal(2);
- });
- });
-
- describe('Sumbodule execution', function() {
- let submoduleStub;
- let insertElementStub;
- beforeEach(function () {
- submoduleStub = sinon.stub(hook, 'submodule');
- insertElementStub = sinon.stub(utils, 'insertElement');
- });
- afterEach(function () {
- utils.insertElement.restore();
- submoduleStub.restore();
- });
-
- function initModule() {
- registerConfiantSubmodule();
-
- expect(submoduleStub.calledOnceWith('realTimeData')).to.equal(true);
-
- const registeredSubmoduleDefinition = submoduleStub.getCall(0).args[1];
- expect(registeredSubmoduleDefinition).to.be.an('object');
- expect(registeredSubmoduleDefinition).to.have.own.property('name', 'confiant');
- expect(registeredSubmoduleDefinition).to.have.own.property('init').that.is.a('function');
-
- return registeredSubmoduleDefinition;
- }
-
- it('should register Confiant submodule', function () {
- initModule();
- });
- });
-});
diff --git a/test/spec/modules/connatixBidAdapter_spec.js b/test/spec/modules/connatixBidAdapter_spec.js
deleted file mode 100644
index e5d51e428..000000000
--- a/test/spec/modules/connatixBidAdapter_spec.js
+++ /dev/null
@@ -1,1105 +0,0 @@
-import { expect } from 'chai';
-import sinon from 'sinon';
-import {
- _getBidRequests,
- _canSelectViewabilityContainer as connatixCanSelectViewabilityContainer,
- detectViewability as connatixDetectViewability,
- getBidFloor as connatixGetBidFloor,
- _getMinSize as connatixGetMinSize,
- _getViewability as connatixGetViewability,
- hasQueryParams as connatixHasQueryParams,
- _isViewabilityMeasurable as connatixIsViewabilityMeasurable,
- readFromAllStorages as connatixReadFromAllStorages,
- saveOnAllStorages as connatixSaveOnAllStorages,
- spec,
- storage
-} from '../../../modules/connatixBidAdapter.js';
-import adapterManager from '../../../src/adapterManager.js';
-import * as ajax from '../../../src/ajax.js';
-import { ADPOD, BANNER, VIDEO } from '../../../src/mediaTypes.js';
-import * as utils from '../../../src/utils.js';
-import * as winDimensions from '../../../src/utils/winDimensions.js';
-
-const BIDDER_CODE = 'connatix';
-
-describe('connatixBidAdapter', function () {
- let bid;
-
- function mockBidRequest() {
- const mediaTypes = {
- banner: {
- sizes: [16, 9],
- }
- };
- return {
- bidId: 'testing',
- bidder: 'connatix',
- params: {
- placementId: '30e91414-545c-4f45-a950-0bec9308ff22'
- },
- mediaTypes
- };
- };
-
- function addVideoToBidMock(bid) {
- const mediaTypes = {
- video: {
- context: 'instream',
- w: 1280,
- h: 720,
- playerSize: [1280, 720],
- placement: 1,
- plcmt: 1,
- api: [1, 2],
- mimes: ['video/mp4', 'application/javascript'],
- minduration: 30,
- maxduration: 60,
- startdelay: 0,
- }
- }
-
- bid.mediaTypes = mediaTypes;
- }
-
- describe('connatixGetMinSize', () => {
- it('should return the smallest size based on area', () => {
- const sizes = [
- { w: 300, h: 250 },
- { w: 728, h: 90 },
- { w: 160, h: 600 }
- ];
- const result = connatixGetMinSize(sizes);
- expect(result).to.deep.equal({ w: 728, h: 90 });
- });
-
- it('should handle an array with one size', () => {
- const sizes = [{ w: 300, h: 250 }];
- const result = connatixGetMinSize(sizes);
- expect(result).to.deep.equal({ w: 300, h: 250 });
- });
-
- it('should handle empty array', () => {
- const sizes = [];
- const result = connatixGetMinSize(sizes);
- expect(result).to.be.undefined;
- });
- });
-
- describe('_isIframe', () => {
- let querySelectorStub;
-
- beforeEach(() => {
- querySelectorStub = sinon.stub(window.top.document, 'querySelector');
- });
-
- afterEach(() => {
- querySelectorStub.restore();
- });
-
- it('should return true when window.top.document.querySelector does not throw an error', () => {
- querySelectorStub.returns({});
- expect(connatixCanSelectViewabilityContainer()).to.be.true;
- });
-
- it('should return false when window.top.document.querySelector throws an error', () => {
- querySelectorStub.throws(new Error('test error'));
- expect(connatixCanSelectViewabilityContainer()).to.be.false;
- });
- });
-
- describe('_isViewabilityMeasurable', () => {
- let querySelectorStub;
-
- beforeEach(() => {
- querySelectorStub = sinon.stub(window.top.document, 'querySelector');
- });
-
- afterEach(() => {
- querySelectorStub.restore();
- });
-
- it('should return false if the element is null or undefined', () => {
- expect(connatixIsViewabilityMeasurable(null)).to.be.false;
- expect(connatixIsViewabilityMeasurable(undefined)).to.be.false;
- });
-
- it('should return false if _isIframe returns true', () => {
- querySelectorStub.throws(new Error('test error'));
-
- const element = document.createElement('div');
- expect(connatixIsViewabilityMeasurable(element)).to.be.false;
- });
-
- it('should return true if _isIframe returns false', () => {
- querySelectorStub.returns(document.createElement('div'))
-
- const element = document.createElement('div');
- expect(connatixIsViewabilityMeasurable(element)).to.be.true;
- });
- });
-
- describe('_getViewability', () => {
- let element;
- let getBoundingClientRectStub;
- let topWinMock;
-
- beforeEach(() => {
- element = document.createElement('div');
- getBoundingClientRectStub = sinon.stub(element, 'getBoundingClientRect');
-
- topWinMock = {
- document: {
- visibilityState: 'visible'
- },
- innerWidth: 800,
- innerHeight: 600
- };
- });
-
- afterEach(() => {
- getBoundingClientRectStub.restore();
- });
-
- it('should return 0 if the document is not visible', () => {
- topWinMock.document.visibilityState = 'hidden';
-
- const viewability = connatixGetViewability(element, topWinMock);
-
- expect(viewability).to.equal(0);
- });
-
- it('should return 100% if the element is fully in view', () => {
- const boundingBox = { left: 100, top: 100, right: 300, bottom: 300, width: 200, height: 200 };
- getBoundingClientRectStub.returns(boundingBox);
-
- const viewability = connatixGetViewability(element, topWinMock);
-
- expect(viewability).to.equal(100);
- });
-
- it('should return the correct percentage if the element is partially in view', () => {
- const boundingBox = { left: 700, top: 500, right: 900, bottom: 700, width: 200, height: 200 };
- getBoundingClientRectStub.returns(boundingBox);
- const getWinDimensionsStub = sinon.stub(winDimensions, 'getWinDimensions');
- getWinDimensionsStub.returns({ innerWidth: topWinMock.innerWidth, innerHeight: topWinMock.innerHeight});
-
- const viewability = connatixGetViewability(element, topWinMock);
-
- expect(viewability).to.equal(25); // 100x100 / 200x200 = 0.25 -> 25%
- getWinDimensionsStub.restore();
- });
-
- it('should return 0% if the element is not in view', () => {
- const getWinDimensionsStub = sinon.stub(winDimensions, 'getWinDimensions');
- getWinDimensionsStub.returns({ innerWidth: topWinMock.innerWidth, innerHeight: topWinMock.innerHeight});
- const boundingBox = { left: 900, top: 700, right: 1100, bottom: 900, width: 200, height: 200 };
- getBoundingClientRectStub.returns(boundingBox);
-
- const viewability = connatixGetViewability(element, topWinMock);
-
- expect(viewability).to.equal(0);
- getWinDimensionsStub.restore();
- });
-
- it('should use provided width and height if element dimensions are zero', () => {
- const boundingBox = { left: 100, top: 100, right: 100, bottom: 100, width: 0, height: 0 };
- getBoundingClientRectStub.returns(boundingBox);
-
- const dimensions = { w: 200, h: 200 };
- const viewability = connatixGetViewability(element, topWinMock, dimensions);
-
- expect(viewability).to.equal(100); // Element fully in view with provided dimensions
- });
- });
-
- describe('detectViewability', () => {
- let element;
- let getBoundingClientRectStub;
- let topWinMock;
- let querySelectorStub;
- let getElementByIdStub;
-
- beforeEach(() => {
- element = document.createElement('div');
- getBoundingClientRectStub = sinon.stub(element, 'getBoundingClientRect');
-
- topWinMock = {
- document: {
- visibilityState: 'visible'
- },
- innerWidth: 800,
- innerHeight: 600
- };
-
- querySelectorStub = sinon.stub(window.top.document, 'querySelector');
- getElementByIdStub = sinon.stub(document, 'getElementById');
- });
-
- afterEach(() => {
- getBoundingClientRectStub.restore();
- querySelectorStub.restore();
- getElementByIdStub.restore();
- });
-
- it('should return 100% viewability when the element is fully within view and has a valid viewabilityContainerIdentifier', () => {
- const bid = {
- params: { viewabilityContainerIdentifier: '#validElement' },
- adUnitCode: 'adUnitCode123',
- mediaTypes: { banner: { sizes: [[300, 250]] } },
- sizes: [[300, 250]]
- };
-
- getBoundingClientRectStub.returns({
- left: 100,
- top: 100,
- right: 400,
- bottom: 350,
- width: 300,
- height: 250
- });
-
- querySelectorStub.withArgs('#validElement').returns(element);
- getElementByIdStub.returns(null);
-
- const result = connatixDetectViewability(bid);
-
- // Expected calculation: the element is fully in view, so 100% viewability
- expect(result).to.equal(100);
- });
-
- it('should fall back to using bid sizes and adUnitCode when the viewabilityContainerIdentifier is invalid or was not provided', () => {
- const bid = {
- params: { viewabilityContainerIdentifier: '#invalidElement' },
- adUnitCode: 'adUnitCode123',
- mediaTypes: { banner: { sizes: [[300, 250]] } },
- sizes: [[300, 250]]
- };
-
- getBoundingClientRectStub.returns({
- left: 200,
- top: 100,
- right: 500,
- bottom: 350,
- width: 300,
- height: 250
- });
-
- querySelectorStub.withArgs('#invalidElement').returns(null);
- getElementByIdStub.withArgs('adUnitCode123').returns(element);
-
- const result = connatixDetectViewability(bid);
-
- expect(result).to.equal(100); // Full viewability
- });
-
- it('should use the adUnitCode as a fallback when querying an element fails due to a browser error, and return 100% viewability because adUnitCode container is fully in view', () => {
- const bid = {
- params: { viewabilityContainerIdentifier: '#invalidElement' },
- adUnitCode: 'adUnitCode123',
- sizes: [[300, 250]]
- };
-
- // Simulate an error when querying the element
- querySelectorStub.withArgs('#invalidElement').throws(new Error('Query failed'));
-
- getBoundingClientRectStub.returns({
- left: 100,
- top: 100,
- right: 400,
- bottom: 350,
- width: 300,
- height: 250
- });
-
- // The fallback should use the adUnitCode to find the element
- getElementByIdStub.withArgs('adUnitCode123').returns(element);
-
- const result = connatixDetectViewability(bid);
-
- expect(result).to.equal(100); // Expect the fallback to work and return 100% viewability
- });
-
- it('should return null when querying the element by the provided identifier fails and the adUnitCode viewability container is unavailable', () => {
- const bid = {
- params: { viewabilityContainerIdentifier: '#invalidElement' },
- adUnitCode: 'adUnitCode123',
- sizes: [[300, 250]]
- };
-
- // Simulate an error when querying the element
- querySelectorStub.withArgs('#invalidElement').throws(new Error('Query failed'));
-
- getBoundingClientRectStub.returns({
- left: 100,
- top: 100,
- right: 400,
- bottom: 350,
- width: 300,
- height: 250
- });
-
- const result = connatixDetectViewability(bid);
-
- expect(result).to.equal(null);
- });
- });
-
- describe('_getBidRequests', function () {
- let bid;
-
- // Mock a bid request similar to the one already used in connatixBidAdapter tests
- function mockBidRequest() {
- const mediaTypes = {
- banner: {
- sizes: [16, 9],
- }
- };
- return {
- bidId: 'testing',
- bidder: 'connatix',
- params: {
- placementId: '30e91414-545c-4f45-a950-0bec9308ff22',
- viewabilityContainerIdentifier: 'viewabilityId',
- },
- mediaTypes,
- sizes: [300, 250]
- };
- }
-
- it('should map valid bid requests and include the expected fields', function () {
- bid = mockBidRequest();
-
- const result = _getBidRequests([bid]);
-
- expect(result).to.have.lengthOf(1);
- expect(result[0]).to.have.property('bidId', bid.bidId);
- expect(result[0]).to.have.property('mediaTypes', bid.mediaTypes);
- expect(result[0]).to.have.property('sizes', bid.sizes);
- expect(result[0]).to.have.property('placementId', bid.params.placementId);
- expect(result[0]).to.have.property('hasViewabilityContainerId', true);
- });
-
- it('should set hasViewabilityContainerId to false when viewabilityContainerIdentifier is absent', function () {
- bid = mockBidRequest();
- delete bid.params.viewabilityContainerIdentifier;
-
- const result = _getBidRequests([bid]);
-
- expect(result[0]).to.have.property('hasViewabilityContainerId', false);
- });
-
- it('should call getBidFloor for each bid and return the correct floor value', function () {
- bid = mockBidRequest();
- const floorValue = 5;
-
- // Mock getFloor method on bid
- bid.getFloor = function() {
- return { floor: floorValue };
- };
-
- const result = _getBidRequests([bid]);
-
- expect(result[0]).to.have.property('floor', floorValue);
- });
-
- it('should return floor as 0 if getBidFloor throws an error', function () {
- bid = mockBidRequest();
-
- // Mock getFloor method to throw an error
- bid.getFloor = function() {
- throw new Error('error');
- };
-
- const result = _getBidRequests([bid]);
-
- expect(result[0]).to.have.property('floor', 0);
- });
- });
-
- describe('onTimeout', function () {
- let ajaxStub;
-
- beforeEach(() => {
- ajaxStub = sinon.stub(spec, 'triggerEvent')
- })
-
- afterEach(() => {
- ajaxStub.restore()
- });
-
- it('call event if bidder is connatix', () => {
- const result = spec.onTimeout([{
- bidder: 'connatix',
- timeout: 500,
- }]);
- expect(ajaxStub.calledOnce).to.equal(true);
-
- const data = ajaxStub.firstCall.args[0];
- expect(data.type).to.equal('Timeout');
- expect(data.timeout).to.equal(500);
- });
-
- it('timeout event is not triggered if bidder is not connatix', () => {
- const result = spec.onTimeout([{
- bidder: 'otherBidder',
- timeout: 500,
- }]);
- expect(ajaxStub.notCalled).to.equal(true);
- });
- });
-
- describe('onBidWon', function () {
- let ajaxStub;
-
- beforeEach(() => {
- ajaxStub = sinon.stub(spec, 'triggerEvent');
- });
-
- afterEach(() => {
- ajaxStub.restore();
- });
-
- it('calls triggerEvent with correct data when bidWinData is provided', () => {
- const bidWinData = {
- bidder: 'connatix',
- cpm: 2.5,
- requestId: 'abc123',
- bidId: 'dasdas-dsawda-dwaddw-dwdwd',
- adUnitCode: 'adunit_1',
- timeToRespond: 300,
- auctionId: 'auction_456',
- };
-
- spec.onBidWon(bidWinData);
- expect(ajaxStub.calledOnce).to.equal(true);
-
- const eventData = ajaxStub.firstCall.args[0];
- expect(eventData.type).to.equal('BidWon');
- expect(eventData.bestBidBidder).to.equal('connatix');
- expect(eventData.bestBidPrice).to.equal(2.5);
- expect(eventData.requestId).to.equal('abc123');
- expect(eventData.bidId).to.equal('dasdas-dsawda-dwaddw-dwdwd');
- expect(eventData.adUnitCode).to.equal('adunit_1');
- expect(eventData.timeToRespond).to.equal(300);
- expect(eventData.auctionId).to.equal('auction_456');
- });
-
- it('does not call triggerEvent if bidWinData is null', () => {
- spec.onBidWon(null);
- expect(ajaxStub.notCalled).to.equal(true);
- });
-
- it('does not call triggerEvent if bidWinData is undefined', () => {
- spec.onBidWon(undefined);
- expect(ajaxStub.notCalled).to.equal(true);
- });
- });
-
- describe('triggerEvent', function () {
- let ajaxStub;
-
- beforeEach(() => {
- ajaxStub = sinon.stub(ajax, 'ajax');
- });
-
- afterEach(() => {
- ajaxStub.restore();
- });
-
- it('should call ajax with the correct parameters', () => {
- const data = { type: 'BidWon', bestBidBidder: 'bidder1', bestBidPrice: 1.5, requestId: 'req123', adUnitCode: 'ad123', timeToRespond: 250, auctionId: 'auc123', context: {} };
- spec.triggerEvent(data);
-
- expect(ajaxStub.calledOnce).to.equal(true);
- const [url, _, payload, options] = ajaxStub.firstCall.args;
- expect(url).to.equal('https://capi.connatix.com/tr/am');
- expect(payload).to.equal(JSON.stringify(data));
- expect(options.method).to.equal('POST');
- expect(options.withCredentials).to.equal(false);
- });
- });
-
- describe('isBidRequestValid', function () {
- this.beforeEach(function () {
- bid = mockBidRequest();
- });
-
- it('Should return true if all required fileds are present', function () {
- expect(spec.isBidRequestValid(bid)).to.be.true;
- });
- it('Should return false if bidId is missing', function () {
- delete bid.bidId;
- expect(spec.isBidRequestValid(bid)).to.be.false;
- });
- it('Should return false if params object is missing', function () {
- delete bid.params;
- expect(spec.isBidRequestValid(bid)).to.be.false;
- });
- it('Should return false if placementId is missing from params', function () {
- delete bid.params.placementId;
- expect(spec.isBidRequestValid(bid)).to.be.false;
- });
- it('Should return false if mediaTypes is missing', function () {
- delete bid.mediaTypes;
- expect(spec.isBidRequestValid(bid)).to.be.false;
- });
- it('Should return false if both banner and video are missing from mediaTypes', function () {
- delete bid.mediaTypes.banner;
- expect(spec.isBidRequestValid(bid)).to.be.false;
- });
- it('Should return false if sizes is missing from banner object', function () {
- delete bid.mediaTypes.banner.sizes;
- expect(spec.isBidRequestValid(bid)).to.be.false;
- });
- it('Should return false if sizes is not an array', function () {
- bid.mediaTypes.banner.sizes = 'test';
- expect(spec.isBidRequestValid(bid)).to.be.false;
- });
- it('Should return false if sizes is an empty array', function () {
- bid.mediaTypes.banner.sizes = [];
- expect(spec.isBidRequestValid(bid)).to.be.false;
- });
- it('Should return true if video is set correctly', function () {
- addVideoToBidMock(bid);
- expect(spec.isBidRequestValid(bid)).to.be.true;
- });
- it('Should return false if context is set to adpod on video media type', function() {
- addVideoToBidMock(bid);
- bid.mediaTypes.video.context = ADPOD;
- expect(spec.isBidRequestValid(bid)).to.be.false;
- });
- it('Should return true if add an extra field was added to the bidRequest', function () {
- bid.params.test = 1;
- expect(spec.isBidRequestValid(bid)).to.be.true;
- });
- });
-
- describe('buildRequests', function () {
- let serverRequest;
- let setCookieStub, setDataInLocalStorageStub;
- const bidderRequest = {
- refererInfo: {
- canonicalUrl: '',
- numIframes: 0,
- reachedTop: true,
- referer: 'http://example.com',
- stack: ['http://example.com']
- },
- gdprConsent: {
- consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==',
- vendorData: {},
- gdprApplies: true
- },
- uspConsent: '1YYY',
- gppConsent: {
- gppString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==',
- applicableSections: [7]
- },
- ortb2: {
- site: {
- data: {
- pageType: 'article'
- }
- }
- }
- };
-
- this.beforeEach(function () {
- const mockIdentityProviderData = { mockKey: 'mockValue' };
- const CNX_IDS_EXPIRY = 24 * 30 * 60 * 60 * 1000;
- setCookieStub = sinon.stub(storage, 'setCookie');
- setDataInLocalStorageStub = sinon.stub(storage, 'setDataInLocalStorage');
- connatixSaveOnAllStorages('test_ids_cnx', mockIdentityProviderData, CNX_IDS_EXPIRY);
-
- bid = mockBidRequest();
- serverRequest = spec.buildRequests([bid], bidderRequest);
- })
-
- this.afterEach(function() {
- setCookieStub.restore();
- setDataInLocalStorageStub.restore();
- });
-
- it('Creates a ServerRequest object with method, URL and data', function () {
- expect(serverRequest).to.exist;
- expect(serverRequest.method).to.exist;
- expect(serverRequest.url).to.exist;
- expect(serverRequest.data).to.exist;
- });
- it('Returns POST method', function () {
- expect(serverRequest.method).to.equal('POST');
- });
- it('Returns valid URL', function () {
- expect(serverRequest.url).to.equal('https://capi.connatix.com/rtb/hba');
- });
- it('Returns request payload', function () {
- expect(serverRequest.data).to.not.empty;
- });
- it('Validate request payload', function () {
- expect(serverRequest.data.bidRequests[0].bidId).to.equal(bid.bidId);
- expect(serverRequest.data.bidRequests[0].placementId).to.equal(bid.params.placementId);
- expect(serverRequest.data.bidRequests[0].floor).to.equal(0);
- expect(serverRequest.data.bidRequests[0].mediaTypes).to.equal(bid.mediaTypes);
- expect(serverRequest.data.bidRequests[0].sizes).to.equal(bid.mediaTypes.sizes);
- expect(serverRequest.data.refererInfo).to.equal(bidderRequest.refererInfo);
- expect(serverRequest.data.gdprConsent).to.equal(bidderRequest.gdprConsent);
- expect(serverRequest.data.uspConsent).to.equal(bidderRequest.uspConsent);
- expect(serverRequest.data.gppConsent).to.equal(bidderRequest.gppConsent);
- expect(serverRequest.data.ortb2).to.equal(bidderRequest.ortb2);
- expect(serverRequest.data.identityProviderData).to.deep.equal({ mockKey: 'mockValue' });
- });
- });
-
- describe('interpretResponse', function () {
- const CustomerId = '99f20d18-c4b4-4a28-3d8e-d43e2c8cb4ac';
- const PlayerId = 'e4984e88-9ff4-45a3-8b9d-33aabcad634f';
- const Bid = {Cpm: 0.1, RequestId: '2f897340c4eaa3', Ttl: 86400, CustomerId, PlayerId};
-
- let serverResponse;
- this.beforeEach(function () {
- serverResponse = {
- body: {
- Bids: [ Bid ]
- },
- headers: function() { }
- };
- });
-
- it('Should return an empty array if Bids is null', function () {
- serverResponse.body.Bids = null;
-
- const response = spec.interpretResponse(serverResponse);
- expect(response).to.be.an('array').that.is.empty;
- });
-
- it('Should return an empty array if Bids is empty array', function () {
- serverResponse.body.Bids = [];
- const response = spec.interpretResponse(serverResponse);
- expect(response).to.be.an('array').that.is.empty;
- });
-
- it('Should return one bid response for one bid', function() {
- const bidResponses = spec.interpretResponse(serverResponse);
- expect(bidResponses.length).to.equal(1);
- });
-
- it('Should contains the same values as in the serverResponse', function() {
- const bidResponses = spec.interpretResponse(serverResponse);
-
- const [ bidResponse ] = bidResponses;
- expect(bidResponse.requestId).to.equal(serverResponse.body.Bids[0].RequestId);
- expect(bidResponse.cpm).to.equal(serverResponse.body.Bids[0].Cpm);
- expect(bidResponse.ttl).to.equal(serverResponse.body.Bids[0].Ttl);
- expect(bidResponse.currency).to.equal('USD');
- expect(bidResponse.mediaType).to.equal(BANNER);
- expect(bidResponse.netRevenue).to.be.true;
- });
-
- it('Should return n bid responses for n bids', function() {
- serverResponse.body.Bids = [ { ...Bid }, { ...Bid } ];
-
- const firstBidCpm = 4;
- serverResponse.body.Bids[0].Cpm = firstBidCpm;
-
- const secondBidCpm = 13;
- serverResponse.body.Bids[1].Cpm = secondBidCpm;
-
- const bidResponses = spec.interpretResponse(serverResponse);
- expect(bidResponses.length).to.equal(2);
-
- expect(bidResponses[0].cpm).to.equal(firstBidCpm);
- expect(bidResponses[1].cpm).to.equal(secondBidCpm);
- });
-
- it('Should contain specific values for banner bids', function () {
- const adHtml = 'ad html'
- serverResponse.body.Bids = [ { ...Bid, Ad: adHtml } ];
-
- const bidResponses = spec.interpretResponse(serverResponse);
- const [ bidResponse ] = bidResponses;
-
- expect(bidResponse.vastXml).to.be.undefined;
- expect(bidResponse.ad).to.equal(adHtml);
- expect(bidResponse.mediaType).to.equal(BANNER);
- });
-
- it('Should contain specific values for video bids', function () {
- const adVastXml = 'ad vast xml'
- serverResponse.body.Bids = [ { ...Bid, VastXml: adVastXml } ];
-
- const bidResponses = spec.interpretResponse(serverResponse);
- const [ bidResponse ] = bidResponses;
-
- expect(bidResponse.ad).to.be.undefined;
- expect(bidResponse.vastXml).to.equal(adVastXml);
- expect(bidResponse.mediaType).to.equal(VIDEO);
- });
- });
-
- describe('getUserSyncs', function() {
- const CustomerId = '99f20d18-c4b4-4a28-3d8e-d43e2c8cb4ac';
- const PlayerId = 'e4984e88-9ff4-45a3-8b9d-33aabcad634f';
- const UserSyncEndpoint = 'https://connatix.com/sync'
- const UserSyncEndpointWithParams = 'https://connatix.com/sync?param1=value1'
- const Bid = {Cpm: 0.1, RequestId: '2f897340c4eaa3', Ttl: 86400, CustomerId, PlayerId};
-
- const serverResponse = {
- body: {
- UserSyncEndpoint,
- Bids: [ Bid ]
- },
- headers: function() { }
- };
- const serverResponse2 = {
- body: {
- UserSyncEndpoint: UserSyncEndpointWithParams,
- Bids: [ Bid ]
- },
- headers: function() { }
- };
-
- it('Should return an empty array when iframeEnabled: false', function () {
- expect(spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [], {}, {}, {})).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array when serverResponses is emprt array', function () {
- expect(spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [], {}, {}, {})).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array when iframeEnabled: true but serverResponses in an empty array', function () {
- expect(spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [serverResponse], {}, {}, {})).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array when iframeEnabled: true but serverResponses in an not defined or null', function () {
- expect(spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, undefined, {}, {}, {})).to.be.an('array').that.is.empty;
- expect(spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, null, {}, {}, {})).to.be.an('array').that.is.empty;
- });
- it('Should return one user sync object when iframeEnabled is true and serverResponses is not an empry array', function () {
- expect(spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [serverResponse], {}, {}, {})).to.be.an('array').that.is.not.empty;
- });
- it('Should return a list containing a single object having type: iframe and url: syncUrl', function () {
- const userSyncList = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [serverResponse], undefined, undefined, undefined);
- const { type, url } = userSyncList[0];
- expect(type).to.equal('iframe');
- expect(url).to.equal(UserSyncEndpoint);
- });
- it('Should append gdpr: 0 if gdprConsent object is provided but gdprApplies field is not provided', function () {
- const userSyncList = spec.getUserSyncs(
- {iframeEnabled: true, pixelEnabled: true},
- [serverResponse],
- {},
- undefined,
- undefined
- );
- const { url } = userSyncList[0];
- expect(url).to.equal(`${UserSyncEndpoint}?gdpr=0`);
- });
- it('Should append gdpr having the value of gdprApplied if gdprConsent object is present and have gdprApplies field', function () {
- const userSyncList = spec.getUserSyncs(
- {iframeEnabled: true, pixelEnabled: true},
- [serverResponse],
- {gdprApplies: true},
- undefined,
- undefined
- );
- const { url } = userSyncList[0];
- expect(url).to.equal(`${UserSyncEndpoint}?gdpr=1`);
- });
- it('Should append gdpr_consent if gdprConsent object is present and have gdprApplies field', function () {
- const userSyncList = spec.getUserSyncs(
- {iframeEnabled: true, pixelEnabled: true},
- [serverResponse],
- {gdprApplies: true, consentString: 'alabala'},
- undefined,
- undefined
- );
- const { url } = userSyncList[0];
- expect(url).to.equal(`${UserSyncEndpoint}?gdpr=1&gdpr_consent=alabala`);
- });
- it('Should encodeURI gdpr_consent corectly', function () {
- const userSyncList = spec.getUserSyncs(
- {iframeEnabled: true, pixelEnabled: true},
- [serverResponse],
- {gdprApplies: true, consentString: 'test&2'},
- undefined,
- undefined
- );
- const { url } = userSyncList[0];
- expect(url).to.equal(`${UserSyncEndpoint}?gdpr=1&gdpr_consent=test%262`);
- });
- it('Should append usp_consent to the url if uspConsent is provided', function () {
- const userSyncList = spec.getUserSyncs(
- {iframeEnabled: true, pixelEnabled: true},
- [serverResponse],
- {gdprApplies: true, consentString: 'test&2'},
- '1YYYN',
- undefined
- );
- const { url } = userSyncList[0];
- expect(url).to.equal(`${UserSyncEndpoint}?gdpr=1&gdpr_consent=test%262&us_privacy=1YYYN`);
- });
- it('Should not modify the sync url if gppConsent param is provided', function () {
- const userSyncList = spec.getUserSyncs(
- {iframeEnabled: true, pixelEnabled: true},
- [serverResponse],
- {gdprApplies: true, consentString: 'test&2'},
- '1YYYN',
- {consent: '1'}
- );
- const { url } = userSyncList[0];
- expect(url).to.equal(`${UserSyncEndpoint}?gdpr=1&gdpr_consent=test%262&us_privacy=1YYYN`);
- });
- it('Should correctly append all consents to the sync url if the url contains query params', function () {
- const userSyncList = spec.getUserSyncs(
- {iframeEnabled: true, pixelEnabled: true},
- [serverResponse2],
- {gdprApplies: true, consentString: 'test&2'},
- '1YYYN',
- {consent: '1'}
- );
- const { url } = userSyncList[0];
- expect(url).to.equal(`${UserSyncEndpointWithParams}&gdpr=1&gdpr_consent=test%262&us_privacy=1YYYN`);
- });
- });
-
- describe('userIdAsEids', function() {
- let validBidRequests;
-
- this.beforeEach(function () {
- bid = mockBidRequest();
- validBidRequests = [bid];
- })
-
- it('Connatix adapter reads EIDs from Prebid user models and adds it to Request', function() {
- validBidRequests[0].userIdAsEids = [{
- 'source': 'adserver.org',
- 'uids': [{
- 'id': 'TTD_ID_FROM_USER_ID_MODULE',
- 'atype': 1,
- 'ext': {
- 'stype': 'ppuid',
- 'rtiPartner': 'TDID'
- }
- }]
- },
- {
- 'source': 'pubserver.org',
- 'uids': [{
- 'id': 'TDID_FROM_USER_ID_MODULE',
- 'atype': 1
- }]
- }];
- const serverRequest = spec.buildRequests(validBidRequests, {});
- expect(serverRequest.data.userIdList).to.deep.equal(validBidRequests[0].userIdAsEids);
- });
- });
-
- describe('isConnatix', function () {
- let aliasRegistryStub;
-
- beforeEach(() => {
- aliasRegistryStub = sinon.stub(adapterManager, 'aliasRegistry').value({});
- });
-
- afterEach(() => {
- aliasRegistryStub.restore();
- });
-
- it('should return false if aliasName is undefined or null', () => {
- expect(spec.isConnatix(undefined)).to.be.false;
- expect(spec.isConnatix(null)).to.be.false;
- });
-
- it('should return true if aliasName matches BIDDER_CODE', () => {
- const aliasName = BIDDER_CODE;
- expect(spec.isConnatix(aliasName)).to.be.true;
- });
-
- it('should return true if aliasName is mapped to BIDDER_CODE in aliasRegistry', () => {
- const aliasName = 'connatixAlias';
- aliasRegistryStub.value({ 'connatixAlias': BIDDER_CODE });
- expect(spec.isConnatix(aliasName)).to.be.true;
- });
-
- it('should return false if aliasName does not match BIDDER_CODE', () => {
- const aliasName = 'otherBidder';
- expect(spec.isConnatix(aliasName)).to.be.false;
- });
-
- it('should return false if aliasName is mapped to a different bidder in aliasRegistry', () => {
- const aliasName = 'someOtherAlias';
- aliasRegistryStub.value({ 'someOtherAlias': 'otherBidder' });
- expect(spec.isConnatix(aliasName)).to.be.false;
- });
- });
-
- describe('getBidFloor', function () {
- this.beforeEach(function () {
- bid = mockBidRequest();
- });
-
- it('Should return 0 if both getFloor method and bidfloor param from bid are absent.', function () {
- const floor = connatixGetBidFloor(bid);
- expect(floor).to.equal(0);
- });
-
- it('Should return the value of the bidfloor parameter if the getFloor method is not defined but the bidfloor parameter is defined', function () {
- const floorValue = 3;
- bid.params.bidfloor = floorValue;
-
- const floor = connatixGetBidFloor(bid);
- expect(floor).to.equal(floorValue);
- });
-
- it('Should return the value of the getFloor method if the getFloor method is defined but the bidfloor parameter is not defined', function () {
- const floorValue = 7;
- bid.getFloor = function() {
- return { floor: floorValue };
- };
-
- const floor = connatixGetBidFloor(bid);
- expect(floor).to.equal(floorValue);
- });
-
- it('Should return the value of the getFloor method if both getFloor method and bidfloor parameter are defined', function () {
- const floorParamValue = 3;
- bid.params.bidfloor = floorParamValue;
-
- const floorMethodValue = 7;
- bid.getFloor = function() {
- return { floor: floorMethodValue };
- };
-
- const floor = connatixGetBidFloor(bid);
- expect(floor).to.equal(floorMethodValue);
- });
-
- it('Should return 0 if the getFloor method is defined and it crash when call it', function () {
- bid.getFloor = function() {
- throw new Error('error');
- };
- const floor = connatixGetBidFloor(bid);
- expect(floor).to.equal(0);
- });
- });
- describe('getUserSyncs with message event listener', function() {
- const CNX_IDS_EXPIRY = 24 * 30 * 60 * 60 * 1000;
- const CNX_IDS_LOCAL_STORAGE_COOKIES_KEY = 'cnx_user_ids';
- const ALL_PROVIDERS_RESOLVED_EVENT = 'cnx_all_identity_providers_resolved';
-
- const mockData = {
- data: {
- supplementalEids: [{ provider: 2, group: 1, eidsList: ['123', '456'] }]
- }
- };
-
- function messageHandler(event) {
- if (!event.data || event.origin !== 'https://cds.connatix.com' || !event.data.cnx) {
- return;
- }
-
- const { message, data } = event.data.cnx;
-
- if (message === ALL_PROVIDERS_RESOLVED_EVENT) {
- window.removeEventListener('message', messageHandler);
- event.stopImmediatePropagation();
- }
-
- if (message === ALL_PROVIDERS_RESOLVED_EVENT || message === IDENTITY_PROVIDER_COLLECTION_UPDATED_EVENT) {
- if (data) {
- connatixSaveOnAllStorages(CNX_IDS_LOCAL_STORAGE_COOKIES_KEY, data, CNX_IDS_EXPIRY);
- }
- }
- }
-
- let sandbox;
-
- beforeEach(() => {
- sandbox = sinon.createSandbox();
- sandbox.stub(storage, 'setCookie');
- sandbox.stub(storage, 'setDataInLocalStorage');
- sandbox.stub(window, 'removeEventListener');
- sandbox.stub(storage, 'cookiesAreEnabled').returns(true);
- sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
- sandbox.stub(storage, 'getCookie');
- sandbox.stub(storage, 'getDataFromLocalStorage');
- });
-
- afterEach(() => {
- sandbox.restore();
- });
-
- it('Should set a cookie and save to local storage when a valid message is received', () => {
- const fakeEvent = {
- data: { cnx: { message: 'cnx_all_identity_providers_resolved', data: mockData } },
- origin: 'https://cds.connatix.com',
- stopImmediatePropagation: sinon.spy()
- };
-
- messageHandler(fakeEvent);
-
- expect(fakeEvent.stopImmediatePropagation.calledOnce).to.be.true;
- expect(window.removeEventListener.calledWith('message', messageHandler)).to.be.true;
- expect(storage.setCookie.calledWith(CNX_IDS_LOCAL_STORAGE_COOKIES_KEY, JSON.stringify(mockData), sinon.match.string)).to.be.true;
- expect(storage.setDataInLocalStorage.calledWith(CNX_IDS_LOCAL_STORAGE_COOKIES_KEY, JSON.stringify(mockData))).to.be.true;
-
- storage.getCookie.returns(JSON.stringify(mockData));
- storage.getDataFromLocalStorage.returns(JSON.stringify(mockData));
-
- const retrievedData = connatixReadFromAllStorages(CNX_IDS_LOCAL_STORAGE_COOKIES_KEY);
- expect(retrievedData).to.deep.equal(mockData);
- });
-
- it('Should not do anything when there is no data in the payload', () => {
- const fakeEvent = {
- data: null,
- origin: 'https://cds.connatix.com',
- stopImmediatePropagation: sinon.spy()
- };
-
- messageHandler(fakeEvent);
-
- expect(fakeEvent.stopImmediatePropagation.notCalled).to.be.true;
- expect(window.removeEventListener.notCalled).to.be.true;
- expect(storage.setCookie.notCalled).to.be.true;
- expect(storage.setDataInLocalStorage.notCalled).to.be.true;
- });
-
- it('Should not do anything when the origin is invalid', () => {
- const fakeEvent = {
- data: { cnx: { message: 'cnx_all_identity_providers_resolved', data: mockData } },
- origin: 'https://notConnatix.com',
- stopImmediatePropagation: sinon.spy()
- };
-
- messageHandler(fakeEvent);
-
- expect(fakeEvent.stopImmediatePropagation.notCalled).to.be.true;
- expect(window.removeEventListener.notCalled).to.be.true;
- expect(storage.setCookie.notCalled).to.be.true;
- expect(storage.setDataInLocalStorage.notCalled).to.be.true;
- });
- });
- describe('connatixHasQueryParams', () => {
- it('Should return false if there is no query param in the url', () => {
- const url = 'http://example.com'
- const result = connatixHasQueryParams(url);
- expect(result).to.equal(false);
- });
-
- it('Should return true if there is one query param in the url', () => {
- const url = 'http://example.com?query1=value1'
- const result = connatixHasQueryParams(url);
- expect(result).to.equal(true);
- });
-
- it('Should return true if there is multiple query params in the url', () => {
- const url = 'http://example.com?query1=value1&query2=value2'
- const result = connatixHasQueryParams(url);
- expect(result).to.equal(true);
- });
-
- it('Should return false if the url is invalid', () => {
- const url = 'example'
- const result = connatixHasQueryParams(url);
- expect(result).to.equal(false);
- });
- });
-});
diff --git a/test/spec/modules/connectadBidAdapter_spec.js b/test/spec/modules/connectadBidAdapter_spec.js
deleted file mode 100644
index 724f4eb93..000000000
--- a/test/spec/modules/connectadBidAdapter_spec.js
+++ /dev/null
@@ -1,794 +0,0 @@
-import {expect} from 'chai';
-import {spec} from 'modules/connectadBidAdapter.js';
-import { config } from 'src/config.js';
-import {newBidder} from 'src/adapters/bidderFactory.js';
-import assert from 'assert';
-
-describe('ConnectAd Adapter', function () {
- let bidRequests;
- let bidderRequest;
- let bidRequestsUserIds;
-
- beforeEach(function () {
- bidRequests = [
- {
- bidder: 'conntectad',
- params: {
- siteId: 123456,
- networkId: 123456,
- bidfloor: 0.50
- },
- adUnitCode: '/19968336/header-bid-tag-1',
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [300, 600]],
- }
- },
- bidId: '2f95c00074b931',
- auctionId: 'e76cbb58-f3e1-4ad9-9f4c-718c1919d0df',
- bidderRequestId: '1c56ad30b9b8ca8',
- transactionId: 'e76cbb58-f3e1-4ad9-9f4c-718c1919d0df',
- ortb2Imp: {
- ext: {
- tid: '601bda1a-01a9-4de9-b8f3-649d3bdd0d8f',
- gpid: '/12345/homepage-leftnav'
- }
- },
- }
- ];
-
- bidRequestsUserIds = [{
- bidder: 'conntectad',
- params: {
- siteId: 123456,
- networkId: 123456
- },
- adUnitCode: '/19968336/header-bid-tag-1',
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [300, 600]],
- }
- },
- bidId: '2f95c00074b931',
- auctionId: 'e76cbb58-f3e1-4ad9-9f4c-718c1919d0df',
- bidderRequestId: '1c56ad30b9b8ca8',
- transactionId: 'e76cbb58-f3e1-4ad9-9f4c-718c1919d0df',
- userIdAsEids: [
- {
- 'source': 'pubcid.org',
- 'uids': [
- {
- 'atype': 1,
- 'id': '123456'
- }
- ]
- }
- ]
- }];
-
- bidderRequest = {
- timeout: 3000,
- gdprConsent: {
- gdprApplies: true,
- consentString: 'consentDataString',
- vendorData: {}
- }
- }
- });
-
- afterEach(function () {
- config.resetConfig();
- });
-
- describe('inherited functions', function () {
- it('should exists and is a function', function () {
- const adapter = newBidder(spec);
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('implementation', function () {
- describe('for requests', function () {
- it('should accept bid', function () {
- const validBid = {
- bidder: 'connectad',
- params: {
- siteId: 123456,
- networkId: 123456
- },
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [300, 600]]
- }
- }
- };
- const isValid = spec.isBidRequestValid(validBid);
- expect(isValid).to.equal(true);
- });
-
- it('should reject if missing sizes', function () {
- const invalidBid = {
- bidder: 'connectad',
- params: {
- siteId: 123456,
- }
- };
- const isValid = spec.isBidRequestValid(invalidBid);
- expect(isValid).to.equal(false);
- });
-
- it('should return true when optional bidFloor params found for an ad', function () {
- const validBid = {
- bidder: 'connectad',
- params: {
- siteId: 123456,
- networkId: 123456,
- bidfloor: 0.20
- },
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [300, 600]]
- }
- }
- };
- const isValid = spec.isBidRequestValid(validBid);
- expect(isValid).to.equal(true)
- });
-
- it('should reject if missing siteId/networkId', function () {
- const invalidBid = {
- bidder: 'connectad',
- params: {},
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [300, 600]],
- }
- }
- };
- const isValid = spec.isBidRequestValid(invalidBid);
- expect(isValid).to.equal(false);
- });
-
- it('should reject if missing networkId', function () {
- const invalidBid = {
- bidder: 'connectad',
- params: {
- siteId: 123456
- },
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [300, 600]],
- }
- }
- };
- const isValid = spec.isBidRequestValid(invalidBid);
- expect(isValid).to.equal(false);
- });
-
- it('should contain SiteId and NetworkId', function () {
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const requestparse = JSON.parse(request.data);
- expect(requestparse.placements[0].siteId).to.equal(123456);
- expect(requestparse.placements[0].networkId).to.equal(123456);
- });
-
- it('should process floors module if available', function() {
- const floorInfo = {
- currency: 'USD',
- floor: 5.20
- };
- bidRequests[0].getFloor = () => floorInfo;
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const requestparse = JSON.parse(request.data);
- expect(requestparse.placements[0].bidfloor).to.equal(5.20);
- });
-
- it('should be bidfloor if no floormodule is available', function() {
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const requestparse = JSON.parse(request.data);
- expect(requestparse.placements[0].bidfloor).to.equal(0.50);
- });
-
- it('should have 0 bidfloor value', function() {
- const request = spec.buildRequests(bidRequestsUserIds, bidderRequest);
- const requestparse = JSON.parse(request.data);
- expect(requestparse.placements[0].bidfloor).to.equal(0);
- });
-
- it('should contain gdpr info', function () {
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const requestparse = JSON.parse(request.data);
-
- expect(requestparse.user.ext.gdpr).to.equal(1);
- expect(requestparse.user.ext.consent).to.equal('consentDataString');
- });
-
- it('should build a request if Consent but no gdprApplies', function () {
- const localbidderRequest = {
- timeout: 3000,
- gdprConsent: {
- gdprApplies: false,
- consentString: 'consentDataString',
- },
- }
- const request = spec.buildRequests(bidRequests, localbidderRequest);
- const requestparse = JSON.parse(request.data);
-
- expect(requestparse.placements[0].siteId).to.equal(123456);
- expect(requestparse.user.ext.consent).to.equal('consentDataString');
- });
-
- it('should build a request if gdprConsent empty', function () {
- const localbidderRequest = {
- timeout: 3000,
- gdprConsent: {}
- }
- const request = spec.buildRequests(bidRequests, localbidderRequest);
- const requestparse = JSON.parse(request.data);
-
- expect(requestparse.placements[0].siteId).to.equal(123456);
- });
-
- it('should have CCPA Consent if defined', function () {
- const uspConsent = '1YYN'
- bidderRequest.uspConsent = uspConsent
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const requestparse = JSON.parse(request.data);
-
- expect(requestparse.user.ext.us_privacy).to.equal(uspConsent);
- });
-
- it('should not have CCPA Consent if not defined', function () {
- bidderRequest.uspConsent = undefined
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const requestparse = JSON.parse(request.data);
- expect(requestparse.user.ext.us_privacy).to.be.undefined;
- });
-
- it('should not include schain when not provided', function () {
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const requestparse = JSON.parse(request.data);
- expect(requestparse).to.not.have.property('source.ext.schain');
- });
-
- it('should submit coppa if set in config', function () {
- sinon.stub(config, 'getConfig')
- .withArgs('coppa')
- .returns(true);
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const requestparse = JSON.parse(request.data);
- expect(requestparse.regs.coppa).to.equal(1);
- config.getConfig.restore();
- });
-
- it('should not set coppa when coppa is not provided or is set to false', function () {
- sinon.stub(config, 'getConfig')
- .withArgs('coppa')
- .returns(false);
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const requestparse = JSON.parse(request.data);
- assert.equal(requestparse.regs.coppa, undefined);
- config.getConfig.restore();
- });
-
- it('should send all UserData data', function () {
- const request = spec.buildRequests(bidRequestsUserIds, bidderRequest);
- const requestparse = JSON.parse(request.data);
- expect(requestparse.user.ext.eids).to.be.an('array');
- expect(requestparse.user.ext.eids[0].uids[0].id).to.equal('123456');
- });
-
- it('should include DSA signals', function () {
- const dsa = {
- dsarequired: 3,
- pubrender: 0,
- datatopub: 2,
- transparency: [
- {
- domain: 'domain1.com',
- dsaparams: [1]
- },
- {
- domain: 'domain2.com',
- dsaparams: [1, 2]
- }
- ]
- };
-
- let bidRequest = {
- ortb2: {
- regs: {
- ext: {
- dsa
- }
- }
- }
- };
- const request = spec.buildRequests(bidRequests, bidRequest);
- const data = JSON.parse(request.data);
- assert.deepEqual(data.regs.ext.dsa, dsa);
- });
-
- it('should pass auction level tid', function() {
- const bidRequest = Object.assign([], bidRequests);
-
- const localBidderRequest = {
- ...bidderRequest,
- ortb2: {
- source: {
- tid: '9XSL9B79XM'
- }
- }
- }
-
- const request = spec.buildRequests(bidRequest, localBidderRequest);
- const data = JSON.parse(request.data);
- expect(data.source?.tid).to.equal('9XSL9B79XM')
- });
-
- it('should pass gpid', function() {
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const requestparse = JSON.parse(request.data);
- expect(requestparse.placements[0].gpid).to.equal('/12345/homepage-leftnav');
- });
-
- it('should pass impression level tid', function() {
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const requestparse = JSON.parse(request.data);
- expect(requestparse.placements[0].tid).to.equal('601bda1a-01a9-4de9-b8f3-649d3bdd0d8f');
- });
-
- it('should pass first party data', function() {
- const bidRequest = Object.assign([], bidRequests);
-
- const localBidderRequest = {
- ...bidderRequest,
- ortb2: {
- bcat: ['IAB1', 'IAB2-1'],
- badv: ['xyz.com', 'zyx.com'],
- site: { ext: { data: 'some site data' } },
- device: { ext: { data: 'some device data' } },
- user: { ext: { data: 'some user data' } },
- regs: { ext: { data: 'some regs data' } }
- }
- };
-
- const request = spec.buildRequests(bidRequest, localBidderRequest);
- const data = JSON.parse(request.data);
- expect(data.bcat).to.deep.equal(localBidderRequest.ortb2.bcat);
- expect(data.badv).to.deep.equal(localBidderRequest.ortb2.badv);
- expect(data.site).to.nested.include({'ext.data': 'some site data'});
- expect(data.device).to.nested.include({'ext.data': 'some device data'});
- expect(data.user).to.nested.include({'ext.data': 'some user data'});
- expect(data.regs).to.nested.include({'ext.data': 'some regs data'});
- });
-
- it('should accept tmax from global config if not set by requestBids method', function() {
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const requestparse = JSON.parse(request.data);
-
- expect(requestparse.tmax).to.deep.equal(3000);
- });
-
- it('should populate schain', function () {
- const bidRequest = Object.assign({}, bidRequests[0], {
- ortb2: {
- source: {
- ext: {
- schain: {
- ver: '1.0',
- complete: 1,
- nodes: [
- {
- 'asi': 'reseller1.com',
- 'sid': 'absc1',
- 'hp': 1
- }
- ]
- }
- }
- }
- }
- });
-
- const request = spec.buildRequests([bidRequest], bidderRequest);
- const requestparse = JSON.parse(request.data);
- expect(requestparse.source.ext.schain).to.deep.equal({
- ver: '1.0',
- complete: 1,
- nodes: [
- {
- 'asi': 'reseller1.com',
- 'sid': 'absc1',
- 'hp': 1
- }
- ]
- });
- });
- });
-
- describe('GPP Implementation', function() {
- it('should check with GPP Consent', function () {
- const bidRequest = {
- gppConsent: {
- 'gppString': 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN',
- 'fullGppData': {
- 'sectionId': 3,
- 'gppVersion': 1,
- 'sectionList': [
- 5,
- 7
- ],
- 'applicableSections': [
- 5
- ],
- 'gppString': 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN',
- 'pingData': {
- 'cmpStatus': 'loaded',
- 'gppVersion': '1.0',
- 'cmpDisplayStatus': 'visible',
- 'supportedAPIs': [
- 'tcfca',
- 'usnat',
- 'usca',
- 'usva',
- 'usco',
- 'usut',
- 'usct'
- ],
- 'cmpId': 31
- },
- 'eventName': 'sectionChange'
- },
- 'applicableSections': [
- 5
- ],
- 'apiVersion': 1
- }
- };
- const request = spec.buildRequests(bidRequests, bidRequest);
- const data = JSON.parse(request.data);
- expect(data.regs.gpp).to.equal('DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN');
- expect(data.regs.gpp_sid[0]).to.equal(5);
- });
-
- it('should check without GPP Consent', function () {
- const bidRequest = {};
- const request = spec.buildRequests(bidRequests, bidRequest);
- const data = JSON.parse(request.data);
- expect(data.regs.gpp).to.equal(undefined);
- });
-
- it('should check with GPP Consent read from OpenRTB2', function () {
- const bidRequest = {
- ortb2: {
- regs: {
- 'gpp': 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN',
- 'gpp_sid': [
- 5
- ]
- }
- }
- };
- const request = spec.buildRequests(bidRequests, bidRequest);
- const data = JSON.parse(request.data);
- expect(data.regs.gpp).to.equal('DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN');
- expect(data.regs.gpp_sid[0]).to.equal(5);
- });
- });
-
- describe('bid responses', function () {
- it('should return complete bid response with adomain', function () {
- const ADOMAINS = ['connectad.io'];
-
- const serverResponse = {
- body: {
- decisions: {
- '2f95c00074b931': {
- adId: '0',
- adomain: ['connectad.io'],
- contents: [
- {
- body: '<<<---- Creative --->>>'
- }
- ],
- height: '250',
- width: '300',
- pricing: {
- clearPrice: 11.899999999999999
- }
- }
- }
- }
- };
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const bids = spec.interpretResponse(serverResponse, request);
-
- expect(bids).to.be.lengthOf(1);
- expect(bids[0].cpm).to.equal(11.899999999999999);
- expect(bids[0].width).to.equal('300');
- expect(bids[0].height).to.equal('250');
- expect(bids[0].ad).to.have.length.above(1);
- expect(bids[0].meta.advertiserDomains).to.deep.equal(ADOMAINS);
- });
-
- it('should process meta response object', function () {
- const ADOMAINS = ['connectad.io'];
- const dsa = {
- behalf: 'Advertiser',
- paid: 'Advertiser',
- transparency: [{
- domain: 'dsp1domain.com',
- dsaparams: [1, 2]
- }],
- adrender: 1
- };
-
- const serverResponse = {
- body: {
- decisions: {
- '2f95c00074b931': {
- adId: '0',
- adomain: ['connectad.io'],
- contents: [
- {
- body: '<<<---- Creative --->>>'
- }
- ],
- height: '250',
- width: '300',
- dsa: dsa,
- category: 'IAB123',
- pricing: {
- clearPrice: 11.899999999999999
- }
- }
- }
- }
- };
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const bids = spec.interpretResponse(serverResponse, request);
-
- expect(bids).to.be.lengthOf(1);
- expect(bids[0].cpm).to.equal(11.899999999999999);
- expect(bids[0].width).to.equal('300');
- expect(bids[0].height).to.equal('250');
- expect(bids[0].ad).to.have.length.above(1);
- expect(bids[0].meta.advertiserDomains).to.deep.equal(ADOMAINS);
- expect(bids[0].meta.dsa).to.equal(dsa);
- expect(bids[0].meta.primaryCatId).to.equal('IAB123');
- });
-
- it('should return complete bid response with empty adomain', function () {
- const ADOMAINS = [];
-
- const serverResponse = {
- body: {
- decisions: {
- '2f95c00074b931': {
- adId: '0',
- contents: [
- {
- body: '<<<---- Creative --->>>'
- }
- ],
- height: '250',
- width: '300',
- pricing: {
- clearPrice: 11.899999999999999
- }
- }
- }
- }
- };
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const bids = spec.interpretResponse(serverResponse, request);
-
- expect(bids).to.be.lengthOf(1);
- expect(bids[0].cpm).to.equal(11.899999999999999);
- expect(bids[0].width).to.equal('300');
- expect(bids[0].height).to.equal('250');
- expect(bids[0].ad).to.have.length.above(1);
- expect(bids[0].meta.advertiserDomains).to.deep.equal(ADOMAINS);
- });
-
- it('should return empty bid response', function () {
- const serverResponse = {
- body: {
- decisions: []
- }
- };
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const bids = spec.interpretResponse(serverResponse, request);
- expect(bids).to.be.lengthOf(0);
- });
-
- it('should return empty bid response on incorrect size', function () {
- const serverResponse = {
- body: {
- decisions: {
- '2f95c00074b931': {
- adId: '0',
- contents: [
- {
- body: '<<<---- Creative --->>>'
- }
- ],
- height: '160',
- width: '600',
- pricing: {
- clearPrice: 0
- }
- }
- }
- }
- };
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const bids = spec.interpretResponse(serverResponse, request);
- expect(bids).to.be.lengthOf(0);
- });
-
- it('should return empty bid response on 0 cpm', function () {
- const serverResponse = {
- body: {
- decisions: {
- '2f95c00074b931': {
- adId: '0',
- contents: [
- {
- body: '<<<---- Creative --->>>'
- }
- ],
- height: '300',
- width: '250',
- pricing: {
- clearPrice: 0
- }
- }
- }
- }
- };
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const bids = spec.interpretResponse(serverResponse, request);
- expect(bids).to.be.lengthOf(0);
- });
-
- it('should process a deal id', function () {
- const serverResponse = {
- body: {
- decisions: {
- '2f95c00074b931': {
- adId: '0',
- dealid: 'ABC90210',
- contents: [
- {
- body: '<<<---- Creative --->>>'
- }
- ],
- height: '300',
- width: '250',
- pricing: {
- clearPrice: 11.899999999999999
- }
- }
- }
- }
- };
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const bids = spec.interpretResponse(serverResponse, request);
- expect(bids).to.be.lengthOf(1);
- expect(bids[0].dealid).to.equal('ABC90210');
- });
- });
- });
-
- describe('GPP Sync', function() {
- it('should concatenate gppString and applicableSections values in the returned image url', () => {
- const gppConsent = { gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN', applicableSections: [5] };
- const result = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, undefined, undefined, undefined, gppConsent);
- expect(result).to.deep.equal([{
- type: 'image',
- url: `https://sync.connectad.io/ImageSyncer?gpp=DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN&gpp_sid=5&`
- }]);
- });
-
- it('should concatenate gppString and applicableSections values in the returned iFrame url', () => {
- const gppConsent = { gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN', applicableSections: [5, 6] };
- const result = spec.getUserSyncs({iframeEnabled: true}, undefined, undefined, undefined, gppConsent);
- expect(result).to.deep.equal([{
- type: 'iframe',
- url: `https://sync.connectad.io/iFrameSyncer?gpp=DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN&gpp_sid=5%2C6&`
- }]);
- });
-
- it('should return url without Gpp consent if gppConsent is undefined', () => {
- const result = spec.getUserSyncs({iframeEnabled: true}, undefined, undefined, undefined, undefined);
- expect(result).to.deep.equal([{
- type: 'iframe',
- url: `https://sync.connectad.io/iFrameSyncer?`
- }]);
- });
-
- it('should return iFrame url without Gpp consent if gppConsent.gppString is undefined', () => {
- const gppConsent = { applicableSections: ['5'] };
- const result = spec.getUserSyncs({iframeEnabled: true}, undefined, undefined, undefined, gppConsent);
- expect(result).to.deep.equal([{
- type: 'iframe',
- url: `https://sync.connectad.io/iFrameSyncer?`
- }]);
- });
- });
-
- describe('getUserSyncs', () => {
- const testParams = [
- {
- name: 'iframe/no gdpr or ccpa',
- arguments: [{ iframeEnabled: true, pixelEnabled: false }, {}, null],
- expect: {
- type: 'iframe',
- pixels: ['https://sync.connectad.io/iFrameSyncer?']
- }
- },
- {
- name: 'iframe/gdpr',
- arguments: [{ iframeEnabled: true, pixelEnabled: false }, {}, {gdprApplies: true, consentString: '234234'}],
- expect: {
- type: 'iframe',
- pixels: ['https://sync.connectad.io/iFrameSyncer?gdpr=1&gdpr_consent=234234&']
- }
- },
- {
- name: 'iframe/ccpa',
- arguments: [{ iframeEnabled: true, pixelEnabled: true }, {}, null, 'YN12'],
- expect: {
- type: 'iframe',
- pixels: ['https://sync.connectad.io/iFrameSyncer?us_privacy=YN12&']
- }
- },
- {
- name: 'iframe/ccpa & gdpr',
- arguments: [{ iframeEnabled: true, pixelEnabled: false }, {}, {gdprApplies: true, consentString: '234234'}, 'YN12'],
- expect: {
- type: 'iframe',
- pixels: ['https://sync.connectad.io/iFrameSyncer?gdpr=1&gdpr_consent=234234&us_privacy=YN12&']
- }
- },
- {
- name: 'image/ccpa & gdpr',
- arguments: [{ iframeEnabled: false, pixelEnabled: true }, {}, {gdprApplies: true, consentString: '234234'}, 'YN12'],
- expect: {
- type: 'image',
- pixels: ['https://sync.connectad.io/ImageSyncer?gdpr=1&gdpr_consent=234234&us_privacy=YN12&']
- }
- },
- {
- name: 'image/gdpr',
- arguments: [{ iframeEnabled: false, pixelEnabled: true }, {}, {gdprApplies: true, consentString: '234234'}],
- expect: {
- type: 'image',
- pixels: ['https://sync.connectad.io/ImageSyncer?gdpr=1&gdpr_consent=234234&']
- }
- },
- {
- name: 'should prioritize iframe over image for user sync',
- arguments: [{ iframeEnabled: true, pixelEnabled: true }, {}, null],
- expect: {
- type: 'iframe',
- pixels: ['https://sync.connectad.io/iFrameSyncer?']
- }
- }
- ];
-
- for (let i = 0; i < testParams.length; i++) {
- const currParams = testParams[i];
- it(currParams.name, function () {
- const result = spec.getUserSyncs.apply(this, currParams.arguments);
- expect(result).to.have.lengthOf(currParams.expect.pixels.length);
- for (let ix = 0; ix < currParams.expect.pixels.length; ix++) {
- expect(result[ix].url).to.equal(currParams.expect.pixels[ix]);
- expect(result[ix].type).to.equal(currParams.expect.type);
- }
- });
- }
- });
-});
diff --git a/test/spec/modules/consumableBidAdapter_spec.js b/test/spec/modules/consumableBidAdapter_spec.js
deleted file mode 100644
index 51db64019..000000000
--- a/test/spec/modules/consumableBidAdapter_spec.js
+++ /dev/null
@@ -1,819 +0,0 @@
-import {expect} from 'chai';
-import {spec} from 'modules/consumableBidAdapter.js';
-import {createBid} from 'src/bidfactory.js';
-import {config} from 'src/config.js';
-import {deepClone} from 'src/utils.js';
-import { createEidsArray } from 'modules/userId/eids.js';
-
-const ENDPOINT = 'https://e.serverbid.com/api/v2';
-const SMARTSYNC_CALLBACK = 'serverbidCallBids';
-
-const BIDDER_REQUEST_1 = {
- bidderCode: 'consumable',
- auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99',
- bidderRequestId: '1c56ad30b9b8ca8',
- bidRequest: [
- {
- bidder: 'consumable',
- params: {
- networkId: '9969',
- siteId: '730181',
- unitId: '123456',
- unitName: 'cnsmbl-unit'
- },
- placementCode: 'header-bid-tag-1',
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [300, 600]]
- }
- },
- bidId: '23acc48ad47af5',
- auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99',
- bidderRequestId: '1c56ad30b9b8ca8',
- transactionId: '92489f71-1bf2-49a0-adf9-000cea934729'
- }
- ],
- gdprConsent: {
- consentString: 'consent-test',
- gdprApplies: false
- },
- gppConsent: {
- applicableSections: [1, 2],
- gppString: 'consent-string'
- },
- refererInfo: {
- referer: 'http://example.com/page.html',
- reachedTop: true,
- numIframes: 2,
- stack: [
- 'http://example.com/page.html',
- 'http://example.com/iframe1.html',
- 'http://example.com/iframe2.html'
- ]
- },
- ortb2: {
- device: {
- language: 'en'
- },
- source: {
- ext: {
- schain: {
- 'ver': '1.0',
- 'complete': 1,
- 'nodes': [
- {
- 'asi': 'indirectseller.com',
- 'sid': '00001',
- 'hp': 1
- },
- {
- 'asi': 'indirectseller-2.com',
- 'sid': '00002',
- 'hp': 2
- },
- ]
- }
- }
- }
- }
-};
-
-const BIDDER_REQUEST_2 = {
- bidderCode: 'consumable',
- auctionId: 'a4713c32-3762-4798-b342-4ab810ca770d',
- bidderRequestId: '109f2a181342a9',
- bidRequest: [
- {
- bidder: 'consumable',
- params: {
- networkId: 9969,
- siteId: 730181,
- unitId: 123456,
- unitName: 'cnsmbl-unit'
- },
- placementCode: 'div-gpt-ad-1487778092495-0',
- mediaTypes: {
- banner: {
- sizes: [
- [728, 90],
- [970, 90]
- ]
- }
- },
- bidId: '2b0f82502298c9',
- bidderRequestId: '109f2a181342a9',
- auctionId: 'a4713c32-3762-4798-b342-4ab810ca770d'
- },
- {
- bidder: 'consumable',
- params: {
- networkId: 9969,
- siteId: 730181,
- unitId: 123456,
- unitName: 'cnsmbl-unit'
- },
- placementCode: 'div-gpt-ad-1487778092495-0',
- mediaTypes: {
- banner: {
- sizes: [
- [728, 90],
- [970, 90]
- ]
- }
- },
- bidId: '123',
- bidderRequestId: '109f2a181342a9',
- auctionId: 'a4713c32-3762-4798-b342-4ab810ca770d'
- }
- ],
- gdprConsent: {
- consentString: 'consent-test',
- gdprApplies: true
- },
- refererInfo: {
- referer: 'http://example.com/page.html',
- reachedTop: true,
- numIframes: 2,
- stack: [
- 'http://example.com/page.html',
- 'http://example.com/iframe1.html',
- 'http://example.com/iframe2.html'
- ]
- },
- ortb2: {
- device: {
- language: 'en'
- }
- }
-};
-
-const BIDDER_REQUEST_VIDEO = {
- bidderCode: 'consumable',
- auctionId: 'a4713c32-3762-4798-b342-4ab810ca770d',
- bidderRequestId: '109f2a181342a9',
- bidRequest: [
- {
- bidder: 'consumable',
- params: {
- networkId: 9969,
- siteId: 730181,
- unitId: 123456,
- unitName: 'cnsmbl-unit'
- },
- placementCode: 'div-gpt-ad-1487778092495-0',
- mediaTypes: {
- video: {
- playerSize: [188, 106],
- context: 'instream',
- mimes: ['application/javascript', 'application/x-mpegurl', 'video/3gpp', 'video/mp4', 'video/mpeg', 'video/ogg', 'video/webm', 'video/x-m4v', 'video/x-ms-asf', 'video/x-ms-wmv', 'video/x-msvideo'],
- minduration: 0,
- maxduration: 120,
- protocols: [1, 2, 3, 4, 5, 6, 7, 8],
- api: [1, 2],
- linearity: 1
- }
- },
- bidId: '6202d555b2f94537',
- bidderRequestId: '109f2a181342a9',
- auctionId: 'a4713c32-3762-4798-b342-4ab810ca770d'
- }
- ],
- gdprConsent: {
- consentString: 'consent-test',
- gdprApplies: true
- },
- refererInfo: {
- referer: 'http://example.com/page.html',
- reachedTop: true,
- numIframes: 2,
- stack: [
- 'http://example.com/page.html',
- 'http://example.com/iframe1.html',
- 'http://example.com/iframe2.html'
- ]
- },
- ortb2: {
- device: {
- language: 'en'
- }
- }
-};
-
-const BIDDER_REQUEST_EMPTY = {
- bidderCode: 'consumable',
- auctionId: 'b06458ef-4fe5-4a0b-a61b-bccbcedb7b11',
- bidderRequestId: '8c8006750b10fd',
- bidRequest: [],
- gdprConsent: {
- consentString: 'consent-test',
- gdprApplies: false
- },
- ortb2: {
- device: {
- language: 'en'
- }
- }
-};
-
-const AD_SERVER_RESPONSE = {
- 'headers': null,
- 'body': {
- 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' },
- 'pixels': [{ 'type': 'image', 'url': '//sync.serverbid.com/ss/' }],
- 'decisions': {
- '2b0f82502298c9': {
- 'adId': 2364764,
- 'creativeId': 1950991,
- 'flightId': 2788300,
- 'campaignId': 542982,
- 'clickUrl': 'https://e.serverbid.com/r',
- 'impressionUrl': 'https://e.serverbid.com/i.gif',
- 'contents': [{
- 'type': 'html',
- 'body': '',
- 'data': {
- 'height': 90,
- 'width': 728,
- 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif',
- 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif'
- },
- 'template': 'image'
- }],
- 'height': 90,
- 'width': 728,
- 'events': [],
- 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5}
- },
- '123': {
- 'adId': 2364764,
- 'creativeId': 1950991,
- 'flightId': 2788300,
- 'campaignId': 542982,
- 'clickUrl': 'https://e.serverbid.com/r',
- 'impressionUrl': 'https://e.serverbid.com/i.gif',
- 'contents': [{
- 'type': 'html',
- 'body': '',
- 'data': {
- 'height': 90,
- 'width': 728,
- 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif',
- 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif'
- },
- 'template': 'image'
- }],
- 'height': 90,
- 'width': 728,
- 'events': [],
- 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5}
- }
- }
- }
-};
-
-const AD_SERVER_RESPONSE_2 = {
- 'headers': null,
- 'body': {
- 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' },
- 'pixels': [{ 'type': 'image', 'url': '//sync.serverbid.com/ss/' }],
- 'bdr': 'notcx',
- 'decisions': {
- '2b0f82502298c9': {
- 'adId': 2364764,
- 'creativeId': 1950991,
- 'flightId': 2788300,
- 'campaignId': 542982,
- 'clickUrl': 'https://e.serverbid.com/r',
- 'impressionUrl': 'https://e.serverbid.com/i.gif',
- 'contents': [{
- 'type': 'html',
- 'body': '',
- 'data': {
- 'height': 90,
- 'width': 728,
- 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif',
- 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif'
- },
- 'template': 'image'
- }],
- 'height': 90,
- 'width': 728,
- 'events': [],
- 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5},
- 'mediaType': 'banner',
- 'cats': ['IAB1', 'IAB2', 'IAB3'],
- 'networkId': 1234567,
- },
- '123': {
- 'adId': 2364764,
- 'creativeId': 1950991,
- 'flightId': 2788300,
- 'campaignId': 542982,
- 'clickUrl': 'https://e.serverbid.com/r',
- 'impressionUrl': 'https://e.serverbid.com/i.gif',
- 'contents': [{
- 'type': 'html',
- 'body': '',
- 'data': {
- 'height': 90,
- 'width': 728,
- 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif',
- 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif'
- },
- 'template': 'image'
- }],
- 'height': 90,
- 'width': 728,
- 'events': [],
- 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5},
- 'mediaType': 'banner',
- 'cats': ['IAB1', 'IAB2'],
- 'networkId': 2345678,
- }
- }
- }
-};
-
-const AD_SERVER_RESPONSE_VIDEO_1 = {
- 'headers': null,
- 'body': {
- 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' },
- 'pixels': [{ 'type': 'image', 'url': '//sync.serverbid.com/ss/' }],
- 'decisions': {
- '6202d555b2f94537': {
- 'adId': 3866158402,
- 'creativeId': 'C1-somo-test-video',
- 'width': 640,
- 'height': 480,
- 'pricing': {
- 'clearPrice': 1.58
- },
- 'vastUrl': 'https://x.serverbid.com/rtb/v?auc=217c051d06b011ed9cbc72b17f01ec03&sc=1.575&s=22&a=9dcab16d340d664310c2135a76989fe946a9d46e5d5f24ff5e2f17bffbb7704a43638bd3f600951e&n=9&r=0&t=1658158906595',
- 'uuid': 'f1e7287514ce11ed9c1de2b3ba87449a',
- 'bidderName': 'consumable',
- 'adomain': ['consumabletv.com'],
- 'cats': ['IAB3-1'],
- 'mediaType': 'video',
- 'networkId': 1
- }
- }
- }
-};
-
-const AD_SERVER_RESPONSE_VIDEO_2 = {
- 'headers': null,
- 'body': {
- 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' },
- 'pixels': [{ 'type': 'image', 'url': '//sync.serverbid.com/ss/' }],
- 'decisions': {
- '6202d555b2f94537': {
- 'adId': 3866158402,
- 'creativeId': 'C1-somo-test-video',
- 'width': 640,
- 'height': 480,
- 'pricing': {
- 'clearPrice': 1.58
- },
- 'vastXml': '',
- 'uuid': 'f1e7287514ce11ed9c1de2b3ba87449a',
- 'bidderName': 'consumable',
- 'adomain': ['consumabletv.com'],
- 'cats': ['IAB3-1'],
- 'mediaType': 'video',
- 'networkId': 1
- }
- }
- }
-};
-
-const BUILD_REQUESTS_OUTPUT = {
- method: 'POST',
- url: 'https://e.serverbid.com/api/v2',
- data: '',
- bidRequest: BIDDER_REQUEST_2.bidRequest,
- bidderRequest: BIDDER_REQUEST_2
-};
-
-const BUILD_REQUESTS_VIDEO_OUTPUT = {
- method: 'POST',
- url: 'https://e.serverbid.com/api/v2',
- data: '',
- bidRequest: BIDDER_REQUEST_VIDEO.bidRequest,
- bidderRequest: BIDDER_REQUEST_VIDEO
-};
-
-describe('Consumable BidAdapter', function () {
- const adapter = spec;
-
- describe('bid request validation', function () {
- it('should accept valid bid requests', function () {
- const bid = {
- bidder: 'consumable',
- params: {
- networkId: '9969',
- siteId: '123',
- unitId: '123456',
- unitName: 'cnsmbl-unit'
- }
- };
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should accept valid bid requests with extra fields', function () {
- const bid = {
- bidder: 'consumable',
- params: {
- networkId: '9969',
- siteId: '123',
- unitId: '123456',
- unitName: 'cnsmbl-unit',
- zoneId: '123'
- }
- };
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should reject bid requests without siteId', function () {
- const bid = {
- bidder: 'consumable',
- params: {
- networkId: '9969',
- unitId: '123456',
- unitName: 'cnsmbl-unit'
- }
- };
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
-
- it('should reject bid requests without networkId', function () {
- const bid = {
- bidder: 'consumable',
- params: {
- siteId: '9969',
- unitId: '123456',
- unitName: 'cnsmbl-unit'
- }
- };
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
- });
-
- describe('buildRequests validation', function () {
- it('creates request data', function () {
- const request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1);
-
- expect(request).to.exist.and.to.be.a('object');
- });
-
- it('request to consumable should contain a url', function () {
- const request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1);
-
- expect(request.url).to.have.string('serverbid.com');
- });
-
- it('requires valid bids to make request', function () {
- const request = spec.buildRequests(BIDDER_REQUEST_EMPTY.bidRequest, BIDDER_REQUEST_EMPTY);
- expect(request.bidRequest).to.be.empty;
- });
-
- it('sends bid request to ENDPOINT via POST', function () {
- const request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1);
-
- expect(request.method).to.have.string('POST');
- });
-
- it('passes through bidderRequest', function () {
- const request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1);
-
- expect(request.bidderRequest).to.equal(BIDDER_REQUEST_1);
- });
-
- it('should contain schain if it exists in the bidRequest', function () {
- const request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1);
- const data = JSON.parse(request.data);
-
- expect(data.schain).to.deep.equal(BIDDER_REQUEST_1.ortb2.source.ext.schain)
- });
-
- it('should not contain schain if it does not exist in the bidRequest', function () {
- const request = spec.buildRequests(BIDDER_REQUEST_2.bidRequest, BIDDER_REQUEST_2);
- const data = JSON.parse(request.data);
-
- expect(data.schain).to.be.undefined;
- });
-
- it('should contain coppa if configured', function () {
- config.setConfig({ coppa: true });
- const request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1);
- const data = JSON.parse(request.data);
-
- expect(data.coppa).to.be.true;
- });
-
- it('should not contain coppa if not configured', function () {
- config.setConfig({ coppa: false });
- const request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1);
- const data = JSON.parse(request.data);
-
- expect(data.coppa).to.be.undefined;
- });
-
- it('should contain video object for video requests', function () {
- const request = spec.buildRequests(BIDDER_REQUEST_VIDEO.bidRequest, BIDDER_REQUEST_VIDEO);
- const data = JSON.parse(request.data);
-
- expect(data.placements[0].video).to.deep.equal(BIDDER_REQUEST_VIDEO.bidRequest[0].mediaTypes.video);
- });
-
- it('sets bidfloor param if present', function () {
- const bidderRequest1 = deepClone(BIDDER_REQUEST_1);
- const bidderRequest2 = deepClone(BIDDER_REQUEST_2);
- bidderRequest1.bidRequest[0].params.bidFloor = 0.05;
- bidderRequest2.bidRequest[0].getFloor = function() {
- return {
- currency: 'USD',
- floor: 0.15
- }
- };
- const request1 = spec.buildRequests(bidderRequest1.bidRequest, BIDDER_REQUEST_1);
- const data1 = JSON.parse(request1.data);
- const request2 = spec.buildRequests(bidderRequest2.bidRequest, BIDDER_REQUEST_2);
- const data2 = JSON.parse(request2.data);
-
- expect(data1.placements[0].bidfloor).to.equal(0.05);
- expect(data2.placements[0].bidfloor).to.equal(0.15);
- });
- it('should contain the language param', function () {
- const request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1);
- const data = JSON.parse(request.data);
-
- expect(data.lang).to.equal('en');
- });
- });
- describe('interpretResponse validation', function () {
- it('response should have valid bidderCode', function () {
- const bidRequest = spec.buildRequests(BIDDER_REQUEST_2.bidRequest, BIDDER_REQUEST_2);
- const bid = createBid(bidRequest.bidRequest[0]);
-
- expect(bid.bidderCode).to.equal('consumable');
- });
-
- it('response should include objects for all bids', function () {
- const bids = spec.interpretResponse(AD_SERVER_RESPONSE, BUILD_REQUESTS_OUTPUT);
- expect(bids.length).to.equal(2);
- });
-
- it('registers bids', function () {
- const bids = spec.interpretResponse(AD_SERVER_RESPONSE_2, BUILD_REQUESTS_OUTPUT);
- bids.forEach(b => {
- expect(b).to.have.property('cpm');
- expect(b.cpm).to.be.above(0);
- expect(b).to.have.property('requestId');
- expect(b).to.have.property('unitId');
- expect(b).to.have.property('unitName');
- expect(b).to.have.property('cpm');
- expect(b).to.have.property('width');
- expect(b).to.have.property('height');
- expect(b).to.have.property('ad');
- expect(b).to.have.property('currency', 'USD');
- expect(b).to.have.property('creativeId');
- expect(b).to.have.property('ttl', 30);
- expect(b).to.have.property('netRevenue', true);
- expect(b).to.have.property('referrer');
- expect(b.meta).to.have.property('advertiserDomains');
- expect(b.meta).to.have.property('primaryCatId');
- expect(b.meta).to.have.property('secondaryCatIds');
- expect(b.meta).to.have.property('networkId');
- expect(b.meta).to.have.property('mediaType');
- });
- });
-
- it('registers video bids with vastUrl', function () {
- const bids = spec.interpretResponse(AD_SERVER_RESPONSE_VIDEO_1, BUILD_REQUESTS_VIDEO_OUTPUT);
-
- bids.forEach(b => {
- expect(b.mediaType).to.equal('video');
- expect(b.meta).to.have.property('mediaType', 'video');
- expect(b.vastUrl).to.equal('https://x.serverbid.com/rtb/v?auc=217c051d06b011ed9cbc72b17f01ec03&sc=1.575&s=22&a=9dcab16d340d664310c2135a76989fe946a9d46e5d5f24ff5e2f17bffbb7704a43638bd3f600951e&n=9&r=0&t=1658158906595');
- expect(b.vastXml).to.be.undefined;
- expect(b.videoCacheKey).to.equal('f1e7287514ce11ed9c1de2b3ba87449a');
- });
- })
-
- it('registers video bids with vastXml', function () {
- const bids = spec.interpretResponse(AD_SERVER_RESPONSE_VIDEO_2, BUILD_REQUESTS_VIDEO_OUTPUT);
-
- bids.forEach(b => {
- expect(b.mediaType).to.equal('video');
- expect(b.meta).to.have.property('mediaType', 'video');
- expect(b.vastXml).to.equal('');
- expect(b.vastUrl).to.be.undefined;
- expect(b.ad).to.equal('');
- expect(b.videoCacheKey).to.equal('f1e7287514ce11ed9c1de2b3ba87449a');
- });
- })
-
- it('handles nobid responses', function () {
- const EMPTY_RESP = Object.assign({}, AD_SERVER_RESPONSE, {'body': {'decisions': null}})
- const bids = spec.interpretResponse(EMPTY_RESP, BUILD_REQUESTS_OUTPUT);
-
- expect(bids).to.be.empty;
- });
-
- it('handles no server response', function () {
- const bids = spec.interpretResponse(null, BUILD_REQUESTS_OUTPUT);
-
- expect(bids).to.be.empty;
- });
- });
- describe('getUserSyncs', function () {
- const syncOptions = {'iframeEnabled': true};
-
- it('handles empty sync options', function () {
- const opts = spec.getUserSyncs({});
-
- expect(opts).to.be.undefined;
- });
-
- it('should return a sync url if iframe syncs are enabled', function () {
- const opts = spec.getUserSyncs(syncOptions);
-
- expect(opts.length).to.equal(1);
- });
-
- it('should return a sync url if iframe syncs are enabled and server response is empty', function () {
- const opts = spec.getUserSyncs(syncOptions, []);
-
- expect(opts.length).to.equal(1);
- });
-
- it('should return a sync url if iframe syncs are enabled and server response does not contain a bdr attribute', function () {
- const opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE]);
-
- expect(opts.length).to.equal(1);
- });
-
- it('should return a sync url if iframe syncs are enabled and server response contains a bdr attribute that is not cx', function () {
- const opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE_2]);
-
- expect(opts.length).to.equal(1);
- });
-
- it('should return a sync url if iframe syncs are enabled and GDPR applies', function () {
- const gdprConsent = {
- consentString: 'GDPR_CONSENT_STRING',
- gdprApplies: true,
- }
- const opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE], gdprConsent);
-
- expect(opts.length).to.equal(1);
- expect(opts[0].url).to.equal('https://sync.serverbid.com/ss/730181.html?gdpr=1&gdpr_consent=GDPR_CONSENT_STRING');
- })
-
- it('should return a sync url if iframe syncs are enabled and GDPR is undefined', function () {
- const gdprConsent = {
- consentString: 'GDPR_CONSENT_STRING',
- gdprApplies: undefined,
- }
- const opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE], gdprConsent);
-
- expect(opts.length).to.equal(1);
- expect(opts[0].url).to.equal('https://sync.serverbid.com/ss/730181.html?gdpr=0&gdpr_consent=GDPR_CONSENT_STRING');
- })
-
- it('should return a sync url if iframe syncs are enabled and has GPP consent with applicable sections', function () {
- const gppConsent = {
- applicableSections: [1, 2],
- gppString: 'GPP_CONSENT_STRING'
- }
- const opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE], {}, '', gppConsent);
-
- expect(opts.length).to.equal(1);
- expect(opts[0].url).to.equal('https://sync.serverbid.com/ss/730181.html?gpp=GPP_CONSENT_STRING&gpp_sid=1%2C2');
- })
-
- it('should return a sync url if iframe syncs are enabled and has GPP consent without applicable sections', function () {
- const gppConsent = {
- applicableSections: [],
- gppString: 'GPP_CONSENT_STRING'
- }
- const opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE], {}, '', gppConsent);
-
- expect(opts.length).to.equal(1);
- expect(opts[0].url).to.equal('https://sync.serverbid.com/ss/730181.html?gpp=GPP_CONSENT_STRING');
- })
-
- it('should return a sync url if iframe syncs are enabled and USP applies', function () {
- const uspConsent = 'USP_CONSENT_STRING';
- const opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE], {}, uspConsent);
-
- expect(opts.length).to.equal(1);
- expect(opts[0].url).to.equal('https://sync.serverbid.com/ss/730181.html?us_privacy=USP_CONSENT_STRING');
- })
-
- it('should return a sync url if iframe syncs are enabled, GDPR and USP applies', function () {
- const gdprConsent = {
- consentString: 'GDPR_CONSENT_STRING',
- gdprApplies: true,
- }
- const uspConsent = 'USP_CONSENT_STRING';
- const opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE], gdprConsent, uspConsent);
-
- expect(opts.length).to.equal(1);
- expect(opts[0].url).to.equal('https://sync.serverbid.com/ss/730181.html?gdpr=1&gdpr_consent=GDPR_CONSENT_STRING&us_privacy=USP_CONSENT_STRING');
- })
-
- it('should return a sync url if pixel syncs are enabled and some are returned from the server', function () {
- const syncOptions = {'pixelEnabled': true};
- const opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE]);
-
- expect(opts.length).to.equal(1);
- });
- });
- describe('unifiedId from userId module', function() {
- let sandbox, bidderRequest;
- beforeEach(() => {
- sandbox = sinon.createSandbox();
- bidderRequest = deepClone(BIDDER_REQUEST_1);
- });
-
- afterEach(() => {
- sandbox.restore();
- });
-
- it('Request should have EIDs', function() {
- bidderRequest.bidRequest[0].userId = {};
- bidderRequest.bidRequest[0].userId.tdid = 'TTD_ID';
- bidderRequest.bidRequest[0].userIdAsEids = [{
- 'source': 'adserver.org',
- 'uids': [{
- 'id': 'TTD_ID_FROM_USER_ID_MODULE',
- 'atype': 1,
- 'ext': {
- 'rtiPartner': 'TDID'
- }
- }]
- }];
- const request = spec.buildRequests(bidderRequest.bidRequest, BIDDER_REQUEST_1);
- const data = JSON.parse(request.data);
- expect(data.user.eids).to.deep.equal(bidderRequest.bidRequest[0].userIdAsEids);
- });
-
- it('Request should remove non-objects for userIdAsEids', function () {
- bidderRequest.bidRequest[0].userId = {};
- bidderRequest.bidRequest[0].userId.tdid = 'TTD_ID';
- bidderRequest.bidRequest[0].userIdAsEids = [
- {
- source: 'adserver.org',
- uids: [
- {
- id: 'TTD_ID_FROM_USER_ID_MODULE',
- atype: 1,
- ext: {
- rtiPartner: 'TDID',
- },
- },
- ],
- },
- 'RANDOM_IDENTIFIER_STRING'
- ];
- const scrubbedEids = [
- {
- source: 'adserver.org',
- uids: [
- {
- id: 'TTD_ID_FROM_USER_ID_MODULE',
- atype: 1,
- ext: {
- rtiPartner: 'TDID',
- },
- },
- ],
- },
- ];
- const request = spec.buildRequests(
- bidderRequest.bidRequest,
- BIDDER_REQUEST_1
- );
- const data = JSON.parse(request.data);
- expect(data.user.eids).to.deep.equal(
- scrubbedEids
- );
- });
-
- it('Request should NOT have adsrvrOrgId params if userId is NOT object', function() {
- const request = spec.buildRequests(bidderRequest.bidRequest, BIDDER_REQUEST_1);
- const data = JSON.parse(request.data);
- expect(data.user.eids).to.deep.equal(undefined);
- });
-
- it('Request should NOT have adsrvrOrgId params if userId.tdid is NOT string', function() {
- bidderRequest.bidRequest[0].userId = {
- tdid: 1234
- };
- const request = spec.buildRequests(bidderRequest.bidRequest, BIDDER_REQUEST_1);
- const data = JSON.parse(request.data);
- expect(data.user.eids).to.deep.equal(undefined);
- });
- });
-});
diff --git a/test/spec/modules/contentexchangeBidAdapter_spec.js b/test/spec/modules/contentexchangeBidAdapter_spec.js
deleted file mode 100644
index 12a4c6c5d..000000000
--- a/test/spec/modules/contentexchangeBidAdapter_spec.js
+++ /dev/null
@@ -1,516 +0,0 @@
-import { expect } from 'chai';
-import { spec } from '../../../modules/contentexchangeBidAdapter.js';
-import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js';
-import { getUniqueIdentifierStr } from '../../../src/utils.js';
-
-const bidder = 'contentexchange';
-
-describe('ContentexchangeBidAdapter', function () {
- const userIdAsEids = [{
- source: 'test.org',
- uids: [{
- id: '01**********',
- atype: 1,
- ext: {
- third: '01***********'
- }
- }]
- }];
- const bids = [
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
- placementId: 'testBanner'
- },
- userIdAsEids
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [VIDEO]: {
- playerSize: [[300, 300]],
- minduration: 5,
- maxduration: 60
- }
- },
- params: {
- placementId: 'testVideo'
- },
- userIdAsEids
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [NATIVE]: {
- native: {
- title: {
- required: true
- },
- body: {
- required: true
- },
- icon: {
- required: true,
- size: [64, 64]
- }
- }
- }
- },
- params: {
- placementId: 'testNative'
- },
- userIdAsEids
- }
- ];
-
- const invalidBid = {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
-
- }
- }
-
- const bidderRequest = {
- uspConsent: '1---',
- gdprConsent: {
- consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw',
- vendorData: {}
- },
- refererInfo: {
- referer: 'https://test.com',
- page: 'https://test.com'
- },
- ortb2: {
- device: {
- w: 1512,
- h: 982,
- language: 'en-UK'
- }
- },
- timeout: 500
- };
-
- describe('isBidRequestValid', function () {
- it('Should return true if there are bidId, params and key parameters present', function () {
- expect(spec.isBidRequestValid(bids[0])).to.be.true;
- });
- it('Should return false if at least one of parameters is not present', function () {
- expect(spec.isBidRequestValid(invalidBid)).to.be.false;
- });
- });
-
- describe('buildRequests', function () {
- let serverRequest = spec.buildRequests(bids, bidderRequest);
-
- it('Creates a ServerRequest object with method, URL and data', function () {
- expect(serverRequest).to.exist;
- expect(serverRequest.method).to.exist;
- expect(serverRequest.url).to.exist;
- expect(serverRequest.data).to.exist;
- });
-
- it('Returns POST method', function () {
- expect(serverRequest.method).to.equal('POST');
- });
-
- it('Returns valid URL', function () {
- expect(serverRequest.url).to.equal('https://eu2.adnetwork.agency/pbjs');
- });
-
- it('Returns general data valid', function () {
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.all.keys('deviceWidth',
- 'deviceHeight',
- 'device',
- 'language',
- 'secure',
- 'host',
- 'page',
- 'placements',
- 'coppa',
- 'ccpa',
- 'gdpr',
- 'tmax',
- 'bcat',
- 'badv',
- 'bapp',
- 'battr'
- );
- expect(data.deviceWidth).to.be.a('number');
- expect(data.deviceHeight).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');
- expect(data.page).to.be.a('string');
- expect(data.coppa).to.be.a('number');
- expect(data.gdpr).to.be.a('object');
- expect(data.ccpa).to.be.a('string');
- expect(data.tmax).to.be.a('number');
- expect(data.placements).to.have.lengthOf(3);
- });
-
- it('Returns valid placements', function () {
- const { placements } = serverRequest.data;
- for (let i = 0, len = placements.length; i < len; i++) {
- const placement = placements[i];
- expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']);
- expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]);
- expect(placement.bidId).to.be.a('string');
- expect(placement.schain).to.be.an('object');
- expect(placement.bidfloor).to.exist.and.to.equal(0);
- expect(placement.type).to.exist.and.to.equal('publisher');
- expect(placement.eids).to.exist.and.to.be.deep.equal(userIdAsEids);
-
- if (placement.adFormat === BANNER) {
- expect(placement.sizes).to.be.an('array');
- }
- switch (placement.adFormat) {
- case BANNER:
- expect(placement.sizes).to.be.an('array');
- break;
- case VIDEO:
- expect(placement.playerSize).to.be.an('array');
- expect(placement.minduration).to.be.an('number');
- expect(placement.maxduration).to.be.an('number');
- break;
- case NATIVE:
- expect(placement.native).to.be.an('object');
- break;
- }
- }
- });
-
- it('Returns valid endpoints', function () {
- const bids = [
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
- endpointId: 'testBanner',
- },
- userIdAsEids
- }
- ];
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
-
- const { placements } = serverRequest.data;
- for (let i = 0, len = placements.length; i < len; i++) {
- const placement = placements[i];
- expect(placement.endpointId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']);
- expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]);
- expect(placement.bidId).to.be.a('string');
- expect(placement.schain).to.be.an('object');
- expect(placement.bidfloor).to.exist.and.to.equal(0);
- expect(placement.type).to.exist.and.to.equal('network');
- expect(placement.eids).to.exist.and.to.be.deep.equal(userIdAsEids);
-
- if (placement.adFormat === BANNER) {
- expect(placement.sizes).to.be.an('array');
- }
- switch (placement.adFormat) {
- case BANNER:
- expect(placement.sizes).to.be.an('array');
- break;
- case VIDEO:
- expect(placement.playerSize).to.be.an('array');
- expect(placement.minduration).to.be.an('number');
- expect(placement.maxduration).to.be.an('number');
- break;
- case NATIVE:
- expect(placement.native).to.be.an('object');
- break;
- }
- }
- });
-
- it('Returns data with gdprConsent and without uspConsent', function () {
- delete bidderRequest.uspConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.gdpr).to.exist;
- expect(data.gdpr).to.be.a('object');
- expect(data.gdpr).to.have.property('consentString');
- expect(data.gdpr).to.not.have.property('vendorData');
- expect(data.gdpr.consentString).to.equal(bidderRequest.gdprConsent.consentString);
- expect(data.ccpa).to.not.exist;
- delete bidderRequest.gdprConsent;
- });
-
- it('Returns data with uspConsent and without gdprConsent', function () {
- bidderRequest.uspConsent = '1---';
- delete bidderRequest.gdprConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.ccpa).to.exist;
- expect(data.ccpa).to.be.a('string');
- expect(data.ccpa).to.equal(bidderRequest.uspConsent);
- expect(data.gdpr).to.not.exist;
- });
- });
-
- describe('gpp consent', function () {
- it('bidderRequest.gppConsent', () => {
- bidderRequest.gppConsent = {
- gppString: 'abc123',
- applicableSections: [8]
- };
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
-
- delete bidderRequest.gppConsent;
- })
-
- it('bidderRequest.ortb2.regs.gpp', () => {
- bidderRequest.ortb2 = bidderRequest.ortb2 || {};
- bidderRequest.ortb2.regs = bidderRequest.ortb2.regs || {};
- bidderRequest.ortb2.regs.gpp = 'abc123';
- bidderRequest.ortb2.regs.gpp_sid = [8];
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
- })
- });
-
- describe('interpretResponse', function () {
- it('Should interpret banner response', function () {
- const banner = {
- body: [{
- mediaType: 'banner',
- width: 300,
- height: 250,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const bannerResponses = spec.interpretResponse(banner);
- expect(bannerResponses).to.be.an('array').that.is.not.empty;
- const dataItem = bannerResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal(banner.body[0].requestId);
- expect(dataItem.cpm).to.equal(banner.body[0].cpm);
- expect(dataItem.width).to.equal(banner.body[0].width);
- expect(dataItem.height).to.equal(banner.body[0].height);
- expect(dataItem.ad).to.equal(banner.body[0].ad);
- expect(dataItem.ttl).to.equal(banner.body[0].ttl);
- expect(dataItem.creativeId).to.equal(banner.body[0].creativeId);
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal(banner.body[0].currency);
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should interpret video response', function () {
- const video = {
- body: [{
- vastUrl: 'test.com',
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const videoResponses = spec.interpretResponse(video);
- expect(videoResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = videoResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.5);
- expect(dataItem.vastUrl).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should interpret native response', function () {
- const native = {
- body: [{
- mediaType: 'native',
- native: {
- clickUrl: 'test.com',
- title: 'Test',
- image: 'test.com',
- impressionTrackers: ['test.com'],
- },
- ttl: 120,
- cpm: 0.4,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const nativeResponses = spec.interpretResponse(native);
- expect(nativeResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = nativeResponses[0];
- expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta');
- expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image')
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.4);
- expect(dataItem.native.clickUrl).to.equal('test.com');
- expect(dataItem.native.title).to.equal('Test');
- expect(dataItem.native.image).to.equal('test.com');
- expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty;
- expect(dataItem.native.impressionTrackers[0]).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should return an empty array if invalid banner response is passed', function () {
- const invBanner = {
- body: [{
- width: 300,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
-
- const serverResponses = spec.interpretResponse(invBanner);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid video response is passed', function () {
- const invVideo = {
- body: [{
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invVideo);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid native response is passed', function () {
- const invNative = {
- body: [{
- mediaType: 'native',
- clickUrl: 'test.com',
- title: 'Test',
- impressionTrackers: ['test.com'],
- ttl: 120,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- }]
- };
- const serverResponses = spec.interpretResponse(invNative);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid response is passed', function () {
- const invalid = {
- body: [{
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invalid);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- });
-
- describe('getUserSyncs', function() {
- it('Should return array of objects with proper sync config , include GDPR', function() {
- const syncData = spec.getUserSyncs({}, {}, {
- consentString: 'ALL',
- gdprApplies: true,
- }, {});
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://sync2.adnetwork.agency/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0')
- });
- it('Should return array of objects with proper sync config , include CCPA', function() {
- const syncData = spec.getUserSyncs({}, {}, {}, {
- consentString: '1---'
- });
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://sync2.adnetwork.agency/image?pbjs=1&ccpa_consent=1---&coppa=0')
- });
- it('Should return array of objects with proper sync config , include GPP', function() {
- const syncData = spec.getUserSyncs({}, {}, {}, {}, {
- gppString: 'abc123',
- applicableSections: [8]
- });
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://sync2.adnetwork.agency/image?pbjs=1&gpp=abc123&gpp_sid=8&coppa=0')
- });
- });
-});
diff --git a/test/spec/modules/contxtfulBidAdapter_spec.js b/test/spec/modules/contxtfulBidAdapter_spec.js
deleted file mode 100644
index f0695130b..000000000
--- a/test/spec/modules/contxtfulBidAdapter_spec.js
+++ /dev/null
@@ -1,1008 +0,0 @@
-import { spec, safeStringify } from 'modules/contxtfulBidAdapter.js';
-import { newBidder } from 'src/adapters/bidderFactory.js';
-import { config } from 'src/config.js';
-import * as ajax from 'src/ajax.js';
-const VERSION = 'v1';
-const CUSTOMER = 'CUSTOMER';
-const BIDDER_ENDPOINT = 'prebid.receptivity.io';
-const RX_FROM_API = { ReceptivityState: 'Receptive', test_info: 'rx_from_engine' };
-
-describe('contxtful bid adapter', function () {
- const adapter = newBidder(spec);
- let sandbox;
-
- beforeEach(function () {
- sandbox = sinon.createSandbox();
- });
-
- afterEach(function () {
- sandbox.restore();
- });
-
- describe('SafeStringify function', function () {
- it('should stringify normal objects successfully', function () {
- const normalObject = { name: 'test', value: 123, active: true };
- const result = safeStringify(normalObject);
- expect(result).to.equal('{"name":"test","value":123,"active":true}');
- });
-
- it('should handle arrays correctly', function () {
- const array = [1, 2, 'three', { nested: true }];
- const result = safeStringify(array);
- expect(result).to.equal('[1,2,"three",{"nested":true}]');
- });
-
- it('should handle circular references', function () {
- const objA = { name: 'A' };
- const objB = { name: 'B', ref: objA };
- objA.ref = objB; // Create circular reference
-
- const result = safeStringify(objA);
- expect(result).to.be.a('string');
- expect(result).to.include('[Circular]');
- expect(result).to.include('"name":"A"');
- });
-
- it('should handle functions by omitting them (standard JSON.stringify behavior)', function () {
- const objWithFunction = {
- name: 'test',
- method: function () { return 'hello'; },
- arrow: () => 'world'
- };
-
- const result = safeStringify(objWithFunction);
- expect(result).to.equal('{"name":"test"}');
- expect(result).to.not.include('[Function]');
- });
-
- it('should handle undefined values by omitting them (standard JSON.stringify behavior)', function () {
- const objWithUndefined = {
- name: 'test',
- undefinedValue: undefined,
- nullValue: null
- };
-
- const result = safeStringify(objWithUndefined);
- expect(result).to.equal('{"name":"test","nullValue":null}');
- expect(result).to.not.include('[Undefined]');
- });
-
- it('should handle mixed complex objects', function () {
- const complexObj = {
- string: 'test',
- number: 42,
- boolean: true,
- nullVal: null,
- undefinedVal: undefined,
- func: function () { return 'test'; },
- nested: {
- array: [1, 2, function () { }],
- date: new Date('2023-01-01')
- }
- };
-
- const result = safeStringify(complexObj);
- expect(result).to.be.a('string');
- expect(result).to.include('"string":"test"');
- expect(result).to.include('"number":42');
- // Functions and undefined values are omitted by standard JSON.stringify
- expect(result).to.not.include('[Function]');
- expect(result).to.not.include('[Undefined]');
- });
-
- it('should handle nested circular references', function () {
- const parent = { name: 'parent', children: [] };
- const child1 = { name: 'child1', parent: parent };
- const child2 = { name: 'child2', parent: parent };
- parent.children.push(child1, child2);
-
- const result = safeStringify(parent);
- expect(result).to.be.a('string');
- expect(result).to.include('[Circular]');
- expect(result).to.include('"name":"parent"');
- });
-
- it('should handle empty objects and arrays', function () {
- expect(safeStringify({})).to.equal('{}');
- expect(safeStringify([])).to.equal('[]');
- });
-
- it('should handle primitive values', function () {
- expect(safeStringify('string')).to.equal('"string"');
- expect(safeStringify(123)).to.equal('123');
- expect(safeStringify(true)).to.equal('true');
- expect(safeStringify(null)).to.equal('null');
- });
-
- it('should handle Date objects', function () {
- const date = new Date('2023-01-01T00:00:00.000Z');
- const result = safeStringify(date);
- expect(result).to.include('2023-01-01');
- });
-
- it('should handle bigint values by converting them to strings', function () {
- const objWithBigInt = {
- name: 'test',
- bigNumber: BigInt('12345678901234567890'),
- regularNumber: 123
- };
-
- const result = safeStringify(objWithBigInt);
- expect(result).to.include('"bigNumber":"12345678901234567890"');
- expect(result).to.include('"name":"test"');
- expect(result).to.include('"regularNumber":123');
- });
-
- it('should handle objects with toJSON methods', function () {
- const objWithToJSON = {
- name: 'test',
- toJSON: function () {
- return { serialized: true };
- }
- };
-
- const result = safeStringify(objWithToJSON);
- expect(result).to.equal('{"serialized":true}');
- });
-
- it('should fall back to safeJSONEncode for completely unstringifiable objects', function () {
- // Mock an object that breaks JSON.stringify even with replacer
- const problematicObj = {};
- Object.defineProperty(problematicObj, 'problematic', {
- get: function () {
- throw new Error('Cannot access this property');
- },
- enumerable: true
- });
-
- const result = safeStringify(problematicObj);
- // Should not throw and should return a string
- expect(result).to.be.a('string');
- });
-
- it('should handle browser Window objects safely', function () {
- const objWithWindow = {
- name: 'test',
- windowRef: window
- };
-
- const result = safeStringify(objWithWindow);
- expect(result).to.include('[Browser Object]');
- expect(result).to.include('"name":"test"');
- });
-
- it('should handle objects with inaccessible properties', function () {
- const problematicObj = {
- name: 'test',
- safeData: 'value',
- normalProperty: 'normal'
- };
-
- // Instead of testing property access errors (which can break entire stringify),
- // let's test that the function handles objects that contain browser objects
- // which should be converted to [Inaccessible Object] or [Browser Object]
- if (typeof window !== 'undefined') {
- problematicObj.browserRef = window;
- }
-
- const result = safeStringify(problematicObj);
- expect(result).to.be.a('string');
- expect(result).to.include('"name":"test"');
- expect(result).to.include('"safeData":"value"');
- expect(result).to.include('"normalProperty":"normal"');
-
- if (typeof window !== 'undefined') {
- expect(result).to.include('[Browser Object]');
- }
- });
-
- it('should handle mixed problematic objects', function () {
- const mixedObj = {
- normal: 'value',
- windowRef: window,
- circular: null
- };
- mixedObj.circular = mixedObj; // Create circular reference
-
- const result = safeStringify(mixedObj);
- expect(result).to.include('[Browser Object]');
- expect(result).to.include('[Circular]');
- expect(result).to.include('"normal":"value"');
- });
-
- it('should handle IMA3 video renderer objects safely', function () {
- // Simulate the IMA3 video renderer object with simpler structure
- const ima3RendererObj = {
- url: "https://imasdk.googleapis.com/js/sdkloader/ima3.js",
- renderNow: false,
- cmd: [null],
- someData: "test"
- };
-
- // Add a simple browser object reference that should be detected
- if (typeof window !== 'undefined') {
- ima3RendererObj.windowRef = window;
- }
-
- const result = safeStringify(ima3RendererObj);
- expect(result).to.be.a('string');
- expect(result).to.include('"url":"https://imasdk.googleapis.com/js/sdkloader/ima3.js"');
- expect(result).to.include('"renderNow":false');
- expect(result).to.include('"someData":"test"');
- if (typeof window !== 'undefined') {
- expect(result).to.include('[Browser Object]'); // for window reference
- }
- });
-
- it('should handle complex nested objects with mixed browser elements', function () {
- const complexBidData = {
- bidId: 'test-bid-123',
- adUnitCode: 'div-ad-unit',
- cpm: 1.25,
- currency: 'USD',
- renderer: {
- url: "https://imasdk.googleapis.com/js/sdkloader/ima3.js",
- renderNow: false,
- cmd: [null]
- },
- sizes: [[300, 250], [728, 90]]
- };
-
- // Add browser objects that should be detected by current implementation
- if (typeof window !== 'undefined') {
- complexBidData.windowContext = window;
- }
- if (typeof document !== 'undefined') {
- complexBidData.documentRef = document;
- }
-
- const result = safeStringify(complexBidData);
- expect(result).to.be.a('string');
- expect(result).to.include('"bidId":"test-bid-123"');
- expect(result).to.include('"cpm":1.25');
- if (typeof window !== 'undefined' || typeof document !== 'undefined') {
- expect(result).to.include('[Browser Object]');
- }
- });
-
- it('should handle additional browser objects safely', function () {
- const objWithBrowserObjects = {
- name: 'test'
- };
-
- // Only test browser objects that are detected by current implementation
- if (typeof window !== 'undefined') {
- objWithBrowserObjects.windowRef = window;
- }
- if (typeof document !== 'undefined') {
- objWithBrowserObjects.documentRef = document;
- }
-
- const result = safeStringify(objWithBrowserObjects);
- expect(result).to.be.a('string');
- expect(result).to.include('"name":"test"');
-
- // Current implementation only detects Window, Document, HTMLElement, Node
- // It doesn't detect navigator, location, etc. as browser objects
- if (typeof window !== 'undefined' || typeof document !== 'undefined') {
- expect(result).to.include('[Browser Object]');
- }
- });
-
- it('should handle event objects and DOM-related objects', function () {
- const objWithDOMObjects = {
- bidId: 'test-123',
- data: 'normal-data'
- };
-
- // Add DOM element if available in test environment
- if (typeof document !== 'undefined') {
- const div = document.createElement('div');
- objWithDOMObjects.element = div;
- }
-
- // Simulate an event object
- if (typeof Event !== 'undefined') {
- try {
- objWithDOMObjects.event = new Event('click');
- } catch (e) {
- // Some test environments might not support Event constructor
- objWithDOMObjects.event = { type: 'click', target: null };
- }
- }
-
- const result = safeStringify(objWithDOMObjects);
- expect(result).to.be.a('string');
- expect(result).to.include('"bidId":"test-123"');
- expect(result).to.include('"data":"normal-data"');
- });
-
- it('should handle storage and web API objects safely', function () {
- const objWithWebAPIs = {
- name: 'test-data',
- normalArray: [1, 2, 3]
- };
-
- // Add storage references if available
- if (typeof globalThis.localStorage !== 'undefined') {
- objWithWebAPIs.storage = globalThis.localStorage;
- }
-
- // Add Blob if available
- if (typeof Blob !== 'undefined') {
- try {
- objWithWebAPIs.blob = new Blob(['test'], { type: 'text/plain' });
- } catch (e) {
- // Fallback if Blob not available in test environment
- }
- }
-
- const result = safeStringify(objWithWebAPIs);
- expect(result).to.be.a('string');
- expect(result).to.include('"name":"test-data"');
- expect(result).to.include('"normalArray":[1,2,3]');
- // Should handle browser objects without throwing
- expect(result).to.not.throw;
- });
-
- it('should detect browser objects using parent hierarchies and duck typing', function () {
- const testObj = {
- normalData: 'safe-value',
- number: 42
- };
-
- // Add various types of browser objects that should be caught by parent classes
- if (typeof document !== 'undefined') {
- testObj.element = document.createElement('div'); // HTMLElement -> EventTarget
- testObj.textNode = document.createTextNode('test'); // Text -> Node
- }
-
- // Add objects that should be caught by duck typing (constructor name patterns)
- const mockObjects = [];
-
- // Mock HTMLCanvasElement (constructor name contains 'HTML' and 'Canvas')
- function HTMLCanvasElement() {}
- const mockCanvas = Object.create(HTMLCanvasElement.prototype);
- Object.defineProperty(mockCanvas, 'constructor', { value: HTMLCanvasElement });
- testObj.mockCanvas = mockCanvas;
-
- // Mock CSSStyleDeclaration (constructor name contains 'CSS')
- function CSSStyleDeclaration() {}
- const mockStyle = Object.create(CSSStyleDeclaration.prototype);
- Object.defineProperty(mockStyle, 'constructor', { value: CSSStyleDeclaration });
- testObj.mockStyle = mockStyle;
-
- const result = safeStringify(testObj);
- expect(result).to.be.a('string');
- expect(result).to.include('"normalData":"safe-value"');
- expect(result).to.include('"number":42');
- expect(result).to.include('[Browser Object]');
-
- // Should not contain the actual browser object data
- expect(result).to.not.include('HTMLCanvasElement');
- expect(result).to.not.include('CSSStyleDeclaration');
- });
-
- it('should detect objects with browser-like properties using duck typing', function () {
- const testObj = {
- safeData: 'value'
- };
-
- // Add actual browser objects that the current implementation can detect
- if (typeof document !== 'undefined') {
- const div = document.createElement('div');
- testObj.element = div; // HTMLElement should be detected
- }
-
- if (typeof window !== 'undefined') {
- testObj.windowRef = window; // Window should be detected
- }
-
- const result = safeStringify(testObj);
- expect(result).to.be.a('string');
- expect(result).to.include('"safeData":"value"');
-
- // Only expect [Browser Object] if we actually added detectable browser objects
- if (typeof document !== 'undefined' || typeof window !== 'undefined') {
- expect(result).to.include('[Browser Object]');
- }
- });
-
- it('should exclude specified keys when keysToExclude parameter is provided', function () {
- const testObj = {
- bidId: 'test-123',
- cpm: 1.25,
- renderer: {
- url: 'https://example.com/renderer.js',
- handlers: { onLoad: function() {} }
- },
- ad: 'Ad content
',
- meta: {
- advertiserDomains: ['example.com']
- }
- };
-
- const result = safeStringify(testObj, ['renderer']);
- expect(result).to.be.a('string');
- expect(result).to.include('"bidId":"test-123"');
- expect(result).to.include('"cpm":1.25');
- expect(result).to.include('"ad":"Ad content
"');
- expect(result).to.include('[Excluded]'); // renderer should be excluded
- expect(result).to.not.include('https://example.com/renderer.js');
- });
-
- it('should exclude multiple keys when multiple keys are specified', function () {
- const testObj = {
- bidId: 'test-456',
- renderer: { url: 'renderer.js' },
- ad: '',
- privateData: 'sensitive',
- normalData: 'safe'
- };
-
- const result = safeStringify(testObj, ['renderer', 'privateData']);
- expect(result).to.be.a('string');
- expect(result).to.include('"bidId":"test-456"');
- expect(result).to.include('"normalData":"safe"');
- expect(result).to.include('[Excluded]'); // Both excluded keys should show this
- expect(result).to.not.include('renderer.js');
- expect(result).to.not.include('sensitive');
- // ad should still be included since it's not in exclude list
- expect(result).to.include('"ad":""');
- });
-
- it('should exclude keys at any nesting level', function () {
- const testObj = {
- bid: {
- id: 'test-789',
- renderer: {
- url: 'nested-renderer.js',
- config: { timeout: 5000 }
- },
- meta: {
- renderer: 'should also be excluded'
- }
- },
- topLevel: 'value'
- };
-
- const result = safeStringify(testObj, ['renderer']);
- expect(result).to.be.a('string');
- expect(result).to.include('"id":"test-789"');
- expect(result).to.include('"topLevel":"value"');
- expect(result).to.include('[Excluded]'); // Both renderer keys should be excluded
- expect(result).to.not.include('nested-renderer.js');
- expect(result).to.not.include('should also be excluded');
- });
-
- it('should work correctly when keysToExclude is empty array', function () {
- const testObj = {
- bidId: 'test-empty',
- renderer: { url: 'renderer.js' },
- normalData: 'value'
- };
-
- const result = safeStringify(testObj, []);
- expect(result).to.be.a('string');
- expect(result).to.include('"bidId":"test-empty"');
- expect(result).to.include('"normalData":"value"');
- expect(result).to.include('renderer.js'); // Should not be excluded
- expect(result).to.not.include('[Excluded]');
- });
-
- it('should work correctly when keysToExclude parameter is not provided', function () {
- const testObj = {
- bidId: 'test-no-param',
- renderer: { url: 'renderer.js' },
- normalData: 'value'
- };
-
- const result = safeStringify(testObj); // No second parameter
- expect(result).to.be.a('string');
- expect(result).to.include('"bidId":"test-no-param"');
- expect(result).to.include('"normalData":"value"');
- expect(result).to.include('renderer.js'); // Should not be excluded
- expect(result).to.not.include('[Excluded]');
- });
-
- it('should combine key exclusion with browser object detection', function () {
- const testObj = {
- bidId: 'test-combined',
- renderer: {
- url: 'renderer.js',
- windowRef: window,
- handlers: {}
- },
- windowRef: window,
- normalData: 'safe'
- };
-
- const result = safeStringify(testObj, ['renderer']);
- expect(result).to.be.a('string');
- expect(result).to.include('"bidId":"test-combined"');
- expect(result).to.include('"normalData":"safe"');
- expect(result).to.include('[Excluded]'); // renderer key excluded
- expect(result).to.include('[Browser Object]'); // top-level windowRef detected as browser object
- expect(result).to.not.include('renderer.js');
- });
- });
-
- describe('is a functions', function () {
- it('exists and is a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('valid code', function () {
- it('should return the bidder code of contxtful', function () {
- expect(spec.code).to.eql('contxtful');
- });
- });
-
- const bidRequests =
- [
- {
- bidder: 'contxtful',
- bidId: 'bId1',
- custom_param_1: 'value_1',
- transactionId: 'tId1',
- params: {
- bcat: ['cat1', 'cat2'],
- badv: ['adv1', 'adv2'],
- },
- mediaTypes: {
- banner: {
- sizes: [
- [300, 250],
- [300, 600]
- ]
- },
- },
- ortb2Imp: {
- ext: {
- tid: 't-id-test-1',
- gpid: 'gpid-id-unitest-1'
- },
- },
- schain: {
- ver: '1.0',
- complete: 1,
- nodes: [
- {
- asi: 'schain-seller-1.com',
- sid: '00001',
- hp: 1,
- },
- ],
- },
- getFloor: () => ({ currency: 'CAD', floor: 10 }),
- }
- ];
-
- const expectedReceptivityData = {
- rx: RX_FROM_API,
- params: {
- ev: VERSION,
- ci: CUSTOMER,
- },
- };
-
- const bidderRequest = {
- refererInfo: {
- ref: 'https://my-referer-custom.com',
- },
- ortb2: {
- source: {
- tid: 'auction-id',
- },
- property_1: 'string_val_1',
- regs: {
- coppa: 1,
- ext: {
- us_privacy: '12345'
- }
- },
- user: {
- data: [
- {
- name: 'contxtful',
- ext: expectedReceptivityData
- }
- ],
- ext: {
- eids: [
- {
- source: 'id5-sync.com',
- uids: [
- {
- atype: 1,
- id: 'fake-id5id',
- },
- ]
- }
- ]
- }
- }
-
- },
- timeout: 1234,
- uspConsent: '12345'
- };
-
- describe('valid configuration', function () {
- const theories = [
- [
- null,
- 'contxfulBidAdapter: contxtful.version should be a non-empty string',
- 'null object for config',
- ],
- [
- {},
- 'contxfulBidAdapter: contxtful.version should be a non-empty string',
- 'empty object for config',
- ],
- [
- { customer: CUSTOMER },
- 'contxfulBidAdapter: contxtful.version should be a non-empty string',
- 'customer only in config',
- ],
- [
- { version: VERSION },
- 'contxfulBidAdapter: contxtful.customer should be a non-empty string',
- 'version only in config',
- ],
- [
- { customer: CUSTOMER, version: '' },
- 'contxfulBidAdapter: contxtful.version should be a non-empty string',
- 'empty string for version',
- ],
- [
- { customer: '', version: VERSION },
- 'contxfulBidAdapter: contxtful.customer should be a non-empty string',
- 'empty string for customer',
- ],
- [
- { customer: '', version: '' },
- 'contxfulBidAdapter: contxtful.version should be a non-empty string',
- 'empty string for version & customer',
- ],
- ];
-
- theories.forEach(([params, expectedErrorMessage, description]) => {
- it('detects invalid configuration and throws the expected error (' + description + ')', () => {
- config.setConfig({
- contxtful: params
- });
- expect(() => spec.buildRequests(bidRequests, {
- auctionId: 'new-auction-id'
- })).to.throw(
- expectedErrorMessage
- );
- });
- });
-
- it('uses a valid configuration and returns the right url', () => {
- config.setConfig({
- contxtful: { customer: CUSTOMER, version: VERSION }
- });
- const bidRequest = spec.buildRequests(bidRequests);
- expect(bidRequest.url).to.eq('https://' + BIDDER_ENDPOINT + `/${VERSION}/prebid/${CUSTOMER}/bid`)
- });
-
- it('will take specific ortb2 configuration parameters and returns it in ortb2 object', () => {
- config.setConfig({
- contxtful: { customer: CUSTOMER, version: VERSION },
- });
- const bidRequest = spec.buildRequests(bidRequests, bidderRequest);
- expect(bidRequest.data.ortb2.property_1).to.equal('string_val_1');
- });
- });
-
- describe('valid bid request', function () {
- config.setConfig({
- contxtful: { customer: CUSTOMER, version: VERSION },
- });
- const bidRequest = spec.buildRequests(bidRequests, bidderRequest);
-
- it('will return a data property containing properties ortb2, bidRequests, bidderRequest and config', () => {
- expect(bidRequest.data).not.to.be.undefined;
- expect(bidRequest.data.ortb2).not.to.be.undefined;
- expect(bidRequest.data.bidRequests).not.to.be.undefined;
- expect(bidRequest.data.bidderRequest).not.to.be.undefined;
- expect(bidRequest.data.config).not.to.be.undefined;
- });
-
- it('will take custom parameters in the bid request and within the bidRequests array', () => {
- expect(bidRequest.data.bidRequests[0].custom_param_1).to.equal('value_1')
- });
-
- it('will return any supply chain parameters within the bidRequests array', () => {
- expect(bidRequest.data.bidRequests[0].schain.ver).to.equal('1.0');
- });
-
- it('will return floor request within the bidFloor parameter in the bidRequests array', () => {
- expect(bidRequest.data.bidRequests[0].bidFloor.currency).to.equal('CAD');
- expect(bidRequest.data.bidRequests[0].bidFloor.floor).to.equal(10);
- });
-
- it('will return the usp string in the uspConsent parameter within the bidderRequest property', () => {
- expect(bidRequest.data.bidderRequest.uspConsent).to.equal('12345');
- });
-
- it('will contains impressions array on ortb2.imp object for all ad units', () => {
- expect(bidRequest.data.ortb2.imp.length).to.equal(1);
- expect(bidRequest.data.ortb2.imp[0].id).to.equal('bId1');
- });
-
- it('will contains the registration on ortb2.regs object', () => {
- expect(bidRequest.data.ortb2.regs).not.to.be.undefined;
- expect(bidRequest.data.ortb2.regs.coppa).to.equal(1);
- expect(bidRequest.data.ortb2.regs.ext.us_privacy).to.equal('12345')
- })
-
- it('will contains the eids modules within the ortb2.user.ext.eids', () => {
- expect(bidRequest.data.ortb2.user.ext.eids).not.to.be.undefined;
- expect(bidRequest.data.ortb2.user.ext.eids[0].source).to.equal('id5-sync.com');
- expect(bidRequest.data.ortb2.user.ext.eids[0].uids[0].id).to.equal('fake-id5id');
- });
-
- it('will contains the receptivity value within the ortb2.user.data with contxtful name', () => {
- const obtained_receptivity_data = bidRequest.data.ortb2.user.data.filter(function (userData) {
- return userData.name === 'contxtful';
- });
- expect(obtained_receptivity_data.length).to.equal(1);
- expect(obtained_receptivity_data[0].ext).to.deep.equal(expectedReceptivityData);
- });
-
- it('will contains ortb2Imp of the bid request within the ortb2.imp.ext', () => {
- const first_imp = bidRequest.data.ortb2.imp[0];
- expect(first_imp.ext).not.to.be.undefined;
- expect(first_imp.ext.tid).to.equal('t-id-test-1');
- expect(first_imp.ext.gpid).to.equal('gpid-id-unitest-1');
- });
- });
-
- describe('valid bid request with no floor module', () => {
- const noFloorsBidRequests =
- [
- {
- bidder: 'contxtful',
- bidId: 'bId1',
- transactionId: 'tId1',
- mediaTypes: {
- banner: {
- sizes: [
- [300, 250],
- [300, 600]
- ]
- },
- },
- },
- {
- bidder: 'contxtful',
- bidId: 'bId2',
- transactionId: 'tId2',
- mediaTypes: {
- banner: {
- sizes: [
- [300, 250],
- [300, 600]
- ]
- },
- },
- params: {
- bidfloor: 54
- }
- },
- ];
-
- config.setConfig({
- contxtful: { customer: CUSTOMER, version: VERSION },
- });
-
- const bidRequest = spec.buildRequests(noFloorsBidRequests, bidderRequest);
- it('will contains default value of floor if the bid request do not contains floor function', () => {
- expect(bidRequest.data.bidRequests[0].bidFloor.currency).to.equal('USD');
- expect(bidRequest.data.bidRequests[0].bidFloor.floor).to.equal(0);
- });
-
- it('will take the param.bidfloor as floor value if possible', () => {
- expect(bidRequest.data.bidRequests[1].bidFloor.currency).to.equal('USD');
- expect(bidRequest.data.bidRequests[1].bidFloor.floor).to.equal(54);
- });
- });
-
- describe('valid bid response', () => {
- const bidResponse = [
- {
- 'requestId': 'arequestId',
- 'originalCpm': 1.5,
- 'cpm': 1.35,
- 'currency': 'CAD',
- 'width': 300,
- 'height': 600,
- 'creativeId': 'creativeid',
- 'netRevenue': true,
- 'ttl': 300,
- 'ad': '',
- 'mediaType': 'banner',
- 'syncs': [
- {
- 'url': 'mysyncurl.com?qparam1=qparamv1&qparam2=qparamv2'
- }
- ]
- }
- ];
- config.setConfig({
- contxtful: { customer: CUSTOMER, version: VERSION },
- });
-
- const bidRequest = spec.buildRequests(bidRequests, bidderRequest);
-
- it('will interpret response correcly', () => {
- const bids = spec.interpretResponse({ body: bidResponse }, bidRequest);
- expect(bids).not.to.be.undefined;
- expect(bids).to.have.lengthOf(1);
- expect(bids).to.deep.equal(bidResponse);
- });
-
- it('will return empty response if bid response is empty', () => {
- const bids = spec.interpretResponse({ body: [] }, bidRequest);
- expect(bids).to.have.lengthOf(0);
- })
-
- it('will trigger user sync if enable pixel mode', () => {
- const syncOptions = {
- pixelEnabled: true
- };
-
- const userSyncs = spec.getUserSyncs(syncOptions, [{ body: bidResponse }]);
- expect(userSyncs).to.deep.equal([
- {
- 'url': 'mysyncurl.com/image?pbjs=1&coppa=0&qparam1=qparamv1&qparam2=qparamv2',
- 'type': 'image'
- }
- ]);
- });
-
- it('will trigger user sync if enable iframe mode', () => {
- const syncOptions = {
- iframeEnabled: true
- };
-
- const userSyncs = spec.getUserSyncs(syncOptions, [{ body: bidResponse }]);
- expect(userSyncs).to.deep.equal([
- {
- 'url': 'mysyncurl.com/iframe?pbjs=1&coppa=0&qparam1=qparamv1&qparam2=qparamv2',
- 'type': 'iframe'
- }
- ]);
- });
-
- describe('no sync option', () => {
- it('will return image sync if no sync options', () => {
- const userSyncs = spec.getUserSyncs({}, [{ body: bidResponse }]);
- expect(userSyncs).to.deep.equal([
- {
- 'url': 'mysyncurl.com/image?pbjs=1&coppa=0&qparam1=qparamv1&qparam2=qparamv2',
- 'type': 'image'
- }
- ]);
- });
- it('will return empty value if no server response', () => {
- const userSyncs = spec.getUserSyncs({}, []);
- expect(userSyncs).to.have.lengthOf(0);
- const userSyncs2 = spec.getUserSyncs({}, null);
- expect(userSyncs2).to.have.lengthOf(0);
- });
- });
-
- it('will return empty value if no server response', () => {
- const syncOptions = {
- iframeEnabled: true
- };
-
- const userSyncs = spec.getUserSyncs(syncOptions, []);
- expect(userSyncs).to.have.lengthOf(0);
- const userSyncs2 = spec.getUserSyncs(syncOptions, null);
- expect(userSyncs2).to.have.lengthOf(0);
- });
-
- describe('onTimeout callback', () => {
- it('will always call server with sendBeacon available', () => {
- config.setConfig({
- contxtful: { customer: CUSTOMER, version: VERSION },
- });
-
- const beaconStub = sandbox.stub(ajax, 'sendBeacon').returns(true);
- const ajaxStub = sandbox.stub(ajax, 'ajax');
- expect(spec.onTimeout({ 'customData': 'customvalue' })).to.not.throw;
- expect(beaconStub.called).to.be.true;
- expect(ajaxStub.called).to.be.false;
- });
-
- it('will always call server with sendBeacon not available', () => {
- config.setConfig({
- contxtful: { customer: CUSTOMER, version: VERSION },
- });
-
- const ajaxStub = sandbox.stub(ajax, 'ajax');
- const beaconStub = sandbox.stub(ajax, 'sendBeacon').returns(false);
- expect(spec.onTimeout({ 'customData': 'customvalue' })).to.not.throw;
- expect(beaconStub.called).to.be.true;
- expect(beaconStub.returned(false)).to.be.true;
- expect(ajaxStub.calledOnce).to.be.true;
- });
- });
-
- describe('on onBidderError callback', () => {
- it('will always call server', () => {
- config.setConfig({
- contxtful: { customer: CUSTOMER, version: VERSION },
- });
-
- const ajaxStub = sandbox.stub(ajax, 'ajax');
- const beaconStub = sandbox.stub(ajax, 'sendBeacon').returns(false);
- spec.onBidderError({ 'customData': 'customvalue' });
- expect(ajaxStub.calledOnce).to.be.true;
- expect(beaconStub.returned(false)).to.be.true;
- });
- });
-
- describe('on onBidWon callback', () => {
- it('will always call server', () => {
- config.setConfig({
- contxtful: { customer: CUSTOMER, version: VERSION },
- });
-
- const ajaxStub = sandbox.stub(ajax, 'ajax');
- const beaconStub = sandbox.stub(ajax, 'sendBeacon').returns(false);
- spec.onBidWon({ 'customData': 'customvalue' });
- expect(ajaxStub.calledOnce).to.be.true;
- expect(beaconStub.returned(false)).to.be.true;
- });
-
- it('will call the server even if payload contains circular reference', () => {
- config.setConfig({
- contxtful: { customer: CUSTOMER, version: VERSION },
- });
-
- const ajaxStub = sandbox.stub(ajax, 'ajax');
- const beaconStub = sandbox.stub(ajax, 'sendBeacon').returns(false);
- const payload = {
- adata: "hello"
- };
- payload.ref = payload
- spec.onBidWon(payload);
- expect(ajaxStub.calledOnce).to.be.true;
- expect(beaconStub.returned(false)).to.be.true;
- })
- });
-
- describe('on onBidBillable callback', () => {
- it('will always call server when sampling rate is configured to be 1.0', () => {
- config.setConfig({
- contxtful: { customer: CUSTOMER, version: VERSION, sampling: { onBidBillable: 1.0 } },
- });
- const ajaxStub = sandbox.stub(ajax, 'ajax');
- const beaconStub = sandbox.stub(ajax, 'sendBeacon').returns(false);
- spec.onBidBillable({ 'customData': 'customvalue' });
- expect(ajaxStub.calledOnce).to.be.true;
- expect(beaconStub.returned(false)).to.be.true;
- });
- });
-
- describe('on onAdRenderSucceeded callback', () => {
- it('will always call server when sampling rate is configured to be 1.0', () => {
- config.setConfig({
- contxtful: { customer: CUSTOMER, version: VERSION, sampling: { onAdRenderSucceeded: 1.0 } },
- });
- const ajaxStub = sandbox.stub(ajax, 'ajax');
- const beaconStub = sandbox.stub(ajax, 'sendBeacon').returns(false);
- spec.onAdRenderSucceeded({ 'customData': 'customvalue' });
- expect(ajaxStub.calledOnce).to.be.true;
- expect(beaconStub.returned(false)).to.be.true;
- });
- });
- });
-});
diff --git a/test/spec/modules/contxtfulRtdProvider_spec.js b/test/spec/modules/contxtfulRtdProvider_spec.js
deleted file mode 100644
index ea57527f8..000000000
--- a/test/spec/modules/contxtfulRtdProvider_spec.js
+++ /dev/null
@@ -1,1051 +0,0 @@
-import { contxtfulSubmodule, extractParameters } from '../../../modules/contxtfulRtdProvider.js';
-import { expect } from 'chai';
-import { loadExternalScriptStub } from 'test/mocks/adloaderStub.js';
-import { getStorageManager } from '../../../src/storageManager.js';
-import { MODULE_TYPE_UID } from '../../../src/activities/modules.js';
-import * as events from '../../../src/events.js';
-import * as utils from 'src/utils.js';
-import * as gptUtils from '../../../libraries/gptUtils/gptUtils.js'
-import Sinon from 'sinon';
-import { deepClone, getWinDimensions } from '../../../src/utils.js';
-
-const MODULE_NAME = 'contxtful';
-
-const VERSION = 'v1';
-const CUSTOMER = 'CUSTOMER';
-const SM = 'SM';
-const CONTXTFUL_CONNECTOR_ENDPOINT = `https://api.receptivity.io/${VERSION}/prebid/${CUSTOMER}/connector/rxConnector.js`;
-
-const RX_FROM_SESSION_STORAGE = { ReceptivityState: 'Receptive', test_info: 'rx_from_session_storage' };
-const RX_FROM_API = { ReceptivityState: 'Receptive', test_info: 'rx_from_engine' };
-
-const RX_API_MOCK = { receptivity: sinon.stub(), receptivityBatched: sinon.stub() };
-const RX_API_MOCK_WITH_BUNDLE = { receptivity: sinon.stub(), receptivityBatched: sinon.stub(), getOrtb2Fragment: sinon.stub() }
-
-const RX_CONNECTOR_MOCK = {
- fetchConfig: sinon.stub(),
- rxApiBuilder: sinon.stub(),
-};
-
-const TIMEOUT = 10;
-const RX_CONNECTOR_IS_READY_EVENT = new CustomEvent('rxConnectorIsReady', { detail: { [CUSTOMER]: RX_CONNECTOR_MOCK }, bubbles: true });
-
-function buildInitConfig(version, customer) {
- return {
- name: 'contxtful',
- params: {
- version: version,
- customer: customer,
- hostname: 'api.receptivity.io',
- bidders: ['mock-bidder-code'],
- adServerTargeting: true,
- },
- };
-}
-
-function fakeGetElementById(width, height, x, y) {
- const obj = { x, y, width, height };
-
- return {
- ...obj,
- getBoundingClientRect: () => {
- return {
- width: obj.width,
- height: obj.height,
- left: obj.x,
- top: obj.y,
- right: obj.x + obj.width,
- bottom: obj.y + obj.height
- };
- }
- };
-}
-
-describe('contxtfulRtdProvider', function () {
- const sandbox = sinon.createSandbox();
- let loadExternalScriptTag;
- let eventsEmitSpy;
-
- const storage = getStorageManager({ moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME });
-
- beforeEach(() => {
- loadExternalScriptTag = document.createElement('script');
- loadExternalScriptStub.callsFake((_url, _moduleName) => loadExternalScriptTag);
-
- RX_API_MOCK.receptivity.resetHistory();
- RX_API_MOCK.receptivity.callsFake(() => RX_FROM_API);
-
- RX_API_MOCK.receptivityBatched.resetHistory();
- RX_API_MOCK.receptivityBatched.callsFake((bidders) => bidders.reduce((accumulator, bidder) => { accumulator[bidder] = RX_FROM_API; return accumulator; }, {}));
-
- RX_API_MOCK_WITH_BUNDLE.receptivity.resetHistory();
- RX_API_MOCK_WITH_BUNDLE.receptivity.callsFake(() => RX_FROM_API);
-
- RX_API_MOCK_WITH_BUNDLE.receptivityBatched.resetHistory();
- RX_API_MOCK_WITH_BUNDLE.receptivityBatched.callsFake((bidders) => bidders.reduce((accumulator, bidder) => { accumulator[bidder] = RX_FROM_API; return accumulator; }, {}));
-
- RX_API_MOCK_WITH_BUNDLE.getOrtb2Fragment.resetHistory();
- RX_API_MOCK_WITH_BUNDLE.getOrtb2Fragment.callsFake((bidders, reqBidsConfigObj) => {
- const bidderObj = bidders.reduce((accumulator, bidder) => { accumulator[bidder] = { user: { data: [{ name: MODULE_NAME, value: RX_FROM_API }] } }; return accumulator; }, {});
- return { global: { user: { site: { id: 'globalsiteId' } } }, bidder: bidderObj }
- }
- );
-
- RX_CONNECTOR_MOCK.fetchConfig.resetHistory();
- RX_CONNECTOR_MOCK.fetchConfig.callsFake((tagId) => new Promise((resolve, reject) => resolve({ tag_id: tagId })));
-
- RX_CONNECTOR_MOCK.rxApiBuilder.resetHistory();
- RX_CONNECTOR_MOCK.rxApiBuilder.callsFake((_config) => new Promise((resolve, reject) => resolve(RX_API_MOCK)));
-
- eventsEmitSpy = sandbox.spy(events, ['emit']);
-
- sandbox.stub(utils, 'generateUUID').returns(SM);
-
- const tagId = CUSTOMER;
- sessionStorage.clear();
- });
-
- afterEach(function () {
- delete window.Contxtful;
- sandbox.restore();
- });
-
- describe('extractParameters', () => {
- const {
- params: { customer, version },
- } = buildInitConfig(VERSION, CUSTOMER);
- const theories = [
- [
- null,
- 'params.version should be a non-empty string',
- 'null object for config',
- ],
- [
- {},
- 'params.version should be a non-empty string',
- 'empty object for config',
- ],
- [
- { customer },
- 'params.version should be a non-empty string',
- 'customer only in config',
- ],
- [
- { version },
- 'params.customer should be a non-empty string',
- 'version only in config',
- ],
- [
- { customer, version: '' },
- 'params.version should be a non-empty string',
- 'empty string for version',
- ],
- [
- { customer: '', version },
- 'params.customer should be a non-empty string',
- 'empty string for customer',
- ],
- [
- { customer: '', version: '' },
- 'params.version should be a non-empty string',
- 'empty string for version & customer',
- ],
- ];
-
- theories.forEach(([params, expectedErrorMessage, _description]) => {
- const config = { name: 'contxtful', params };
- it('detects invalid configuration and throws the expected error', () => {
- expect(() => extractParameters(config)).to.throw(
- expectedErrorMessage
- );
- });
- });
- });
-
- describe('extractParameters', function () {
- it('detects invalid configuration and returns false', () => {
- expect(contxtfulSubmodule.init({})).to.be.false;
- });
- });
-
- describe('init', function () {
- it('uses a valid configuration and returns true when initializing', () => {
- const config = buildInitConfig(VERSION, CUSTOMER);
- expect(contxtfulSubmodule.init(config)).to.be.true;
- });
-
- it('loads a RX connector script asynchronously', (done) => {
- contxtfulSubmodule.init(buildInitConfig(VERSION, CUSTOMER));
-
- setTimeout(() => {
- expect(loadExternalScriptStub.calledOnce).to.be.true;
- expect(loadExternalScriptStub.args[0][0]).to.equal(
- CONTXTFUL_CONNECTOR_ENDPOINT
- );
-
- done();
- }, TIMEOUT);
- });
- });
-
- describe('init', function () {
- it('returns true when initializing', () => {
- loadExternalScriptStub.callsFake((url, moduleCode, callback, doc, attributes) => {
- return { addEventListener: (type, listener) => { } };
- });
- const config = buildInitConfig(VERSION, CUSTOMER);
- expect(contxtfulSubmodule.init(config)).to.be.true;
- });
- });
-
- describe('init', function () {
- it('uses the RX API to get receptivity', (done) => {
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
- window.dispatchEvent(RX_CONNECTOR_IS_READY_EVENT);
-
- setTimeout(() => {
- contxtfulSubmodule.getTargetingData(['ad-slot'], config);
- expect(RX_API_MOCK.receptivity.callCount, 'receptivity 42').to.be.equal(1);
- expect(RX_API_MOCK.receptivity.firstCall.returnValue, 'receptivity').to.be.equal(RX_FROM_API);
- done();
- }, TIMEOUT);
- });
- });
-
- describe('init', function () {
- it('gets the RX API returned by an external script', (done) => {
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
- window.dispatchEvent(RX_CONNECTOR_IS_READY_EVENT);
-
- setTimeout(() => {
- contxtfulSubmodule.getTargetingData(['ad-slot'], config);
- expect(RX_CONNECTOR_MOCK.fetchConfig.callCount, 'fetchConfig').at.least(1);
- expect(RX_CONNECTOR_MOCK.rxApiBuilder.callCount, 'rxApiBuilder').at.least(1);
- done();
- }, TIMEOUT);
- });
- });
-
- describe('init', function () {
- it('detect that initial receptivity is not dispatched and it does not initialize receptivity value', (done) => {
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
-
- setTimeout(() => {
- const targetingData = contxtfulSubmodule.getTargetingData(['ad-slot'], config);
- expect(targetingData).to.deep.equal({});
- done();
- }, TIMEOUT);
- });
- });
-
- describe('init', function () {
- const theories = [
- [new Event('initialReceptivity'), 'event without details'],
- [new CustomEvent('initialReceptivity', {}), 'custom event without details'],
- [new CustomEvent('initialReceptivity', { detail: {} }), 'custom event with invalid details'],
- [new CustomEvent('initialReceptivity', { detail: { ReceptivityState: '' } }), 'custom event with details without ReceptivityState'],
- ];
-
- theories.forEach(([initialReceptivityEvent, _description]) => {
- it('figures out that initial receptivity is invalid and it does not initialize receptivity value', (done) => {
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
- loadExternalScriptTag.dispatchEvent(initialReceptivityEvent);
-
- setTimeout(() => {
- const targetingData = contxtfulSubmodule.getTargetingData(['ad-slot'], config);
- expect(targetingData).to.deep.equal({});
- done();
- }, TIMEOUT);
- });
- })
- });
-
- describe('getTargetingData', function () {
- const theories = [
- [undefined, {}, 'undefined ad-slots'],
- [[], {}, 'empty ad-slots'],
- [
- ['ad-slot'],
- { 'ad-slot': RX_FROM_API },
- 'single ad-slot',
- ],
- [
- ['ad-slot-1', 'ad-slot-2'],
- {
- 'ad-slot-1': RX_FROM_API,
- 'ad-slot-2': RX_FROM_API,
- },
- 'many ad-slots',
- ],
- ];
-
- theories.forEach(([adUnits, expected, description]) => {
- it('adds receptivity to the ad units using the RX API', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
- window.dispatchEvent(RX_CONNECTOR_IS_READY_EVENT);
-
- setTimeout(() => {
- const targetingData = contxtfulSubmodule.getTargetingData(adUnits, config);
- expect(targetingData, description).to.deep.equal(expected, description);
- done();
- }, TIMEOUT);
- });
- });
- });
-
- describe('getTargetingData', function () {
- const theories = [
- [undefined, {}, 'undefined ad-slots'],
- [[], {}, 'empty ad-slots'],
- [
- ['ad-slot'],
- {},
- 'single ad-slot',
- ],
- [
- ['ad-slot-1', 'ad-slot-2'],
- {
- },
- 'many ad-slots',
- ],
- ];
-
- theories.forEach(([adUnits, expected, description]) => {
- it('honours "adServerTargeting" and the RX API is not called', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- config.params.adServerTargeting = false;
- contxtfulSubmodule.init(config);
- window.dispatchEvent(RX_CONNECTOR_IS_READY_EVENT);
-
- setTimeout(() => {
- const _ = contxtfulSubmodule.getTargetingData(adUnits, config);
- expect(RX_API_MOCK.receptivity.callCount).to.be.equal(0);
- done();
- }, TIMEOUT);
- });
-
- it('honours adServerTargeting and it does not add receptivity to the ad units', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- config.params.adServerTargeting = false;
- contxtfulSubmodule.init(config);
- window.dispatchEvent(RX_CONNECTOR_IS_READY_EVENT);
-
- setTimeout(() => {
- const targetingData = contxtfulSubmodule.getTargetingData(adUnits, config);
- expect(targetingData, description).to.deep.equal(expected);
- done();
- }, TIMEOUT);
- });
- });
- });
-
- describe('getTargetingData', function () {
- const theories = [
- [undefined, {}, 'undefined ad-slots'],
- [[], {}, 'empty ad-slots'],
- [
- ['ad-slot'],
- { 'ad-slot': RX_FROM_SESSION_STORAGE },
- 'single ad-slot',
- ],
- [
- ['ad-slot-1', 'ad-slot-2'],
- {
- 'ad-slot-1': RX_FROM_SESSION_STORAGE,
- 'ad-slot-2': RX_FROM_SESSION_STORAGE,
- },
- 'many ad-slots',
- ],
- ];
-
- theories.forEach(([adUnits, expected, _description]) => {
- it('uses non-expired info from session storage and adds receptivity to the ad units using session storage', function (done) {
- // Simulate that there was a write to sessionStorage in the past.
- storage.setDataInSessionStorage(CUSTOMER, JSON.stringify({ exp: new Date().getTime() + 1000, rx: RX_FROM_SESSION_STORAGE }))
-
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
-
- const targetingData = contxtfulSubmodule.getTargetingData(adUnits, config);
- expect(targetingData).to.deep.equal(expected);
-
- done();
- });
- });
- });
-
- describe('getTargetingData', function () {
- const theories = [
- [undefined, {}, 'undefined ad-slots'],
- [[], {}, 'empty ad-slots'],
- [
- ['ad-slot'],
- {},
- 'single ad-slot',
- ],
- [
- ['ad-slot-1', 'ad-slot-2'],
- {
- },
- 'many ad-slots',
- ],
- ];
-
- theories.forEach(([adUnits, expected, _description]) => {
- it('ignores expired info from session storage and does not forward the info to ad units', function (done) {
- // Simulate that there was a write to sessionStorage in the past.
- storage.setDataInSessionStorage(CUSTOMER, JSON.stringify({ exp: new Date().getTime() - 100, rx: RX_FROM_SESSION_STORAGE }));
-
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
-
- const targetingData = contxtfulSubmodule.getTargetingData(adUnits, config);
- expect(targetingData).to.deep.equal(expected);
-
- done();
- });
- });
- });
-
- describe('getBidRequestData', function () {
- it('calls once the onDone callback', function (done) {
- contxtfulSubmodule.init(buildInitConfig(VERSION, CUSTOMER));
- window.dispatchEvent(RX_CONNECTOR_IS_READY_EVENT);
-
- const reqBidsConfigObj = {
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
-
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, buildInitConfig(VERSION, CUSTOMER));
- expect(onDoneSpy.calledOnce).to.be.true;
- done();
- }, TIMEOUT);
- });
- });
-
- describe('getBidRequestData', function () {
- it('does not write receptivity to the global OpenRTB 2 fragment', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
- window.dispatchEvent(RX_CONNECTOR_IS_READY_EVENT);
-
- const reqBidsConfigObj = {
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
-
- setTimeout(() => {
- const onDone = () => 42;
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDone, config);
- expect(reqBidsConfigObj.ortb2Fragments.global).to.deep.equal({});
- done();
- }, TIMEOUT);
- });
- });
-
- describe('getBidRequestData', function () {
- it('writes receptivity to the configured bidder OpenRTB 2 fragments', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
- window.dispatchEvent(RX_CONNECTOR_IS_READY_EVENT);
-
- const reqBidsConfigObj = {
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
-
- const expectedData = {
- name: 'contxtful',
- ext: {
- rx: RX_FROM_API,
- params: {
- ev: config.params?.version,
- ci: config.params?.customer,
- },
- },
- };
-
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
-
- const data = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0];
-
- expect(data.name).to.deep.equal(expectedData.name);
- expect(data.ext.rx).to.deep.equal(expectedData.ext.rx);
- expect(data.ext.params).to.deep.equal(expectedData.ext.params);
- done();
- }, TIMEOUT);
- });
- });
-
- describe('getBidRequestData', function () {
- it('uses non-expired info from session storage and adds receptivity to the reqBidsConfigObj', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
-
- // Simulate that there was a write to sessionStorage in the past.
- const bidder = config.params.bidders[0];
-
- storage.setDataInSessionStorage(`${config.params.customer}_${bidder}`, JSON.stringify({ exp: new Date().getTime() + 1000, rx: RX_FROM_SESSION_STORAGE }));
-
- const reqBidsConfigObj = {
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
-
- contxtfulSubmodule.init(config);
-
- // Since the RX_CONNECTOR_IS_READY_EVENT event was not dispatched, the RX engine is not loaded.
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, () => { }, config);
-
- setTimeout(() => {
- const ortb2BidderFragment = reqBidsConfigObj.ortb2Fragments.bidder[bidder];
- const userData = ortb2BidderFragment.user.data;
- const contxtfulData = userData[0];
-
- expect(contxtfulData.name).to.be.equal('contxtful');
- expect(contxtfulData.ext.rx).to.deep.equal(RX_FROM_SESSION_STORAGE);
- expect(contxtfulData.ext.params).to.deep.equal({
- ev: config.params.version,
- ci: config.params.customer,
- });
-
- done();
- }, TIMEOUT);
- });
- });
-
- describe('getBidRequestData', function () {
- it('uses the RX API', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
- window.dispatchEvent(RX_CONNECTOR_IS_READY_EVENT);
-
- const reqBidsConfigObj = {
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
-
- setTimeout(() => {
- expect(RX_CONNECTOR_MOCK.fetchConfig.callCount).at.least(1);
- expect(RX_CONNECTOR_MOCK.rxApiBuilder.callCount).at.least(1);
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
- expect(onDoneSpy.callCount).to.equal(1);
- expect(RX_API_MOCK.receptivityBatched.callCount).to.equal(1);
- done();
- }, TIMEOUT);
- });
- });
-
- describe('getBidRequestData', function () {
- it('adds receptivity to the reqBidsConfigObj', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
- window.dispatchEvent(RX_CONNECTOR_IS_READY_EVENT);
-
- const reqBidsConfigObj = {
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
-
- const expectedData = {
- name: 'contxtful',
- ext: {
- rx: RX_FROM_API,
- sm: SM,
- params: {
- ev: config.params?.version,
- ci: config.params?.customer,
- },
- },
- };
-
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
-
- const data = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0];
-
- expect(data.name).to.deep.equal(expectedData.name);
- expect(data.ext.rx).to.deep.equal(expectedData.ext.rx);
- expect(data.ext.sm).to.deep.equal(expectedData.ext.sm);
- expect(data.ext.params).to.deep.equal(expectedData.ext.params);
- done();
- }, TIMEOUT);
- });
-
- it('does not change the sm', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
- window.dispatchEvent(RX_CONNECTOR_IS_READY_EVENT);
-
- const firstReqBidsConfigObj = {
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
-
- const secondReqBidsConfigObj = deepClone(firstReqBidsConfigObj);
-
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(firstReqBidsConfigObj, onDoneSpy, config);
- contxtfulSubmodule.getBidRequestData(secondReqBidsConfigObj, onDoneSpy, config);
-
- const firstData = firstReqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0];
- const secondData = secondReqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0];
-
- expect(firstData.ext.sm).to.equal(secondData.ext.sm);
-
- done();
- }, TIMEOUT);
- });
-
- describe('before rxApi is loaded', function () {
- const moveEventTheories = [
- [
- new PointerEvent('pointermove', { clientX: 1, clientY: 2 }),
- { x: 1, y: 2 },
- 'pointer move',
- ]
- ];
-
- moveEventTheories.forEach(([event, expected, _description]) => {
- it('adds move event', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
-
- window.dispatchEvent(event);
-
- const reqBidsConfigObj = {
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
-
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
-
- const ext = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0].ext;
-
- const events = JSON.parse(atob(ext.events));
-
- expect(events.ui.position.x).to.be.deep.equal(expected.x);
- expect(events.ui.position.y).to.be.deep.equal(expected.y);
- expect(Sinon.match.number.test(events.ui.position.timestampMs)).to.be.true;
- done();
- }, TIMEOUT);
- });
- });
-
- it('adds screen event', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
-
- // Cannot change the window size from JS
- // So we take the current size as expectation
- const { innerHeight: height, innerWidth: width } = getWinDimensions()
-
- const reqBidsConfigObj = {
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
-
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
-
- const ext = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0].ext;
-
- const events = JSON.parse(atob(ext.events));
-
- expect(events.ui.screen.topLeft).to.be.deep.equal({ x: 0, y: 0 }, 'screen top left');
- expect(events.ui.screen.width).to.be.deep.equal(width, 'screen width');
- expect(events.ui.screen.height).to.be.deep.equal(height, 'screen height');
- expect(Sinon.match.number.test(events.ui.screen.timestampMs), 'screen timestamp').to.be.true;
- done();
- }, TIMEOUT);
- });
- });
- });
-
- describe('when there is no ad units', function () {
- it('adds empty ad unit positions', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
- const reqBidsConfigObj = {
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
-
- const ext = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0].ext;
- const pos = JSON.parse(atob(ext.pos));
-
- expect(Object.keys(pos).length).to.be.equal(0);
- done();
- }, TIMEOUT);
- });
- });
-
- describe('when there are ad units', function () {
- it('return empty objects for ad units that we can\'t get position of', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
- const reqBidsConfigObj = {
- adUnits: [
- { code: 'code1' },
- { code: 'code2' }
- ],
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
-
- const ext = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0].ext;
- const pos = JSON.parse(atob(ext.pos));
-
- expect(Object.keys(pos).length).to.be.equal(0);
- done();
- }, TIMEOUT);
- });
-
- it('returns the IAB position if the ad unit div id cannot be bound but property pos can be found in the ad unit', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
- const reqBidsConfigObj = {
- adUnits: [
- { code: 'code1', mediaTypes: { banner: { pos: 4 } } },
- { code: 'code2', mediaTypes: { banner: { pos: 5 } } },
- { code: 'code3', mediaTypes: { banner: { pos: 0 } } },
- ],
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
-
- const ext = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0].ext;
- const pos = JSON.parse(atob(ext.pos));
-
- expect(Object.keys(pos).length).to.be.equal(3);
- expect(pos['code1'].p).to.be.equal(4);
- expect(pos['code2'].p).to.be.equal(5);
- expect(pos['code3'].p).to.be.equal(0);
- done();
- }, TIMEOUT);
- })
-
- function getFakeRequestBidConfigObj() {
- return {
- adUnits: [
- { code: 'code1', ortb2Imp: { ext: { data: { divId: 'divId1' } } } },
- { code: 'code2', ortb2Imp: { ext: { data: { divId: 'divId2' } } } }
- ],
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
- }
-
- function InitDivStubPositions(config, withIframe, isVisible, forceGetElementById = true) {
- const fakeElem = fakeGetElementById(100, 100, 30, 30);
- if (isVisible) {
- fakeElem.checkVisibility = function () { return true };
- sandbox.stub(window.top, 'getComputedStyle').returns({ display: 'block' });
- } else {
- fakeElem.checkVisibility = function () { return false };
- sandbox.stub(window.top, 'getComputedStyle').returns({ display: 'none' });
- }
-
- if (withIframe) {
- const ws = {
- frameElement: {
- getBoundingClientRect: () => fakeElem.getBoundingClientRect()
- },
- document: {
- getElementById: (id) => fakeElem,
-
- }
- }
- sandbox.stub(utils, 'getWindowSelf').returns(window.top);
- sandbox.stub(utils, 'inIframe').returns(true);
- sandbox.stub(fakeElem, 'checkVisibility').returns(isVisible);
- } else {
- sandbox.stub(utils, 'inIframe').returns(false);
- sandbox.stub(fakeElem, 'checkVisibility').returns(isVisible);
- }
- if (forceGetElementById) {
- sandbox.stub(window.top.document, 'getElementById').returns(fakeElem);
- }
- contxtfulSubmodule.init(config);
- }
-
- describe('when the div id cannot be found, we should try with GPT method', function () {
- it('returns an empty list if gpt not find the div', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- const reqBidsConfigObj = {
- adUnits: [
- { code: 'code1' },
- { code: 'code2' }
- ],
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
- InitDivStubPositions(config, false, true, false);
- const fakeElem = fakeGetElementById(100, 100, 30, 30);
- sandbox.stub(window.top.document, 'getElementById').returns(function (id) {
- if (id === 'code1' || id === 'code2') {
- return undefined;
- } else {
- return fakeElem;
- }
- });
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
-
- const ext = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0].ext;
- const pos = JSON.parse(atob(ext.pos));
-
- expect(Object.keys(pos).length).to.be.equal(0);
- done();
- }, TIMEOUT);
- })
-
- it('returns object visibility and position if gpt not found but the div id is the ad unit code', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- const reqBidsConfigObj = {
- adUnits: [
- { code: 'code1' },
- { code: 'code2' }
- ],
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
- InitDivStubPositions(config, false, true);
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
-
- const ext = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0].ext;
- const pos = JSON.parse(atob(ext.pos));
-
- expect(Object.keys(pos).length).to.be.equal(2);
- expect(pos['code1'].p.x).to.be.equal(30);
- expect(pos['code1'].p.y).to.be.equal(30);
- expect(pos['code1'].v).to.be.equal(true);
- done();
- }, TIMEOUT);
- });
-
- it('returns object visibility and position if gpt finds the div', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- const reqBidsConfigObj = {
- adUnits: [
- { code: 'code1' },
- { code: 'code2' }
- ],
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
- InitDivStubPositions(config, false, true);
- sandbox.stub(gptUtils, 'getGptSlotInfoForAdUnitCode').returns({ divId: 'div1' });
-
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
-
- const ext = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0].ext;
- const pos = JSON.parse(atob(ext.pos));
-
- expect(Object.keys(pos).length).to.be.equal(2);
- expect(pos['code1'].p.x).to.be.equal(30);
- expect(pos['code1'].p.y).to.be.equal(30);
- expect(pos['code1'].v).to.be.equal(true);
- done();
- }, TIMEOUT);
- });
- });
-
- describe('when we get object visibility and position for ad units that we can get div id', function () {
- const config = buildInitConfig(VERSION, CUSTOMER);
-
- describe('when we are not in an iframe', function () {
- it('return object visibility true if element is visible', function (done) {
- const reqBidsConfigObj = getFakeRequestBidConfigObj();
- InitDivStubPositions(config, false, true);
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
-
- const ext = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0].ext;
- const pos = JSON.parse(atob(ext.pos));
-
- expect(Object.keys(pos).length).to.be.equal(2);
- expect(pos['code1'].p.x).to.be.equal(30);
- expect(pos['code1'].p.y).to.be.equal(30);
- expect(pos['code1'].v).to.be.equal(true);
- done();
- }, TIMEOUT);
- });
-
- it('return object visibility false if element is not visible', function (done) {
- const reqBidsConfigObj = getFakeRequestBidConfigObj();
- InitDivStubPositions(config, false, false);
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
-
- const ext = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0].ext;
- const pos = JSON.parse(atob(ext.pos));
-
- expect(Object.keys(pos).length).to.be.equal(2);
- expect(pos['code1'].v).to.be.equal(false);
- expect(pos['code2'].v).to.be.equal(false);
- done();
- }, TIMEOUT);
- });
- });
-
- describe('when we are in an iframe', function () {
- it('return object visibility true if element is visible', function (done) {
- const reqBidsConfigObj = getFakeRequestBidConfigObj();
- InitDivStubPositions(config, true, true)
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
-
- const ext = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0].ext;
- const pos = JSON.parse(atob(ext.pos));
-
- expect(Object.keys(pos).length).to.be.equal(2);
- expect(pos['code1'].p.x).to.be.equal(30);
- expect(pos['code1'].p.y).to.be.equal(30);
- expect(pos['code1'].v).to.be.equal(true);
- done();
- }, TIMEOUT);
- });
-
- it('return object visibility false if element is not visible', function (done) {
- const reqBidsConfigObj = getFakeRequestBidConfigObj();
- InitDivStubPositions(config, true, false);
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
-
- const ext = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0].ext;
- const pos = JSON.parse(atob(ext.pos));
-
- expect(Object.keys(pos).length).to.be.equal(2);
- expect(pos['code1'].v).to.be.equal(false);
- done();
- }, TIMEOUT);
- });
- });
- });
- });
-
- describe('after rxApi is loaded', function () {
- it('should add event', function (done) {
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
- window.dispatchEvent(RX_CONNECTOR_IS_READY_EVENT);
-
- const reqBidsConfigObj = {
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
-
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
-
- const ext = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]].user.data[0].ext;
-
- const events = ext.events;
-
- expect(events).to.be.not.undefined;
- done();
- }, TIMEOUT);
- });
- })
-
- describe('when rxConnector contains getOrtb2Fragment function', () => {
- it('should just take whatever it contains and merge to the fragment', function (done) {
- RX_CONNECTOR_MOCK.rxApiBuilder.resetHistory();
- RX_CONNECTOR_MOCK.rxApiBuilder.callsFake((_config) => new Promise((resolve, reject) => resolve(RX_API_MOCK_WITH_BUNDLE)));
-
- const config = buildInitConfig(VERSION, CUSTOMER);
- contxtfulSubmodule.init(config);
- window.dispatchEvent(RX_CONNECTOR_IS_READY_EVENT);
-
- const reqBidsConfigObj = {
- ortb2Fragments: {
- global: {},
- bidder: {},
- },
- };
-
- setTimeout(() => {
- const onDoneSpy = sinon.spy();
- contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, config);
- const global = reqBidsConfigObj.ortb2Fragments.global;
- const bidder = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]];
-
- const globalExpected = { user: { site: { id: 'globalsiteId' } } };
- const bidderExpected = { user: { data: [{ name: MODULE_NAME, value: RX_FROM_API }] } };
- expect(RX_API_MOCK_WITH_BUNDLE.getOrtb2Fragment.callCount).to.equal(1);
- expect(global).to.deep.equal(globalExpected);
- expect(bidder).to.deep.equal(bidderExpected);
- done();
- }, TIMEOUT);
- })
- })
-});
diff --git a/test/spec/modules/conversantBidAdapter_spec.js b/test/spec/modules/conversantBidAdapter_spec.js
deleted file mode 100644
index ac19bcd10..000000000
--- a/test/spec/modules/conversantBidAdapter_spec.js
+++ /dev/null
@@ -1,749 +0,0 @@
-import {expect} from 'chai';
-import {spec} from 'modules/conversantBidAdapter.js';
-import * as utils from 'src/utils.js';
-import {deepAccess} from 'src/utils';
-// load modules that register ORTB processors
-import 'src/prebid.js'
-import 'modules/currency.js';
-import 'modules/userId/index.js'; // handles eids
-import 'modules/priceFloors.js';
-import 'modules/consentManagementTcf.js';
-import 'modules/consentManagementUsp.js';
-import {hook} from '../../../src/hook.js'
-import {BANNER} from '../../../src/mediaTypes.js';
-
-describe('Conversant adapter tests', function() {
- const siteId = '108060';
- const versionPattern = /^\d+\.\d+\.\d+(.)*$/;
- const bidRequests = [
- // banner with single size
- {
- bidder: 'conversant',
- params: {
- site_id: siteId,
- position: 1,
- tag_id: 'tagid-1',
- bidfloor: 0.5
- },
- mediaTypes: {
- banner: {
- sizes: [[300, 250]],
- }
- },
- placementCode: 'pcode000',
- transactionId: 'tx000',
- bidId: 'bid000',
- bidderRequestId: '117d765b87bed38',
- auctionId: 'req000'
- },
-
- // banner with sizes in mediaTypes.banner.sizes
- {
- bidder: 'conversant',
- params: {
- site_id: siteId
- },
- mediaTypes: {
- banner: {
- sizes: [[728, 90], [468, 60]]
- }
- },
- placementCode: 'pcode001',
- transactionId: 'tx001',
- bidId: 'bid001',
- bidderRequestId: '117d765b87bed38',
- auctionId: 'req000'
- },
- // banner with tag id and position
- {
- bidder: 'conversant',
- params: {
- site_id: siteId,
- position: 2,
- tag_id: ''
- },
- mediaTypes: {
- banner: {
- sizes: [[300, 600], [160, 600]],
- }
- },
- placementCode: 'pcode002',
- transactionId: 'tx002',
- bidId: 'bid002',
- bidderRequestId: '117d765b87bed38',
- auctionId: 'req000'
- },
- // video with single size
- {
- bidder: 'conversant',
- params: {
- site_id: siteId,
- api: [2],
- protocols: [1, 2],
- mimes: ['video/mp4', 'video/x-flv'],
- maxduration: 30
- },
- mediaTypes: {
- video: {
- context: 'instream',
- playerSize: [632, 499],
- pos: 3
- }
- },
- placementCode: 'pcode003',
- transactionId: 'tx003',
- bidId: 'bid003',
- bidderRequestId: '117d765b87bed38',
- auctionId: 'req000'
- },
- // video with playerSize
- {
- bidder: 'conversant',
- params: {
- site_id: siteId,
- maxduration: 30,
- api: [2, 3]
- },
- mediaTypes: {
- video: {
- context: 'instream',
- playerSize: [1024, 768],
- api: [1, 2],
- protocols: [1, 2, 3],
- mimes: ['video/mp4', 'video/x-flv']
- }
- },
- placementCode: 'pcode004',
- transactionId: 'tx004',
- bidId: 'bid004',
- bidderRequestId: '117d765b87bed38',
- auctionId: 'req000'
- },
- // video without sizes
- {
- bidder: 'conversant',
- params: {
- site_id: siteId,
- position: 2,
- },
- mediaTypes: {
- video: {
- context: 'instream',
- mimes: ['video/mp4', 'video/x-flv'],
- pos: 7,
- }
- },
- placementCode: 'pcode005',
- transactionId: 'tx005',
- bidId: 'bid005',
- bidderRequestId: '117d765b87bed38',
- auctionId: 'req000'
- },
- // banner with first party data
- {
- bidder: 'conversant',
- params: {
- site_id: siteId
- },
- mediaTypes: {
- banner: {
- sizes: [[300, 600], [160, 600]],
- }
- },
- ortb2Imp: {
- instl: 1,
- ext: {
- data: {
- pbadslot: 'homepage-top-rect'
- }
- }
- },
- placementCode: 'pcode006',
- transactionId: 'tx006',
- bidId: 'bid006',
- bidderRequestId: '117d765b87bed38',
- auctionId: 'req000'
- }
- ];
-
- const bidResponses = {
- body: {
- id: 'req000',
- seatbid: [{
- bid: [{
- nurl: 'notify000',
- adm: 'markup000',
- crid: '1000',
- impid: 'bid000',
- price: 0.99,
- w: 300,
- h: 250,
- adomain: ['https://example.com'],
- id: 'bid000'
- }, {
- impid: 'bid001',
- price: 0.00000,
- id: 'bid001'
- }, {
- nurl: 'notify002',
- adm: 'markup002',
- crid: '1002',
- impid: 'bid002',
- price: 2.99,
- w: 300,
- h: 600,
- adomain: ['https://example.com'],
- id: 'bid002'
- }, {
- nurl: 'notify003',
- adm: 'markup003',
- crid: '1003',
- impid: 'bid003',
- price: 3.99,
- adomain: ['https://example.com'],
- id: 'bid003'
- }, {
- nurl: 'notify004',
- adm: '',
- crid: '1004',
- impid: 'bid004',
- price: 4.99,
- adomain: ['https://example.com'],
- id: 'bid004'
- }]
- }]
- },
- headers: {}
- };
-
- before(() => {
- // ortbConverter depends on other modules to be setup to work as expected so run hook.ready to register some
- // submodules so functions like setOrtbSourceExtSchain and setOrtbUserExtEids are available
- hook.ready();
- });
-
- it('Verify basic properties', function() {
- expect(spec.code).to.equal('conversant');
- expect(spec.aliases).to.be.an('array').with.lengthOf(2);
- expect(spec.aliases[0]).to.equal('cnvr');
- expect(spec.aliases[1]).to.equal('epsilon');
- expect(spec.supportedMediaTypes).to.be.an('array').with.lengthOf(3);
- expect(spec.supportedMediaTypes[1]).to.equal('video');
- });
-
- it('Verify isBidRequestValid', function() {
- expect(spec.isBidRequestValid({})).to.be.false;
- expect(spec.isBidRequestValid({params: {}})).to.be.false;
- expect(spec.isBidRequestValid({params: {site_id: '123'}})).to.be.true;
- bidRequests.forEach((bid) => {
- expect(spec.isBidRequestValid(bid)).to.be.true;
- });
-
- const simpleVideo = JSON.parse(JSON.stringify(bidRequests[3]));
- simpleVideo.params.site_id = 123;
- expect(spec.isBidRequestValid(simpleVideo)).to.be.false;
- simpleVideo.params.site_id = siteId;
- simpleVideo.params.mimes = [1, 2, 3];
- expect(spec.isBidRequestValid(simpleVideo)).to.be.false;
- simpleVideo.params.mimes = 'bad type';
- expect(spec.isBidRequestValid(simpleVideo)).to.be.false;
- delete simpleVideo.params.mimes;
- expect(spec.isBidRequestValid(simpleVideo)).to.be.true;
- });
-
- describe('Verify buildRequest', function() {
- let page, bidderRequest, request, payload;
- before(() => {
- page = 'http://test.com?a=b&c=123';
- // ortbConverter uses the site/device information from the ortb2 object passed in the bidderRequest object
- bidderRequest = {
- refererInfo: {
- page: page
- },
- ortb2: {
- source: {
- tid: 'tid000'
- },
- site: {
- mobile: 0,
- page: page,
- },
- device: {
- w: screen.width,
- h: screen.height,
- dnt: 0,
- ua: navigator.userAgent
- }
- }
- };
- request = spec.buildRequests(bidRequests, bidderRequest);
- payload = request.data;
- });
-
- it('Verify common elements', function() {
- expect(request.method).to.equal('POST');
- expect(request.url).to.equal('https://web.hb.ad.cpe.dotomi.com/cvx/client/hb/ortb/25');
-
- expect(payload).to.have.property('id');
- expect(payload.source).to.have.property('tid', 'tid000');
- expect(payload).to.have.property('at', 1);
- expect(payload).to.have.property('imp');
- expect(payload.imp).to.be.an('array').with.lengthOf(bidRequests.length);
-
- expect(payload).to.have.property('site');
- expect(payload.site).to.have.property('id', siteId);
- expect(payload.site).to.have.property('mobile').that.is.oneOf([0, 1]);
-
- expect(payload.site).to.have.property('page', page);
-
- expect(payload).to.have.property('device');
- expect(payload.device).to.have.property('w', screen.width);
- expect(payload.device).to.have.property('h', screen.height);
- expect(payload.device).to.have.property('dnt').that.is.oneOf([0, 1]);
- expect(payload.device).to.have.property('ua', navigator.userAgent);
-
- expect(payload).to.not.have.property('user'); // there should be no user by default
- expect(payload).to.not.have.property('tmax'); // there should be no user by default
- });
-
- it('Simple banner', () => {
- expect(payload.imp[0]).to.have.property('id', 'bid000');
- expect(payload.imp[0]).to.have.property('secure', 1);
- expect(payload.imp[0]).to.have.property('bidfloor', 0.5);
- expect(payload.imp[0]).to.have.property('displaymanager', 'Prebid.js');
- expect(payload.imp[0]).to.have.property('displaymanagerver').that.matches(versionPattern);
- expect(payload.imp[0]).to.have.property('tagid', 'tagid-1');
- expect(payload.imp[0]).to.have.property('banner');
- expect(payload.imp[0].banner).to.have.property('pos', 1);
- expect(payload.imp[0].banner).to.have.property('format');
- expect(payload.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}]);
- expect(payload.imp[0]).to.not.have.property('video');
- });
-
- it('Banner multiple sizes', () => {
- expect(payload.imp[1]).to.have.property('id', 'bid001');
- expect(payload.imp[1]).to.have.property('secure', 1);
- expect(payload.imp[1]).to.have.property('bidfloor', 0);
- expect(payload.imp[1]).to.have.property('displaymanager', 'Prebid.js');
- expect(payload.imp[1]).to.have.property('displaymanagerver').that.matches(versionPattern);
- expect(payload.imp[1]).to.not.have.property('tagid');
- expect(payload.imp[1]).to.have.property('banner');
- expect(payload.imp[1].banner).to.not.have.property('pos');
- expect(payload.imp[1].banner).to.have.property('format');
- expect(payload.imp[1].banner.format).to.deep.equal([{w: 728, h: 90}, {w: 468, h: 60}]);
- });
-
- it('Banner with tagid and position', () => {
- expect(payload.imp[2]).to.have.property('id', 'bid002');
- expect(payload.imp[2]).to.have.property('secure', 1);
- expect(payload.imp[2]).to.have.property('bidfloor', 0);
- expect(payload.imp[2]).to.have.property('displaymanager', 'Prebid.js');
- expect(payload.imp[2]).to.have.property('displaymanagerver').that.matches(versionPattern);
- expect(payload.imp[2]).to.have.property('banner');
- expect(payload.imp[2].banner).to.have.property('pos', 2);
- expect(payload.imp[2].banner).to.have.property('format');
- expect(payload.imp[2].banner.format).to.deep.equal([{w: 300, h: 600}, {w: 160, h: 600}]);
- });
-
- if (FEATURES.VIDEO) {
- it('Simple video', () => {
- expect(payload.imp[3]).to.have.property('id', 'bid003');
- expect(payload.imp[3]).to.have.property('secure', 1);
- expect(payload.imp[3]).to.have.property('bidfloor', 0);
- expect(payload.imp[3]).to.have.property('displaymanager', 'Prebid.js');
- expect(payload.imp[3]).to.have.property('displaymanagerver').that.matches(versionPattern);
- expect(payload.imp[3]).to.not.have.property('tagid');
- expect(payload.imp[3]).to.have.property('video');
- expect(payload.imp[3].video).to.have.property('pos', 3);
- expect(payload.imp[3].video).to.have.property('w', 632);
- expect(payload.imp[3].video).to.have.property('h', 499);
- expect(payload.imp[3].video).to.have.property('mimes');
- expect(payload.imp[3].video.mimes).to.deep.equal(['video/mp4', 'video/x-flv']);
- expect(payload.imp[3].video).to.have.property('protocols');
- expect(payload.imp[3].video.protocols).to.deep.equal([1, 2]);
- expect(payload.imp[3].video).to.have.property('api');
- expect(payload.imp[3].video.api).to.deep.equal([2]);
- expect(payload.imp[3].video).to.have.property('maxduration', 30);
- expect(payload.imp[3]).to.not.have.property('banner');
- });
-
- it('Video with playerSize', () => {
- expect(payload.imp[4]).to.have.property('id', 'bid004');
- expect(payload.imp[4]).to.have.property('secure', 1);
- expect(payload.imp[4]).to.have.property('bidfloor', 0);
- expect(payload.imp[4]).to.have.property('displaymanager', 'Prebid.js');
- expect(payload.imp[4]).to.have.property('displaymanagerver').that.matches(versionPattern);
- expect(payload.imp[4]).to.not.have.property('tagid');
- expect(payload.imp[4]).to.have.property('video');
- expect(payload.imp[4].video).to.not.have.property('pos');
- expect(payload.imp[4].video).to.have.property('w', 1024);
- expect(payload.imp[4].video).to.have.property('h', 768);
- expect(payload.imp[4].video).to.have.property('mimes');
- expect(payload.imp[4].video.mimes).to.deep.equal(['video/mp4', 'video/x-flv']);
- expect(payload.imp[4].video).to.have.property('protocols');
- expect(payload.imp[4].video.protocols).to.deep.equal([1, 2, 3]);
- expect(payload.imp[4].video).to.have.property('api');
- expect(payload.imp[4].video.api).to.deep.equal([1, 2, 3]);
- expect(payload.imp[4].video).to.have.property('maxduration', 30);
- });
-
- it('Video without sizes', () => {
- expect(payload.imp[5]).to.have.property('id', 'bid005');
- expect(payload.imp[5]).to.have.property('secure', 1);
- expect(payload.imp[5]).to.have.property('bidfloor', 0);
- expect(payload.imp[5]).to.have.property('displaymanager', 'Prebid.js');
- expect(payload.imp[5]).to.have.property('displaymanagerver').that.matches(versionPattern);
- expect(payload.imp[5]).to.not.have.property('tagid');
- expect(payload.imp[5]).to.have.property('video');
- expect(payload.imp[5].video).to.have.property('pos', 2);
- expect(payload.imp[5].video).to.not.have.property('w');
- expect(payload.imp[5].video).to.not.have.property('h');
- expect(payload.imp[5].video).to.have.property('mimes');
- expect(payload.imp[5].video.mimes).to.deep.equal(['video/mp4', 'video/x-flv']);
- expect(payload.imp[5].video).to.not.have.property('protocols');
- expect(payload.imp[5].video).to.not.have.property('api');
- expect(payload.imp[5].video).to.not.have.property('maxduration');
- expect(payload.imp[5]).to.not.have.property('banner');
- });
- }
-
- it('With FPD', () => {
- expect(payload.imp[6]).to.have.property('id', 'bid006');
- expect(payload.imp[6]).to.have.property('banner');
- expect(payload.imp[6]).to.not.have.property('video');
- expect(payload.imp[6]).to.have.property('instl');
- expect(payload.imp[6]).to.have.property('ext');
- expect(payload.imp[6].ext).to.have.property('data');
- expect(payload.imp[6].ext.data).to.have.property('pbadslot');
- });
- });
-
- it('Verify timeout', () => {
- const bidderRequest = { timeout: 9999 };
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const payload = request.data;
- expect(payload.tmax).equals(bidderRequest.timeout);
- });
-
- it('Verify first party data', () => {
- const bidderRequest = {
- refererInfo: {page: 'http://test.com?a=b&c=123'},
- ortb2: {site: {content: {series: 'MySeries', season: 'MySeason', episode: 3, title: 'MyTitle'}}}
- };
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const payload = request.data;
- expect(payload.site).to.have.property('content');
- expect(payload.site.content).to.have.property('series');
- expect(payload.site.content).to.have.property('season');
- expect(payload.site.content).to.have.property('episode');
- expect(payload.site.content).to.have.property('title');
- });
-
- it('Verify currency', () => {
- const bidderRequest = { timeout: 9999, ortb2: {cur: ['EUR']} };
- const request = spec.buildRequests(bidRequests, bidderRequest);
- const payload = request.data;
- expect(payload.cur).deep.equal(['USD']);
- })
-
- it('Verify supply chain data', () => {
- const bidderRequest = {refererInfo: {page: 'http://test.com?a=b&c=123'}};
- const schain = {complete: 1, ver: '1.0', nodes: [{asi: 'bidderA.com', sid: '00001', hp: 1}]};
-
- // Add schain to bidderRequest
- bidderRequest.ortb2 = {
- source: {
- ext: {schain: schain}
- }
- };
-
- const bidsWithSchain = bidRequests.map((bid) => {
- return Object.assign({
- ortb2: {
- source: {
- ext: {schain: schain}
- }
- }
- }, bid);
- });
- const request = spec.buildRequests(bidsWithSchain, bidderRequest);
- const payload = request.data;
- expect(deepAccess(payload, 'source.ext.schain.nodes')).to.exist;
- expect(payload.source.ext.schain.nodes[0].asi).equals(schain.nodes[0].asi);
- });
-
- it('Verify override url', function() {
- const testUrl = 'https://someurl?name=value';
- const request = spec.buildRequests([{params: {white_label_url: testUrl}}], {});
- expect(request.url).to.equal(testUrl);
- });
-
- describe('Verify interpretResponse', function() {
- let bid, request, response;
-
- before(() => {
- request = spec.buildRequests(bidRequests, {});
- response = spec.interpretResponse(bidResponses, request).bids;
- });
-
- it('Banner', function() {
- expect(response).to.be.an('array').with.lengthOf(4);
- bid = response[0];
- expect(bid).to.have.property('requestId', 'bid000');
- expect(bid).to.have.property('cpm', 0.99);
- expect(bid).to.have.property('creativeId', '1000');
- expect(bid).to.have.property('width', 300);
- expect(bid).to.have.property('height', 250);
- expect(bid.meta.advertiserDomains).to.deep.equal(['https://example.com']);
- expect(bid).to.have.property('ad', 'markup000');
- expect(bid).to.have.property('ttl', 300);
- expect(bid).to.have.property('netRevenue', true);
- });
-
- // There is no bid001 because cpm is $0
-
- it('Banner multiple sizes', function() {
- bid = response[1];
- expect(bid).to.have.property('requestId', 'bid002');
- expect(bid).to.have.property('cpm', 2.99);
- expect(bid).to.have.property('creativeId', '1002');
- expect(bid).to.have.property('width', 300);
- expect(bid).to.have.property('height', 600);
- expect(bid).to.have.property('ad', 'markup002');
- expect(bid).to.have.property('ttl', 300);
- expect(bid).to.have.property('netRevenue', true);
- });
-
- if (FEATURES.VIDEO) {
- it('Video', function () {
- bid = response[2];
- expect(bid).to.have.property('requestId', 'bid003');
- expect(bid).to.have.property('cpm', 3.99);
- expect(bid).to.have.property('creativeId', '1003');
- expect(bid).to.have.property('playerWidth', 632);
- expect(bid).to.have.property('playerHeight', 499);
- expect(bid).to.have.property('vastUrl', 'notify003');
- expect(bid).to.have.property('vastXml', 'markup003');
- expect(bid).to.have.property('mediaType', 'video');
- expect(bid).to.have.property('ttl', 300);
- expect(bid).to.have.property('netRevenue', true);
- });
-
- it('Empty Video', function() {
- bid = response[3];
- expect(bid).to.have.property('vastXml', '');
- });
- }
- });
-
- describe('Verify Native Ads', function () {
- let request, response;
-
- const nativeOrtbRequest = {
- ver: '1.2',
- assets: [
- { id: 1, required: 1, title: { len: 80 } }]
- };
- const nativeBidRequests = [{
- bidder: 'conversant',
- params: {
- site_id: 10806
- },
- adUnitCode: 'adunit',
- mediaTypes: {
- banner: { sizes: [[300, 250]] },
- native: {
- ...nativeOrtbRequest
- },
- },
- nativeOrtbRequest,
- bidId: '0',
- bidderRequestId: 'requestId',
- }];
-
- const nativeMarkup = JSON.stringify({
- native: {
- assets: [
- {id: 1, title: {text: 'TextValue!'}},
- {id: 5, data: {value: 'Epsilon'}},
- ],
- link: { url: 'https://www.epsilon.com/us', }, }
- });
-
- const nativeBidResponse = {
- body: {
- bidId: 'requestId',
- seatbid: [{
- bid: [{
- impid: '0',
- price: 0.25,
- mtype: 4,
- adm: nativeMarkup
- }]
- }],
- cur: 'USD'
- }
- };
-
- if (FEATURES.NATIVE) {
- it('Request', function () {
- request = spec.buildRequests(nativeBidRequests, {});
- const payload = request.data;
- const native = JSON.parse(payload.imp[0].native.request);
- expect(native).to.deep.equal(nativeBidRequests[0].nativeOrtbRequest);
- });
- it('Response', function () {
- response = spec.interpretResponse(nativeBidResponse, request);
- const result = response.bids[0];
- expect(result.ad).to.equal(nativeMarkup);
- expect(result.mediaType).to.equal(BANNER);
- expect(result.cpm).to.equal(nativeBidResponse.body.seatbid[0].bid[0].price);
- });
- }
- })
-
- describe('Extended ID', function() {
- it('Verify unifiedid and liveramp', function() {
- // clone bidRequests
- const requests = utils.deepClone(bidRequests);
-
- const eidArray = [{'source': 'pubcid.org', 'uids': [{'id': '112233', 'atype': 1}]}, {'source': 'liveramp.com', 'uids': [{'id': '334455', 'atype': 3}]}];
-
- // construct http post payload
- const payload = spec.buildRequests(requests, {ortb2: {user: {ext: {eids: eidArray}}}}).data;
- expect(payload).to.have.deep.nested.property('user.ext.eids', [
- {source: 'pubcid.org', uids: [{id: '112233', atype: 1}]},
- {source: 'liveramp.com', uids: [{id: '334455', atype: 3}]}
- ]);
- });
- });
-
- describe('price floor module', function() {
- let bidRequest;
- beforeEach(function() {
- bidRequest = [utils.deepClone(bidRequests[0])];
- delete bidRequest[0].params.bidfloor;
- });
-
- it('obtain floor from getFloor', function() {
- bidRequest[0].getFloor = () => {
- return {
- currency: 'USD',
- floor: 3.21
- };
- };
-
- const payload = spec.buildRequests(bidRequest, {}).data;
- expect(payload.imp[0]).to.have.property('bidfloor', 3.21);
- });
-
- it('obtain floor from params', function() {
- bidRequest[0].getFloor = () => {
- return {
- currency: 'USD',
- floor: 3.21
- };
- };
- bidRequest[0].params.bidfloor = 0.6;
-
- const payload = spec.buildRequests(bidRequest, {}).data;
- expect(payload.imp[0]).to.have.property('bidfloor', 0.6);
- });
-
- it('unsupported currency', function() {
- bidRequest[0].getFloor = () => {
- return {
- currency: 'EUR',
- floor: 1.23
- };
- };
-
- const payload = spec.buildRequests(bidRequest, {}).data;
- expect(payload.imp[0]).to.have.property('bidfloor', 0);
- });
-
- it('bad floor value', function() {
- bidRequest[0].getFloor = () => {
- return {
- currency: 'USD',
- floor: 'test'
- };
- };
-
- const payload = spec.buildRequests(bidRequest, {}).data;
- expect(payload.imp[0]).to.have.property('bidfloor', 0);
- });
-
- it('empty floor object', function() {
- bidRequest[0].getFloor = () => {
- return {};
- };
-
- const payload = spec.buildRequests(bidRequest, {}).data;
- expect(payload.imp[0]).to.have.property('bidfloor', 0);
- });
-
- it('undefined floor result', function() {
- bidRequest[0].getFloor = () => {};
-
- const payload = spec.buildRequests(bidRequest, {}).data;
- expect(payload.imp[0]).to.have.property('bidfloor', 0);
- });
- });
-
- describe('getUserSyncs', function() {
- const syncurl_iframe = 'https://sync.dotomi.com:8080/iframe';
- const syncurl_image = 'https://sync.dotomi.com:8080/pixel';
- const cnvrResponse = {ext: {psyncs: [syncurl_image], fsyncs: [syncurl_iframe]}};
- let sandbox;
- beforeEach(function () {
- sandbox = sinon.createSandbox();
- });
- afterEach(function() {
- sandbox.restore();
- });
-
- it('empty params', function() {
- expect(spec.getUserSyncs({ iframeEnabled: true }, [], undefined, undefined))
- .to.deep.equal([]);
- expect(spec.getUserSyncs({ iframeEnabled: true }, [{body: {ext: {}}}], undefined, undefined))
- .to.deep.equal([]);
- expect(spec.getUserSyncs({ iframeEnabled: true }, [{body: cnvrResponse}], undefined, undefined))
- .to.deep.equal([{ type: 'iframe', url: syncurl_iframe }]);
- expect(spec.getUserSyncs({ pixelEnabled: true }, [{body: cnvrResponse}], undefined, undefined))
- .to.deep.equal([{ type: 'image', url: syncurl_image }]);
- expect(spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: true }, [{body: cnvrResponse}], undefined, undefined))
- .to.deep.equal([{type: 'iframe', url: syncurl_iframe}, {type: 'image', url: syncurl_image}]);
- });
-
- it('URL building', function() {
- expect(spec.getUserSyncs({pixelEnabled: true}, [{body: {ext: {psyncs: [`${syncurl_image}?sid=1234`]}}}], undefined, undefined))
- .to.deep.equal([{type: 'image', url: `${syncurl_image}?sid=1234`}]);
- expect(spec.getUserSyncs({pixelEnabled: true}, [{body: {ext: {psyncs: [`${syncurl_image}?sid=1234`]}}}], undefined, '1NYN'))
- .to.deep.equal([{type: 'image', url: `${syncurl_image}?sid=1234&us_privacy=1NYN`}]);
- });
-
- it('GDPR', function() {
- expect(spec.getUserSyncs({ iframeEnabled: true }, [{body: cnvrResponse}], {gdprApplies: true, consentString: 'consentstring'}, undefined))
- .to.deep.equal([{ type: 'iframe', url: `${syncurl_iframe}?gdpr=1&gdpr_consent=consentstring` }]);
- expect(spec.getUserSyncs({ iframeEnabled: true }, [{body: cnvrResponse}], {gdprApplies: false, consentString: 'consentstring'}, undefined))
- .to.deep.equal([{ type: 'iframe', url: `${syncurl_iframe}?gdpr=0&gdpr_consent=consentstring` }]);
- expect(spec.getUserSyncs({ iframeEnabled: true }, [{body: cnvrResponse}], {gdprApplies: true, consentString: undefined}, undefined))
- .to.deep.equal([{ type: 'iframe', url: `${syncurl_iframe}?gdpr=1&gdpr_consent=` }]);
-
- expect(spec.getUserSyncs({ pixelEnabled: true }, [{body: cnvrResponse}], {gdprApplies: true, consentString: 'consentstring'}, undefined))
- .to.deep.equal([{ type: 'image', url: `${syncurl_image}?gdpr=1&gdpr_consent=consentstring` }]);
- expect(spec.getUserSyncs({ pixelEnabled: true }, [{body: cnvrResponse}], {gdprApplies: false, consentString: 'consentstring'}, undefined))
- .to.deep.equal([{ type: 'image', url: `${syncurl_image}?gdpr=0&gdpr_consent=consentstring` }]);
- expect(spec.getUserSyncs({ pixelEnabled: true }, [{body: cnvrResponse}], {gdprApplies: true, consentString: undefined}, undefined))
- .to.deep.equal([{ type: 'image', url: `${syncurl_image}?gdpr=1&gdpr_consent=` }]);
- });
-
- it('US_Privacy', function() {
- expect(spec.getUserSyncs({ iframeEnabled: true }, [{body: cnvrResponse}], undefined, '1NYN'))
- .to.deep.equal([{ type: 'iframe', url: `${syncurl_iframe}?us_privacy=1NYN` }]);
- expect(spec.getUserSyncs({ pixelEnabled: true }, [{body: cnvrResponse}], undefined, '1NYN'))
- .to.deep.equal([{ type: 'image', url: `${syncurl_image}?us_privacy=1NYN` }]);
- });
- });
-});
diff --git a/test/spec/modules/copper6sspBidAdapter_spec.js b/test/spec/modules/copper6sspBidAdapter_spec.js
deleted file mode 100644
index 3c32750cb..000000000
--- a/test/spec/modules/copper6sspBidAdapter_spec.js
+++ /dev/null
@@ -1,519 +0,0 @@
-import { expect } from 'chai';
-import { spec } from '../../../modules/copper6sspBidAdapter.js';
-import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js';
-import { getUniqueIdentifierStr } from '../../../src/utils.js';
-
-const bidder = 'copper6ssp';
-
-describe('Copper6SSPBidAdapter', function () {
- const userIdAsEids = [{
- source: 'test.org',
- uids: [{
- id: '01**********',
- atype: 1,
- ext: {
- third: '01***********'
- }
- }]
- }];
- const bids = [
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
- placementId: 'testBanner'
- },
- userIdAsEids
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [VIDEO]: {
- playerSize: [[300, 300]],
- minduration: 5,
- maxduration: 60
- }
- },
- params: {
- placementId: 'testVideo'
- },
- userIdAsEids
- },
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [NATIVE]: {
- native: {
- title: {
- required: true
- },
- body: {
- required: true
- },
- icon: {
- required: true,
- size: [64, 64]
- }
- }
- }
- },
- params: {
- placementId: 'testNative'
- },
- userIdAsEids
- }
- ];
-
- const invalidBid = {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
-
- }
- }
-
- const bidderRequest = {
- uspConsent: '1---',
- gdprConsent: {
- consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw',
- vendorData: {}
- },
- refererInfo: {
- referer: 'https://test.com',
- page: 'https://test.com'
- },
- ortb2: {
- device: {
- w: 1512,
- h: 982,
- language: 'en-UK'
- }
- },
- timeout: 500
- };
-
- describe('isBidRequestValid', function () {
- it('Should return true if there are bidId, params and key parameters present', function () {
- expect(spec.isBidRequestValid(bids[0])).to.be.true;
- });
- it('Should return false if at least one of parameters is not present', function () {
- expect(spec.isBidRequestValid(invalidBid)).to.be.false;
- });
- });
-
- describe('buildRequests', function () {
- let serverRequest = spec.buildRequests(bids, bidderRequest);
-
- it('Creates a ServerRequest object with method, URL and data', function () {
- expect(serverRequest).to.exist;
- expect(serverRequest.method).to.exist;
- expect(serverRequest.url).to.exist;
- expect(serverRequest.data).to.exist;
- });
-
- it('Returns POST method', function () {
- expect(serverRequest.method).to.equal('POST');
- });
-
- it('Returns valid URL', function () {
- expect(serverRequest.url).to.equal('https://endpoint.copper6.com/pbjs');
- });
-
- it('Returns general data valid', function () {
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.all.keys(
- 'deviceWidth',
- 'deviceHeight',
- 'device',
- 'language',
- 'secure',
- 'host',
- 'page',
- 'placements',
- 'coppa',
- 'ccpa',
- 'gdpr',
- 'tmax',
- 'bcat',
- 'badv',
- 'bapp',
- 'battr'
- );
- expect(data.deviceWidth).to.be.a('number');
- expect(data.deviceHeight).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');
- expect(data.page).to.be.a('string');
- expect(data.coppa).to.be.a('number');
- expect(data.gdpr).to.be.a('object');
- expect(data.ccpa).to.be.a('string');
- expect(data.tmax).to.be.a('number');
- expect(data.placements).to.have.lengthOf(3);
- });
-
- it('Returns valid placements', function () {
- const { placements } = serverRequest.data;
- for (let i = 0, len = placements.length; i < len; i++) {
- const placement = placements[i];
- expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']);
- expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]);
- expect(placement.bidId).to.be.a('string');
- expect(placement.schain).to.be.an('object');
- expect(placement.bidfloor).to.exist.and.to.equal(0);
- expect(placement.type).to.exist.and.to.equal('publisher');
- expect(placement.eids).to.exist.and.to.be.deep.equal(userIdAsEids);
-
- if (placement.adFormat === BANNER) {
- expect(placement.sizes).to.be.an('array');
- }
- switch (placement.adFormat) {
- case BANNER:
- expect(placement.sizes).to.be.an('array');
- break;
- case VIDEO:
- expect(placement.playerSize).to.be.an('array');
- expect(placement.minduration).to.be.an('number');
- expect(placement.maxduration).to.be.an('number');
- break;
- case NATIVE:
- expect(placement.native).to.be.an('object');
- break;
- }
- }
- });
-
- it('Returns valid endpoints', function () {
- const bids = [
- {
- bidId: getUniqueIdentifierStr(),
- bidder: bidder,
- mediaTypes: {
- [BANNER]: {
- sizes: [[300, 250]]
- }
- },
- params: {
- endpointId: 'testBanner',
- },
- userIdAsEids
- }
- ];
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
-
- const { placements } = serverRequest.data;
- for (let i = 0, len = placements.length; i < len; i++) {
- const placement = placements[i];
- expect(placement.endpointId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']);
- expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]);
- expect(placement.bidId).to.be.a('string');
- expect(placement.schain).to.be.an('object');
- expect(placement.bidfloor).to.exist.and.to.equal(0);
- expect(placement.type).to.exist.and.to.equal('network');
- expect(placement.eids).to.exist.and.to.be.deep.equal(userIdAsEids);
-
- if (placement.adFormat === BANNER) {
- expect(placement.sizes).to.be.an('array');
- }
- switch (placement.adFormat) {
- case BANNER:
- expect(placement.sizes).to.be.an('array');
- break;
- case VIDEO:
- expect(placement.playerSize).to.be.an('array');
- expect(placement.minduration).to.be.an('number');
- expect(placement.maxduration).to.be.an('number');
- break;
- case NATIVE:
- expect(placement.native).to.be.an('object');
- break;
- }
- }
- });
-
- it('Returns data with gdprConsent and without uspConsent', function () {
- delete bidderRequest.uspConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.gdpr).to.exist;
- expect(data.gdpr).to.be.a('object');
- expect(data.gdpr).to.have.property('consentString');
- expect(data.gdpr).to.not.have.property('vendorData');
- expect(data.gdpr.consentString).to.equal(bidderRequest.gdprConsent.consentString);
- expect(data.ccpa).to.not.exist;
- delete bidderRequest.gdprConsent;
- });
-
- it('Returns data with uspConsent and without gdprConsent', function () {
- bidderRequest.uspConsent = '1---';
- delete bidderRequest.gdprConsent;
- serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data.ccpa).to.exist;
- expect(data.ccpa).to.be.a('string');
- expect(data.ccpa).to.equal(bidderRequest.uspConsent);
- expect(data.gdpr).to.not.exist;
- });
- });
-
- describe('gpp consent', function () {
- it('bidderRequest.gppConsent', () => {
- bidderRequest.gppConsent = {
- gppString: 'abc123',
- applicableSections: [8]
- };
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
-
- delete bidderRequest.gppConsent;
- })
-
- it('bidderRequest.ortb2.regs.gpp', () => {
- bidderRequest.ortb2 = bidderRequest.ortb2 || {};
- bidderRequest.ortb2.regs = bidderRequest.ortb2.regs || {};
- bidderRequest.ortb2.regs.gpp = 'abc123';
- bidderRequest.ortb2.regs.gpp_sid = [8];
-
- const serverRequest = spec.buildRequests(bids, bidderRequest);
- const data = serverRequest.data;
- expect(data).to.be.an('object');
- expect(data).to.have.property('gpp');
- expect(data).to.have.property('gpp_sid');
-
- expect(bidderRequest).to.have.property('ortb2');
- })
- });
-
- describe('interpretResponse', function () {
- it('Should interpret banner response', function () {
- const banner = {
- body: [{
- mediaType: 'banner',
- width: 300,
- height: 250,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const bannerResponses = spec.interpretResponse(banner);
- expect(bannerResponses).to.be.an('array').that.is.not.empty;
- const dataItem = bannerResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal(banner.body[0].requestId);
- expect(dataItem.cpm).to.equal(banner.body[0].cpm);
- expect(dataItem.width).to.equal(banner.body[0].width);
- expect(dataItem.height).to.equal(banner.body[0].height);
- expect(dataItem.ad).to.equal(banner.body[0].ad);
- expect(dataItem.ttl).to.equal(banner.body[0].ttl);
- expect(dataItem.creativeId).to.equal(banner.body[0].creativeId);
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal(banner.body[0].currency);
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should interpret video response', function () {
- const video = {
- body: [{
- vastUrl: 'test.com',
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const videoResponses = spec.interpretResponse(video);
- expect(videoResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = videoResponses[0];
- expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId',
- 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.5);
- expect(dataItem.vastUrl).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should interpret native response', function () {
- const native = {
- body: [{
- mediaType: 'native',
- native: {
- clickUrl: 'test.com',
- title: 'Test',
- image: 'test.com',
- impressionTrackers: ['test.com'],
- },
- ttl: 120,
- cpm: 0.4,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- meta: {
- advertiserDomains: ['google.com'],
- advertiserId: 1234
- }
- }]
- };
- const nativeResponses = spec.interpretResponse(native);
- expect(nativeResponses).to.be.an('array').that.is.not.empty;
-
- const dataItem = nativeResponses[0];
- expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta');
- expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image')
- expect(dataItem.requestId).to.equal('23fhj33i987f');
- expect(dataItem.cpm).to.equal(0.4);
- expect(dataItem.native.clickUrl).to.equal('test.com');
- expect(dataItem.native.title).to.equal('Test');
- expect(dataItem.native.image).to.equal('test.com');
- expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty;
- expect(dataItem.native.impressionTrackers[0]).to.equal('test.com');
- expect(dataItem.ttl).to.equal(120);
- expect(dataItem.creativeId).to.equal('2');
- expect(dataItem.netRevenue).to.be.true;
- expect(dataItem.currency).to.equal('USD');
- expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
- });
- it('Should return an empty array if invalid banner response is passed', function () {
- const invBanner = {
- body: [{
- width: 300,
- cpm: 0.4,
- ad: 'Test',
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
-
- const serverResponses = spec.interpretResponse(invBanner);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid video response is passed', function () {
- const invVideo = {
- body: [{
- mediaType: 'video',
- cpm: 0.5,
- requestId: '23fhj33i987f',
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invVideo);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid native response is passed', function () {
- const invNative = {
- body: [{
- mediaType: 'native',
- clickUrl: 'test.com',
- title: 'Test',
- impressionTrackers: ['test.com'],
- ttl: 120,
- requestId: '23fhj33i987f',
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- }]
- };
- const serverResponses = spec.interpretResponse(invNative);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- it('Should return an empty array if invalid response is passed', function () {
- const invalid = {
- body: [{
- ttl: 120,
- creativeId: '2',
- netRevenue: true,
- currency: 'USD',
- dealId: '1'
- }]
- };
- const serverResponses = spec.interpretResponse(invalid);
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- });
-
- describe('getUserSyncs', function() {
- it('Should return array of objects with proper sync config , include GDPR', function() {
- const syncData = spec.getUserSyncs({}, {}, {
- consentString: 'ALL',
- gdprApplies: true,
- }, {});
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://сsync.copper6.com/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0')
- });
- it('Should return array of objects with proper sync config , include CCPA', function() {
- const syncData = spec.getUserSyncs({}, {}, {}, {
- consentString: '1---'
- });
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://сsync.copper6.com/image?pbjs=1&ccpa_consent=1---&coppa=0')
- });
- it('Should return array of objects with proper sync config , include GPP', function() {
- const syncData = spec.getUserSyncs({}, {}, {}, {}, {
- gppString: 'abc123',
- applicableSections: [8]
- });
- expect(syncData).to.be.an('array').which.is.not.empty;
- expect(syncData[0]).to.be.an('object')
- expect(syncData[0].type).to.be.a('string')
- expect(syncData[0].type).to.equal('image')
- expect(syncData[0].url).to.be.a('string')
- expect(syncData[0].url).to.equal('https://сsync.copper6.com/image?pbjs=1&gpp=abc123&gpp_sid=8&coppa=0')
- });
- });
-});
diff --git a/test/spec/modules/cpmstarBidAdapter_spec.js b/test/spec/modules/cpmstarBidAdapter_spec.js
deleted file mode 100755
index c1c773d50..000000000
--- a/test/spec/modules/cpmstarBidAdapter_spec.js
+++ /dev/null
@@ -1,237 +0,0 @@
-import { expect } from 'chai';
-import { spec } from 'modules/cpmstarBidAdapter.js';
-import { deepClone } from 'src/utils.js';
-import { config } from 'src/config.js';
-
-const valid_bid_requests = [{
- 'bidder': 'cpmstar',
- 'params': {
- 'placementId': '57'
- },
- 'sizes': [[300, 250]],
- 'bidId': 'bidId'
-}];
-
-const bidderRequest = {
- refererInfo: {
- referer: 'referer',
- reachedTop: false,
- }
-};
-
-const serverResponse = {
- body: [{
- creatives: [{
- cpm: 1,
- width: 0,
- height: 0,
- currency: 'USD',
- netRevenue: true,
- ttl: 1,
- creativeid: '1234',
- requestid: '11123',
- code: 'no idea',
- media: 'banner',
- }
- ],
- syncs: [{ type: 'image', url: 'https://server.cpmstar.com/pixel.aspx' }]
- }]
-};
-
-describe('Cpmstar Bid Adapter', function () {
- describe('isBidRequestValid', function () {
- it('should return true since the bid is valid',
- function () {
- var bid = { params: { placementId: 123456 } };
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- })
-
- it('should return false since the bid is invalid', function () {
- var bid = { params: { placementId: '' } };
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- })
-
- it('should return a valid player size', function () {
- var bid = {
- mediaTypes: {
- video: {
- playerSize: [[960, 540]]
- }
- }
- }
- expect(spec.getPlayerSize(bid)[0]).to.equal(960);
- expect(spec.getPlayerSize(bid)[1]).to.equal(540);
- })
-
- it('should return a default player size', function () {
- var bid = {
- mediaTypes: {
- video: {
- playerSize: null
- }
- }
- }
- expect(spec.getPlayerSize(bid)[0]).to.equal(640);
- expect(spec.getPlayerSize(bid)[1]).to.equal(440);
- })
- });
-
- describe('buildRequests', function () {
- it('should produce a valid production request', function () {
- var requests = spec.buildRequests(valid_bid_requests, bidderRequest);
- expect(requests[0]).to.have.property('method');
- expect(requests[0]).to.have.property('url');
- expect(requests[0]).to.have.property('bidRequest');
- expect(requests[0].url).to.include('https://server.cpmstar.com/view.aspx');
- });
- it('should produce a valid staging request', function () {
- var stgReq = deepClone(valid_bid_requests);
- stgReq[0].params.endpoint = 'staging';
- var requests = spec.buildRequests(stgReq, bidderRequest);
- expect(requests[0]).to.have.property('method');
- expect(requests[0]).to.have.property('url');
- expect(requests[0]).to.have.property('bidRequest');
- expect(requests[0].url).to.include('https://staging.server.cpmstar.com/view.aspx');
- });
- it('should produce a valid dev request', function () {
- var devReq = deepClone(valid_bid_requests);
- devReq[0].params.endpoint = 'dev';
- var requests = spec.buildRequests(devReq, bidderRequest);
- expect(requests[0]).to.have.property('method');
- expect(requests[0]).to.have.property('url');
- expect(requests[0]).to.have.property('bidRequest');
- expect(requests[0].url).to.include('https://dev.server.cpmstar.com/view.aspx');
- });
- it('should produce a request with support for GDPR', function () {
- var gdpr_bidderRequest = deepClone(bidderRequest);
- gdpr_bidderRequest.gdprConsent = {
- consentString: 'consentString',
- gdprApplies: true
- };
- var requests = spec.buildRequests(valid_bid_requests, gdpr_bidderRequest);
- expect(requests[0]).to.have.property('url');
- expect(requests[0].url).to.include('gdpr_consent=consentString');
- expect(requests[0].url).to.include('gdpr=1');
- });
- it('should produce a request with support for USP', function () {
- var usp_bidderRequest = deepClone(bidderRequest);
- usp_bidderRequest.uspConsent = '1YYY';
- var requests = spec.buildRequests(valid_bid_requests, usp_bidderRequest);
- expect(requests[0]).to.have.property('url');
- expect(requests[0].url).to.include('us_privacy=1YYY');
- });
- it('should produce a request with support for COPPA', function () {
- sinon.stub(config, 'getConfig').withArgs('coppa').returns(true);
- var requests = spec.buildRequests(valid_bid_requests, bidderRequest);
- config.getConfig.restore();
- expect(requests[0]).to.have.property('url');
- expect(requests[0].url).to.include('tfcd=1');
- });
- });
-
- it('should produce a request with support for OpenRTB SupplyChain', function () {
- var reqs = deepClone(valid_bid_requests);
- reqs[0].ortb2 = {
- source: {
- ext: {
- schain: {
- 'ver': '1.0',
- 'complete': 1,
- 'nodes': [
- {
- 'asi': 'exchange1.com',
- 'sid': '1234',
- 'hp': 1
- },
- {
- 'asi': 'exchange2.com',
- 'sid': 'abcd',
- 'hp': 1
- }
- ]
- }
- }
- }
- };
- var requests = spec.buildRequests(reqs, bidderRequest);
- expect(requests[0]).to.have.property('url');
- expect(requests[0].url).to.include('&schain=1.0%2C1%21exchange1.com%2C1234%2C1%2C%2C%2C%21exchange2.com%2Cabcd%2C1%2C%2C%2C');
- });
-
- describe('interpretResponse', function () {
- const request = {
- bidRequest: {
- mediaType: 'BANNER'
- }
- };
-
- it('should return a valid bidresponse array', function () {
- var r = spec.interpretResponse(serverResponse, request)
- var c = serverResponse.body[0].creatives[0];
- expect(r[0].length).to.not.equal(0);
- expect(r[0].requestId).equal(c.requestid);
- expect(r[0].creativeId).equal(c.creativeid);
- expect(r[0].cpm).equal(c.cpm);
- expect(r[0].width).equal(c.width);
- expect(r[0].height).equal(c.height);
- expect(r[0].currency).equal(c.currency);
- expect(r[0].netRevenue).equal(c.netRevenue);
- expect(r[0].ttl).equal(c.ttl);
- expect(r[0].ad).equal(c.code);
- });
-
- it('should return a valid bidresponse array from a non-array-body', function () {
- var r = spec.interpretResponse({ body: serverResponse.body[0] }, request)
- var c = serverResponse.body[0].creatives[0];
- expect(r[0].length).to.not.equal(0);
- expect(r[0].requestId).equal(c.requestid);
- expect(r[0].creativeId).equal(c.creativeid);
- expect(r[0].cpm).equal(c.cpm);
- expect(r[0].width).equal(c.width);
- expect(r[0].height).equal(c.height);
- expect(r[0].currency).equal(c.currency);
- expect(r[0].netRevenue).equal(c.netRevenue);
- expect(r[0].ttl).equal(c.ttl);
- expect(r[0].ad).equal(c.code);
- });
-
- it('should return undefined due to an invalid cpm value', function () {
- var badServer = deepClone(serverResponse);
- badServer.body[0].creatives[0].cpm = 0;
- var c = spec.interpretResponse(badServer, request);
- expect(c).to.be.undefined;
- });
-
- it('should return undefined due to a bad response', function () {
- var badServer = deepClone(serverResponse);
- badServer.body[0].creatives[0].code = null;
- var c = spec.interpretResponse(badServer, request);
- expect(c).to.be.undefined;
- });
-
- it('should return a valid response with a dealId', function () {
- var dealServer = deepClone(serverResponse);
- dealServer.body[0].creatives[0].dealId = 'deal';
- expect(spec.interpretResponse(dealServer, request)[0].dealId).to.equal('deal');
- });
- });
-
- describe('getUserSyncs', function () {
- var sres = [deepClone(serverResponse)];
-
- it('should return a valid pixel sync', function () {
- var syncs = spec.getUserSyncs({ pixelEnabled: true }, sres);
- expect(syncs.length).equal(1);
- expect(syncs[0].type).equal('image');
- expect(syncs[0].url).equal('https://server.cpmstar.com/pixel.aspx');
- });
-
- it('should return a valid iframe sync', function () {
- sres[0].body[0].syncs[0].type = 'iframe';
- var syncs = spec.getUserSyncs({ iframeEnabled: true }, sres);
- expect(syncs.length).equal(1);
- expect(syncs[0].type).equal('iframe');
- expect(syncs[0].url).equal('https://server.cpmstar.com/pixel.aspx');
- });
- });
-});
diff --git a/test/spec/modules/craftBidAdapter_spec.js b/test/spec/modules/craftBidAdapter_spec.js
deleted file mode 100644
index 92aa10309..000000000
--- a/test/spec/modules/craftBidAdapter_spec.js
+++ /dev/null
@@ -1,169 +0,0 @@
-import {expect} from 'chai';
-import {spec} from 'modules/craftBidAdapter.js';
-import {newBidder} from 'src/adapters/bidderFactory.js';
-import {config} from 'src/config.js';
-import {getGlobal} from '../../../src/prebidGlobal.js';
-
-describe('craftAdapter', function () {
- const adapter = newBidder(spec);
-
- describe('inherited functions', function () {
- it('exists and is a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('isBidRequestValid', function () {
- before(function() {
- getGlobal().bidderSettings = {
- craft: {
- storageAllowed: true
- }
- };
- this.windowContext = window.context;
- window.context = null;
- });
-
- after(function() {
- getGlobal().bidderSettings = {};
- window.context = this.windowContext;
- });
- const bid = {
- bidder: 'craft',
- params: {
- sitekey: 'craft-prebid-example',
- placementId: '1234abcd'
- },
- };
-
- it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should return false when params.sitekey not found', function () {
- const invalidBid = Object.assign({}, bid);
- delete invalidBid.params;
- invalidBid.params = {
- placementId: '1234abcd'
- };
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
-
- it('should return false when params.placementId not found', function () {
- const invalidBid = Object.assign({}, bid);
- delete invalidBid.params;
- invalidBid.params = {
- sitekey: 'craft-prebid-example'
- };
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
-
- it('should return false when AMP cotext found', function () {
- window.context = {
- pageViewId: 'xxx'
- };
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
- });
-
- describe('buildRequests', function () {
- before(function () {
- getGlobal().bidderSettings = {
- craft: {
- storageAllowed: true
- }
- };
- });
- after(function () {
- getGlobal().bidderSettings = {};
- });
- const bidRequests = [{
- bidder: 'craft',
- params: {
- 'sitekey': 'craft-prebid-example',
- 'placementId': '1234abcd'
- },
- adUnitCode: '/21998384947/prebid-example',
- sizes: [[300, 250]],
- bidId: '0396fae4eb5f47',
- bidderRequestId: '4a859978b5d4bd',
- auctionId: '8720f980-4639-4150-923a-e96da2f1de36',
- transactionId: 'e0c52da2-c008-491c-a910-c6765d948700',
- }];
- const bidderRequest = {
- refererInfo: {
- topmostLocation: 'https://www.gacraft.jp/publish/craft-prebid-example.html'
- }
- };
- it('sends bid request to ENDPOINT via POST', function () {
- const request = spec.buildRequests(bidRequests, bidderRequest);
- expect(request.method).to.equal('POST');
- expect(request.url).to.equal('https://gacraft.jp/prebid-v3/craft-prebid-example');
- const data = JSON.parse(request.data);
- expect(data.tags).to.deep.equals([{
- sitekey: 'craft-prebid-example',
- placementId: '1234abcd',
- uid: null,
- sizes: [[300, 250]],
- primary_size: [300, 250],
- uuid: '0396fae4eb5f47'
- }]);
- expect(data.referrer_detection).to.deep.equals({
- rd_ref: 'https://www.gacraft.jp/publish/craft-prebid-example.html'
- });
- });
- });
-
- describe('interpretResponse', function() {
- const serverResponse = {
- body: {
- tags: [{
- uuid: '0396fae4eb5f47',
- bid_key: '72038482-c4c3-4055-9e7e-0579585bb421',
- won_url: 'https://www.gacraft.jp/publish/won',
- ads: [{
- content_source: 'rtb',
- ad_type: 'banner',
- creative_id: 9999,
- cpm: 10.01,
- deal_id: '8DEF60EFDFB5',
- rtb: {
- banner: {
- content: '
',
- width: 300,
- height: 250
- },
- }
- }]
- }],
- }
- };
- const bidderRequest = {
- bids: [{
- bidId: '0396fae4eb5f47',
- adUnitCode: 'craft-prebid-example'
- }]
- };
- it('should get correct bid response', function() {
- const bids = spec.interpretResponse(serverResponse, {bidderRequest: bidderRequest});
- expect(bids).to.have.lengthOf(1);
- expect(bids[0]).to.deep.equals({
- _adUnitCode: 'craft-prebid-example',
- _bidKey: '72038482-c4c3-4055-9e7e-0579585bb421',
- _prebidWon: 'https://www.gacraft.jp/publish/won',
- ad: '
',
- cpm: 10.01,
- creativeId: 9999,
- currency: 'JPY',
- dealId: '8DEF60EFDFB5',
- height: 250,
- mediaType: 'banner',
- meta: null,
- netRevenue: true,
- requestId: '0396fae4eb5f47',
- ttl: 360,
- width: 300,
- });
- });
- });
-});
diff --git a/test/spec/modules/criteoBidAdapter_spec.js b/test/spec/modules/criteoBidAdapter_spec.js
deleted file mode 100644
index f6f6d31fe..000000000
--- a/test/spec/modules/criteoBidAdapter_spec.js
+++ /dev/null
@@ -1,2849 +0,0 @@
-import {expect} from 'chai';
-import {spec, storage} from 'modules/criteoBidAdapter.js';
-import * as utils from 'src/utils.js';
-import * as refererDetection from 'src/refererDetection.js';
-import * as ajax from 'src/ajax.js';
-import {config} from '../../../src/config.js';
-import {BANNER, NATIVE, VIDEO} from '../../../src/mediaTypes.js';
-import {addFPDToBidderRequest} from '../../helpers/fpd.js';
-import 'modules/userId/index.js';
-import 'modules/consentManagementTcf.js';
-import 'modules/consentManagementUsp.js';
-import 'modules/consentManagementGpp.js';
-
-import {hook} from '../../../src/hook.js';
-import {getGlobal} from '../../../src/prebidGlobal.js';
-
-describe('The Criteo bidding adapter', function () {
- let sandbox, ajaxStub, logWarnStub;
-
- beforeEach(function () {
- getGlobal().bidderSettings = {
- criteo: {
- storageAllowed: true
- }
- };
- // Remove FastBid to avoid side effects
- localStorage.removeItem('criteo_fast_bid');
- sandbox = sinon.createSandbox();
- logWarnStub = sandbox.stub(utils, 'logWarn');
- ajaxStub = sandbox.stub(ajax, 'ajax');
- });
-
- afterEach(function () {
- getGlobal().bidderSettings = {};
- global.Criteo = undefined;
- try {
- sandbox?.restore();
- } catch (e) {
- // sinon sandbox restore may fail if a stubbed object went undefined
- // catch and ignore to avoid breaking unrelated tests
- // finding the bad stub is proving to be extremely difficult
- /* eslint-disable no-console */
- console.error('sandbox restore error:', e);
- /* eslint-enable no-console */
- }
- });
-
- describe('getUserSyncs in pixel mode', function () {
- const syncOptions = {
- pixelEnabled: true
- };
-
- it('should not trigger sync if publisher did not enable pixel based syncs', function () {
- const userSyncs = spec.getUserSyncs({
- iframeEnabled: false
- }, undefined, undefined, undefined);
-
- expect(userSyncs).to.eql([]);
- });
-
- it('should not trigger sync if purpose one is not granted', function () {
- const gdprConsent = {
- gdprApplies: true,
- consentString: 'ABC',
- vendorData: {
- purpose: {
- consents: {
- 1: false
- }
- }
- }
- };
- const userSyncs = spec.getUserSyncs(syncOptions, undefined, gdprConsent, undefined);
-
- expect(userSyncs).to.eql([]);
- });
-
- it('should trigger sync with consent data', function () {
- const usPrivacy = 'usp_string';
-
- const gppConsent = {
- gppString: 'gpp_string',
- applicableSections: [ 1, 2 ]
- };
-
- const gdprConsent = {
- gdprApplies: true,
- consentString: 'ABC',
- vendorData: {
- purpose: {
- consents: {
- 1: true
- }
- }
- }
- };
-
- const userSyncs = spec.getUserSyncs(syncOptions, undefined, gdprConsent, usPrivacy, gppConsent);
-
- expect(userSyncs).to.eql([{
- type: 'image',
- url: 'https://ssp-sync.criteo.com/user-sync/redirect?profile=207&gdprapplies=true&gdpr=ABC&ccpa=usp_string&gpp=gpp_string&gpp_sid=1&gpp_sid=2'
- }]);
- });
- });
-
- describe('getUserSyncs in iframe mode', function () {
- const syncOptionsIframeEnabled = {
- iframeEnabled: true
- };
-
- const expectedHash = {
- cw: true,
- lsw: true,
- origin: 'criteoPrebidAdapter',
- requestId: '123456',
- tld: 'www.abc.com',
- topUrl: 'www.abc.com',
- version: '$prebid.version$'.replace(/\./g, '_'),
- };
-
- let sandbox,
- randomStub,
- getConfigStub,
- getRefererInfoStub,
- cookiesAreEnabledStub,
- localStorageIsEnabledStub,
- getCookieStub,
- setCookieStub,
- getDataFromLocalStorageStub,
- setDataInLocalStorageStub,
- removeDataFromLocalStorageStub,
- triggerPixelStub;
-
- beforeEach(function () {
- sandbox = sinon.createSandbox();
- getConfigStub = sandbox.stub(config, 'getConfig');
- getConfigStub.withArgs('criteo.fastBidVersion').returns('none');
-
- randomStub = sandbox.stub(Math, 'random');
- randomStub.returns(123456);
-
- getRefererInfoStub = sandbox.stub(refererDetection, 'getRefererInfo');
- getRefererInfoStub.returns({
- domain: 'www.abc.com'
- });
-
- cookiesAreEnabledStub = sandbox.stub(storage, 'cookiesAreEnabled');
- cookiesAreEnabledStub.returns(true);
- localStorageIsEnabledStub = sandbox.stub(storage, 'localStorageIsEnabled');
- localStorageIsEnabledStub.returns(true);
-
- getCookieStub = sandbox.stub(storage, 'getCookie');
- setCookieStub = sandbox.stub(storage, 'setCookie');
- getDataFromLocalStorageStub = sandbox.stub(storage, 'getDataFromLocalStorage');
- setDataInLocalStorageStub = sandbox.stub(storage, 'setDataInLocalStorage');
- removeDataFromLocalStorageStub = sandbox.stub(storage, 'removeDataFromLocalStorage');
-
- triggerPixelStub = sandbox.stub(utils, 'triggerPixel');
- });
-
- afterEach(function () {
- sandbox?.restore();
- });
-
- it('should not trigger sync if publisher did not enable iframe based syncs', function () {
- const userSyncs = spec.getUserSyncs({
- iframeEnabled: false
- }, undefined, undefined, undefined);
-
- expect(userSyncs).to.eql([]);
- });
-
- it('should not trigger sync if purpose one is not granted', function () {
- const gdprConsent = {
- gdprApplies: true,
- consentString: 'ABC',
- vendorData: {
- purpose: {
- consents: {
- 1: false
- }
- }
- }
- };
- const userSyncs = spec.getUserSyncs(syncOptionsIframeEnabled, undefined, gdprConsent, undefined);
-
- expect(userSyncs).to.eql([]);
- });
-
- it('forwards ids from cookies', function () {
- const cookieData = {
- 'cto_bundle': 'a',
- 'cto_optout': 'b'
- };
-
- const expectedHashWithCookieData = {
- ...expectedHash,
- ...{
- bundle: cookieData['cto_bundle'],
- optoutCookie: cookieData['cto_optout']
- }
- };
-
- getCookieStub.callsFake(cookieName => cookieData[cookieName]);
-
- const userSyncs = spec.getUserSyncs(syncOptionsIframeEnabled, undefined, undefined, undefined);
-
- expect(userSyncs).to.eql([{
- type: 'iframe',
- url: `https://gum.criteo.com/syncframe?origin=criteoPrebidAdapter&topUrl=www.abc.com&gpp=#${JSON.stringify(expectedHashWithCookieData, Object.keys(expectedHashWithCookieData).sort()).replace(/"/g, '%22')}`
- }]);
- });
-
- it('forwards ids from local storage', function () {
- const localStorageData = {
- 'cto_bundle': 'a',
- 'cto_optout': 'b'
- };
-
- const expectedHashWithLocalStorageData = {
- ...expectedHash,
- ...{
- bundle: localStorageData['cto_bundle'],
- optoutCookie: localStorageData['cto_optout']
- }
- };
-
- getDataFromLocalStorageStub.callsFake(localStorageName => localStorageData[localStorageName]);
-
- const userSyncs = spec.getUserSyncs(syncOptionsIframeEnabled, undefined, undefined, undefined);
-
- expect(userSyncs).to.eql([{
- type: 'iframe',
- url: `https://gum.criteo.com/syncframe?origin=criteoPrebidAdapter&topUrl=www.abc.com&gpp=#${JSON.stringify(expectedHashWithLocalStorageData, Object.keys(expectedHashWithLocalStorageData).sort()).replace(/"/g, '%22')}`
- }]);
- });
-
- it('forwards gdpr data', function () {
- const gdprConsent = {
- gdprApplies: true,
- consentString: 'ABC',
- vendorData: {
- purpose: {
- consents: {
- 1: true
- }
- }
- }
- };
- const userSyncs = spec.getUserSyncs(syncOptionsIframeEnabled, undefined, gdprConsent, undefined);
-
- expect(userSyncs).to.eql([{
- type: 'iframe',
- url: `https://gum.criteo.com/syncframe?origin=criteoPrebidAdapter&topUrl=www.abc.com&gdpr=1&gdpr_consent=ABC&gpp=#${JSON.stringify(expectedHash).replace(/"/g, '%22')}`
- }]);
- });
-
- it('forwards usp data', function () {
- const userSyncs = spec.getUserSyncs(syncOptionsIframeEnabled, undefined, undefined, 'ABC');
-
- expect(userSyncs).to.eql([{
- type: 'iframe',
- url: `https://gum.criteo.com/syncframe?origin=criteoPrebidAdapter&topUrl=www.abc.com&us_privacy=ABC&gpp=#${JSON.stringify(expectedHash).replace(/"/g, '%22')}`
- }]);
- });
-
- it('should delete user data when calling onDataDeletionRequest', () => {
- const cookieData = {
- 'cto_bundle': 'a'
- };
- const lsData = {
- 'cto_bundle': 'a'
- }
- getCookieStub.callsFake(cookieName => cookieData[cookieName]);
- setCookieStub.callsFake((cookieName, value, expires) => cookieData[cookieName] = value);
- getDataFromLocalStorageStub.callsFake(name => lsData[name]);
- removeDataFromLocalStorageStub.callsFake(name => lsData[name] = '');
- spec.onDataDeletionRequest([]);
- expect(getCookieStub.calledOnce).to.equal(true);
- expect(setCookieStub.calledOnce).to.equal(true);
- expect(getDataFromLocalStorageStub.calledOnce).to.equal(true);
- expect(removeDataFromLocalStorageStub.calledOnce).to.equal(true);
- expect(cookieData.cto_bundle).to.equal('');
- expect(lsData.cto_bundle).to.equal('');
- expect(ajaxStub.calledOnce).to.equal(true);
- });
-
- it('should not call API when calling onDataDeletionRequest with no id', () => {
- const cookieData = {
- 'cto_bundle': ''
- };
- const lsData = {
- 'cto_bundle': ''
- }
- getCookieStub.callsFake(cookieName => cookieData[cookieName]);
- setCookieStub.callsFake((cookieName, value, expires) => cookieData[cookieName] = value);
- getDataFromLocalStorageStub.callsFake(name => lsData[name]);
- removeDataFromLocalStorageStub.callsFake(name => lsData[name] = '');
- spec.onDataDeletionRequest([]);
- expect(getCookieStub.calledOnce).to.be.true;
- expect(setCookieStub.called).to.be.false;
- expect(getDataFromLocalStorageStub.calledOnce).to.be.true
- expect(removeDataFromLocalStorageStub.called).to.be.false;
- expect(ajaxStub.called).to.be.false;
- });
-
- it('should trigger sync pixel from iframe response', function (done) {
- const userSyncs = spec.getUserSyncs(syncOptionsIframeEnabled, undefined, undefined, undefined);
-
- const event = new MessageEvent('message', {
- data: {
- requestId: '123456',
- callbacks: [
- 'https://example.com/pixel1',
- 'https://example.com/pixel2'
- ]
- },
- origin: 'https://gum.criteo.com'
- });
-
- window.dispatchEvent(event);
- setTimeout(() => {
- expect(triggerPixelStub.calledTwice).to.be.true;
- expect(triggerPixelStub.firstCall.calledWith('https://example.com/pixel1')).to.be.true;
- expect(triggerPixelStub.secondCall.calledWith('https://example.com/pixel2')).to.be.true;
-
- done();
- }, 0);
- });
-
- it('should write cookie only on TLD+1 level', function(done) {
- const cookies = {};
-
- const userSyncs = spec.getUserSyncs(syncOptionsIframeEnabled, undefined, undefined, undefined);
-
- setCookieStub.callsFake((name, value, expires, _, domain) => {
- if (domain !== '.com') {
- cookies[name] = value;
- }
- });
-
- getCookieStub.callsFake((name) => cookies[name]);
-
- const event = new MessageEvent('message', {
- data: {
- requestId: '123456',
- bundle: 'bundle'
- },
- origin: 'https://gum.criteo.com'
- });
-
- window.dispatchEvent(event);
- setTimeout(() => {
- expect(setCookieStub.calledWith('cto_bundle', 'bundle', sinon.match.string, null, '.com')).to.be.true;
- expect(setCookieStub.calledWith('cto_bundle', 'bundle', sinon.match.string, null, '.abc.com')).to.be.true;
- expect(setCookieStub.calledWith('cto_bundle', 'bundle', sinon.match.string, null, '.www.abc.com')).to.be.false;
- expect(cookies).to.deep.equal({ 'cto_bundle': 'bundle' });
-
- done();
- }, 0);
- });
- });
-
- describe('isBidRequestValid', function () {
- it('should return false when given an invalid bid', function () {
- const bid = {
- bidder: 'criteo',
- };
- const isValid = spec.isBidRequestValid(bid);
- expect(isValid).to.equal(false);
- });
-
- it('should return true when given a zoneId bid', function () {
- const bid = {
- bidder: 'criteo',
- params: {
- zoneId: 123,
- },
- };
- const isValid = spec.isBidRequestValid(bid);
- expect(isValid).to.equal(true);
- });
-
- it('should return true when given a networkId bid', function () {
- const bid = {
- bidder: 'criteo',
- params: {
- networkId: 456,
- },
- };
- const isValid = spec.isBidRequestValid(bid);
- expect(isValid).to.equal(true);
- });
-
- it('should return true when given a mixed bid with both a zoneId and a networkId', function () {
- const bid = {
- bidder: 'criteo',
- params: {
- zoneId: 123,
- networkId: 456,
- },
- };
- const isValid = spec.isBidRequestValid(bid);
- expect(isValid).to.equal(true);
- });
-
- it('should return true when given a valid video bid request using mix custom bidder video parameters', function () {
- expect(spec.isBidRequestValid({
- bidder: 'criteo',
- mediaTypes: {
- video: {
- context: 'instream',
- mimes: ['video/mpeg'],
- playerSize: [640, 480],
- protocols: [5, 6],
- maxduration: 30,
- api: [1, 2]
- }
- },
- params: {
- networkId: 456,
- video: {
- skip: 1,
- placement: 1,
- playbackmethod: 1
- }
- },
- })).to.equal(true);
-
- expect(spec.isBidRequestValid({
- bidder: 'criteo',
- mediaTypes: {
- video: {
- context: 'outstream',
- mimes: ['video/mpeg'],
- playerSize: [640, 480],
- protocols: [5, 6],
- maxduration: 30,
- api: [1, 2]
- }
- },
- params: {
- networkId: 456,
- video: {
- skip: 1,
- placement: 2,
- playbackmethod: 1
- }
- },
- })).to.equal(true);
- });
-
- it('should return true when given a valid video bid request using only mediaTypes.video parameters', function () {
- expect(spec.isBidRequestValid({
- bidder: 'criteo',
- mediaTypes: {
- video: {
- context: 'instream',
- mimes: ['video/mpeg'],
- playerSize: [640, 480],
- protocols: [5, 6],
- maxduration: 30,
- api: [1, 2],
- skip: 1,
- placement: 1,
- minduration: 0,
- playbackmethod: 1,
- startdelay: 0,
- plcmt: 1
- }
- },
- params: {
- networkId: 456
- },
- })).to.equal(true);
- });
-
- it('should return false when given an invalid video bid request', function () {
- expect(spec.isBidRequestValid({
- bidder: 'criteo',
- mediaTypes: {
- video: {
- context: 'instream',
- playerSize: [640, 480],
- protocols: [5, 6],
- maxduration: 30,
- api: [1, 2]
- }
- },
- params: {
- networkId: 456,
- video: {
- skip: 1,
- placement: 1,
- playbackmethod: 1
- }
- },
- })).to.equal(false);
-
- expect(spec.isBidRequestValid({
- bidder: 'criteo',
- mediaTypes: {
- video: {
- context: 'instream',
- mimes: ['video/mpeg'],
- protocols: [5, 6],
- maxduration: 30,
- api: [1, 2]
- }
- },
- params: {
- networkId: 456,
- video: {
- skip: 1,
- placement: 1,
- playbackmethod: 1
- }
- },
- })).to.equal(false);
-
- expect(spec.isBidRequestValid({
- bidder: 'criteo',
- mediaTypes: {
- video: {
- context: 'instream',
- mimes: ['video/mpeg'],
- playerSize: [640, 480],
- maxduration: 30,
- api: [1, 2]
- }
- },
- params: {
- networkId: 456,
- video: {
- skip: 1,
- placement: 1,
- playbackmethod: 1
- }
- },
- })).to.equal(false);
-
- expect(spec.isBidRequestValid({
- bidder: 'criteo',
- mediaTypes: {
- video: {
- context: 'instream',
- mimes: ['video/mpeg'],
- playerSize: [640, 480],
- protocols: [5, 6],
- api: [1, 2]
- }
- },
- params: {
- networkId: 456,
- video: {
- skip: 1,
- placement: 1,
- playbackmethod: 1
- }
- },
- })).to.equal(false);
-
- expect(spec.isBidRequestValid({
- bidder: 'criteo',
- mediaTypes: {
- video: {
- context: 'instream',
- mimes: ['video/mpeg'],
- playerSize: [640, 480],
- protocols: [5, 6],
- maxduration: 30
- }
- },
- params: {
- networkId: 456,
- video: {
- skip: 1,
- placement: 1,
- playbackmethod: 1
- }
- },
- })).to.equal(false);
-
- expect(spec.isBidRequestValid({
- bidder: 'criteo',
- mediaTypes: {
- video: {
- context: 'instream',
- mimes: ['video/mpeg'],
- playerSize: [640, 480],
- protocols: [5, 6],
- maxduration: 30,
- api: [1, 2]
- }
- },
- params: {
- networkId: 456,
- video: {
- placement: 1,
- playbackmethod: 1
- }
- },
- })).to.equal(false);
-
- expect(spec.isBidRequestValid({
- bidder: 'criteo',
- mediaTypes: {
- video: {
- context: 'instream',
- mimes: ['video/mpeg'],
- playerSize: [640, 480],
- protocols: [5, 6],
- maxduration: 30,
- api: [1, 2]
- }
- },
- params: {
- networkId: 456,
- video: {
- skip: 1,
- playbackmethod: 1
- }
- },
- })).to.equal(false);
-
- expect(spec.isBidRequestValid({
- bidder: 'criteo',
- mediaTypes: {
- video: {
- context: 'instream',
- mimes: ['video/mpeg'],
- playerSize: [640, 480],
- protocols: [5, 6],
- maxduration: 30,
- api: [1, 2]
- }
- },
- params: {
- networkId: 456,
- video: {
- skip: 1,
- placement: 1
- }
- },
- })).to.equal(false);
- });
- });
-
- describe('buildRequests', function () {
- const refererUrl = 'https://criteo.com?pbt_debug=1&pbt_nolog=1';
- const bidderRequest = {
- refererInfo: {
- page: refererUrl,
- topmostLocation: refererUrl
- },
- timeout: 3000,
- gdprConsent: {
- gdprApplies: true,
- consentString: 'consentDataString',
- vendorData: {
- vendorConsents: {
- '91': 1
- },
- },
- apiVersion: 1,
- },
- };
- const defaultBidRequests = [{
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: { sizes: [[728, 90]] }
- },
- params: {}
- }]
-
- let sandbox, localStorageIsEnabledStub, bidderConfigStub;
-
- before(() => {
- hook.ready();
- });
-
- this.beforeEach(function () {
- sandbox = sinon.createSandbox();
- localStorageIsEnabledStub = sandbox.stub(storage, 'localStorageIsEnabled');
- bidderConfigStub = sandbox.stub(config, "getBidderConfig")
- localStorageIsEnabledStub.returns(true);
- });
-
- afterEach(function () {
- sandbox?.restore();
- config.resetConfig();
- });
-
- it('should properly build a request using random uuid as auction id', async function () {
- // Re‐use the sandbox from beforeEach instead of creating a new one
- const generateUUIDStub = sandbox.stub(utils, 'generateUUID');
- generateUUIDStub.returns('def');
-
- const minimalBidderRequest = {};
- const bidRequests = [{
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: { sizes: [[728, 90]] }
- },
- params: {}
- }];
-
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(minimalBidderRequest));
- const ortbRequest = request.data;
- expect(ortbRequest.id).to.equal('def');
- });
-
- it('should properly transmit source.tid if available', async function () {
- const bidderRequest = {
- ortb2: {
- source: {
- tid: 'abc'
- }
- }
- };
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {}
- },
- ];
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const ortbRequest = request.data;
- expect(ortbRequest.source.tid).to.equal('abc');
- });
-
- it('should properly transmit tmax if available', async function () {
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- transactionId: 'transaction-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {}
- },
- ];
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const ortbRequest = request.data;
- expect(ortbRequest.tmax).to.equal(bidderRequest.timeout);
- });
-
- it('should properly transmit bidId if available', async function () {
- const bidderRequest = {};
- const bidRequests = [
- {
- bidId: 'bidId',
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {}
- },
- ];
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const ortbRequest = request.data;
- expect(ortbRequest.imp[0].id).to.equal('bidId');
- });
-
- it('should properly build a zoneId request', async function () {
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- ortb2Imp: {
- ext: {
- tid: 'transaction-123',
- },
- },
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123,
- publisherSubId: '123',
- integrationMode: 'amp'
- },
- },
- ];
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- expect(request.url).to.match(/^https:\/\/grid-bidder\.criteo\.com\/openrtb_2_5\/pbjs\/auction\/request\?profileId=207&av=\d+&wv=[^&]+&cb=\d+&lsavail=[01]&im=1&debug=[01]&nolog=[01]$/);
- expect(request.method).to.equal('POST');
- const ortbRequest = request.data;
- expect(ortbRequest.site.page).to.equal(refererUrl);
- expect(ortbRequest.imp).to.have.lengthOf(1);
- expect(ortbRequest.imp[0].tagid).to.equal('bid-123');
- expect(ortbRequest.imp[0].banner.format).to.have.lengthOf(1);
- expect(ortbRequest.imp[0].banner.format[0].w).to.equal(728);
- expect(ortbRequest.imp[0].banner.format[0].h).to.equal(90);
- expect(ortbRequest.imp[0].ext.bidder.zoneid).to.equal(123);
- expect(ortbRequest.user.ext.consent).to.equal('consentDataString');
- expect(ortbRequest.regs.ext.gdpr).to.equal(1);
- expect(ortbRequest.regs.ext.gdprversion).to.equal(1);
- });
-
- it('should properly forward eids', async function () {
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {}
- },
- ];
- const br = {
- ...bidderRequest,
- ortb2: {
- user: {
- ext: {
- eids: [
- {
- source: 'criteo.com',
- uids: [{
- id: 'abc',
- atype: 1
- }]
- }
- ]
- }
- }
- }
- }
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(br));
- const ortbRequest = request.data;
- expect(ortbRequest.user.ext.eids).to.deep.equal([
- {
- source: 'criteo.com',
- uids: [{
- id: 'abc',
- atype: 1
- }]
- }
- ]);
- });
-
- if (FEATURES.NATIVE) {
- it('should properly build a native request without assets', async function () {
- const bidRequests = [
- {
- mediaTypes: {
- native: {}
- },
- params: {}
- },
- ];
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const ortbRequest = request.data;
- expect(ortbRequest.imp[0].native.request_native).to.not.be.null;
- expect(ortbRequest.imp[0].native.request_native.assets).to.be.undefined;
- });
- }
-
- if (FEATURES.NATIVE) {
- it('should properly build a native request with assets', async function () {
- const assets = [{
- required: 1,
- id: 1,
- img: {
- type: 3,
- wmin: 100,
- hmin: 100,
- }
- },
- {
- required: 1,
- id: 2,
- title: {
- len: 140,
- }
- },
- {
- required: 1,
- id: 3,
- data: {
- type: 1,
- }
- },
- {
- required: 0,
- id: 4,
- data: {
- type: 2,
- }
- },
- {
- required: 0,
- id: 5,
- img: {
- type: 1,
- wmin: 20,
- hmin: 20,
- }
- }];
- const bidRequests = [
- {
- mediaTypes: {
- native: {}
- },
- nativeOrtbRequest: {
- assets: assets
- },
- params: {}
- },
- ];
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const ortbRequest = request.data;
- expect(ortbRequest.imp[0].native.request_native).to.not.be.null;
- expect(ortbRequest.imp[0].native.request_native.assets).to.deep.equal(assets);
- });
- }
-
- it('should properly build a networkId request', async function () {
- const bidderRequest = {
- refererInfo: {
- page: refererUrl,
- topmostLocation: refererUrl,
- },
- timeout: 3000,
- gdprConsent: {
- gdprApplies: false,
- consentString: undefined,
- vendorData: {
- vendorConsents: {
- '1': 0
- },
- },
- },
- };
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- ortb2Imp: {
- ext: {
- tid: 'transaction-123',
- },
- },
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [728, 90]]
- }
- },
- params: {
- networkId: 456,
- },
- },
- ];
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- expect(request.url).to.match(/^https:\/\/grid-bidder\.criteo\.com\/openrtb_2_5\/pbjs\/auction\/request\?profileId=207&av=\d+&wv=[^&]+&cb=\d+&lsavail=[01]&debug=[01]&nolog=[01]&networkId=456$/);
- expect(request.method).to.equal('POST');
- const ortbRequest = request.data;
- expect(ortbRequest.site.page).to.equal(refererUrl);
- expect(ortbRequest.imp).to.have.lengthOf(1);
- expect(ortbRequest.imp[0].tagid).to.equal('bid-123');
- expect(ortbRequest.imp[0].banner.format).to.have.lengthOf(2);
- expect(ortbRequest.imp[0].banner.format[0].w).to.equal(300);
- expect(ortbRequest.imp[0].banner.format[0].h).to.equal(250);
- expect(ortbRequest.imp[0].banner.format[1].w).to.equal(728);
- expect(ortbRequest.imp[0].banner.format[1].h).to.equal(90);
- expect(ortbRequest.user?.ext?.consent).to.equal(undefined);
- expect(ortbRequest.regs.ext.gdpr).to.equal(0);
- });
-
- it('should properly build a mixed request with both a zoneId and a networkId', async function () {
- const bidderRequest = {
- refererInfo: {
- page: refererUrl,
- topmostLocation: refererUrl,
- },
- timeout: 3000
- };
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- ortb2Imp: {
- ext: {
- tid: 'transaction-123',
- },
- },
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123,
- },
- },
- {
- bidder: 'criteo',
- adUnitCode: 'bid-234',
- ortb2Imp: {
- ext: {
- tid: 'transaction-234',
- },
- },
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [728, 90]]
- }
- },
- params: {
- networkId: 456,
- },
- },
- ];
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- expect(request.url).to.match(/^https:\/\/grid-bidder\.criteo\.com\/openrtb_2_5\/pbjs\/auction\/request\?profileId=207&av=\d+&wv=[^&]+&cb=\d+&lsavail=[01]&debug=[01]&nolog=[01]&networkId=456$/);
- expect(request.method).to.equal('POST');
- const ortbRequest = request.data;
- expect(ortbRequest.site.page).to.equal(refererUrl);
- expect(ortbRequest.imp).to.have.lengthOf(2);
- expect(ortbRequest.imp[0].tagid).to.equal('bid-123');
- expect(ortbRequest.imp[0].banner.format).to.have.lengthOf(1);
- expect(ortbRequest.imp[0].banner.format[0].w).to.equal(728);
- expect(ortbRequest.imp[0].banner.format[0].h).to.equal(90);
- expect(ortbRequest.imp[0].ext.tid).to.equal('transaction-123');
- expect(ortbRequest.imp[0].ext.bidder.zoneid).to.equal(123);
- expect(ortbRequest.imp[1].tagid).to.equal('bid-234');
- expect(ortbRequest.imp[1].banner.format).to.have.lengthOf(2);
- expect(ortbRequest.imp[1].banner.format[0].w).to.equal(300);
- expect(ortbRequest.imp[1].banner.format[0].h).to.equal(250);
- expect(ortbRequest.imp[1].banner.format[1].w).to.equal(728);
- expect(ortbRequest.imp[1].banner.format[1].h).to.equal(90);
- expect(ortbRequest.imp[1].ext.tid).to.equal('transaction-234');
- expect(ortbRequest.user?.ext?.consent).to.equal(undefined);
- });
-
- it('should properly build a request with undefined gdpr consent fields when they are not provided', async function () {
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123,
- },
- },
- ];
- const bidderRequest = {
- timeout: 3000,
- gdprConsent: {},
- };
-
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.user?.ext?.consent).to.equal(undefined);
- expect(ortbRequest.regs?.ext?.gdpr).to.equal(undefined);
- });
-
- it('should properly build a request with ccpa consent field', async function () {
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123,
- },
- },
- ];
- const bidderRequest = {
- timeout: 3000,
- uspConsent: '1YNY',
- };
-
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.regs.ext.us_privacy).to.equal('1YNY');
- });
-
- it('should properly build a request with overridden tmax', async function () {
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123,
- },
- },
- ];
- const bidderRequest = {
- timeout: 1234
- };
-
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.tmax).to.equal(1234);
- });
-
- it('should properly build a request with device sua field', async function () {
- const sua = {
- platform: {
- brand: 'abc'
- }
- }
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123,
- },
- },
- ];
- const bidderRequest = {
- timeout: 3000,
- uspConsent: '1YNY',
- ortb2: {
- device: {
- sua: sua
- }
- }
- };
-
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.device.ext.sua).not.to.be.null;
- expect(ortbRequest.device.ext.sua.platform.brand).to.equal('abc');
- });
-
- it('should properly build a request with gpp consent field', async function () {
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123,
- },
- },
- ];
- const ortb2 = {
- regs: {
- gpp: 'gpp_consent_string',
- gpp_sid: [0, 1, 2],
- }
- };
-
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest({...bidderRequest, ortb2})).data;
- expect(ortbRequest.regs.ext.gpp).to.equal('gpp_consent_string');
- expect(ortbRequest.regs.ext.gpp_sid).to.deep.equal([0, 1, 2]);
- });
-
- it('should properly build a request with dsa object', async function () {
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123,
- },
- },
- ];
- const dsa = {
- required: 3,
- pubrender: 0,
- datatopub: 2,
- transparency: [{
- domain: 'platform1domain.com',
- params: [1]
- }, {
- domain: 'SSP2domain.com',
- params: [1, 2]
- }]
- };
- const ortb2 = {
- regs: {
- ext: {
- dsa: dsa
- }
- }
- };
-
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest({...bidderRequest, ortb2})).data;
- expect(ortbRequest.regs.ext.dsa).to.deep.equal(dsa);
- });
-
- it('should properly build a request with schain object', function () {
- const expectedSchain = {
- someProperty: 'someValue'
- };
- const bidRequests = [
- {
- bidder: 'criteo',
- ortb2: {
- source: {
- ext: {schain: expectedSchain}
- }
- },
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123,
- },
- },
- ];
-
- // Create a modified bidderRequest with schain
- const modifiedBidderRequest = {
- ...bidderRequest,
- ortb2: {
- source: {
- ext: {schain: expectedSchain}
- }
- }
- };
-
- const ortbRequest = spec.buildRequests(bidRequests, modifiedBidderRequest).data;
- expect(ortbRequest.source.ext.schain).to.deep.equal(expectedSchain);
- });
-
- it('should properly build a request with bcat field', async function () {
- const bcat = ['IAB1', 'IAB2'];
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123,
- },
- },
- ];
- const bidderRequest = {
- ortb2: {
- bcat
- }
- };
-
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.bcat).to.deep.equal(bcat);
- });
-
- it('should properly build a request with badv field', async function () {
- const badv = ['ford.com'];
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123,
- },
- },
- ];
- const bidderRequest = {
- ortb2: {
- badv
- }
- };
-
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.badv).to.deep.equal(badv);
- });
-
- it('should properly build a request with bapp field', async function () {
- const bapp = ['com.foo.mygame'];
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123,
- },
- },
- ];
- const bidderRequest = {
- ortb2: {
- bapp
- }
- };
-
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.bapp).to.deep.equal(bapp);
- });
-
- if (FEATURES.VIDEO) {
- it('should properly build a video request', async function () {
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- sizes: [[640, 480]],
- mediaTypes: {
- video: {
- context: 'inbanner',
- playerSize: [640, 480],
- mimes: ['video/mp4', 'video/x-flv'],
- maxduration: 30,
- api: [1, 2],
- protocols: [2, 3],
- plcmt: 3,
- w: 640,
- h: 480,
- linearity: 1,
- skipmin: 30,
- skipafter: 30,
- minbitrate: 10000,
- maxbitrate: 48000,
- delivery: [1, 2, 3],
- pos: 1,
- playbackend: 1,
- adPodDurationSec: 30,
- durationRangeSec: [1, 30],
- }
- },
- params: {
- zoneId: 123,
- video: {
- skip: 1,
- minduration: 5,
- startdelay: 5,
- playbackmethod: [1, 3],
- placement: 2
- }
- },
- },
- ];
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- expect(request.url).to.match(/^https:\/\/grid-bidder\.criteo\.com\/openrtb_2_5\/pbjs\/auction\/request\?profileId=207&av=\d+&wv=[^&]+&cb=\d+&lsavail=[01]&debug=[01]&nolog=[01]$/);
- expect(request.method).to.equal('POST');
- const ortbRequest = request.data;
- expect(ortbRequest.imp).to.have.lengthOf(1);
- expect(ortbRequest.imp[0].video.mimes).to.deep.equal(['video/mp4', 'video/x-flv']);
- expect(ortbRequest.imp[0].video.maxduration).to.equal(30);
- expect(ortbRequest.imp[0].video.api).to.deep.equal([1, 2]);
- expect(ortbRequest.imp[0].video.protocols).to.deep.equal([2, 3]);
- expect(ortbRequest.imp[0].video.skip).to.equal(1);
- expect(ortbRequest.imp[0].video.minduration).to.equal(5);
- expect(ortbRequest.imp[0].video.startdelay).to.equal(5);
- expect(ortbRequest.imp[0].video.playbackmethod).to.deep.equal([1, 3]);
- expect(ortbRequest.imp[0].video.placement).to.equal(2);
- expect(ortbRequest.imp[0].video.w).to.equal(640);
- expect(ortbRequest.imp[0].video.h).to.equal(480);
- expect(ortbRequest.imp[0].video.linearity).to.equal(1);
- expect(ortbRequest.imp[0].video.skipmin).to.equal(30);
- expect(ortbRequest.imp[0].video.skipafter).to.equal(30);
- expect(ortbRequest.imp[0].video.minbitrate).to.equal(10000);
- expect(ortbRequest.imp[0].video.maxbitrate).to.equal(48000);
- expect(ortbRequest.imp[0].video.delivery).to.deep.equal([1, 2, 3]);
- expect(ortbRequest.imp[0].video.pos).to.equal(1);
- expect(ortbRequest.imp[0].video.playbackend).to.equal(1);
- expect(ortbRequest.imp[0].video.ext.context).to.equal('inbanner');
- expect(ortbRequest.imp[0].video.ext.playersizes).to.deep.equal(['640x480']);
- expect(ortbRequest.imp[0].video.ext.plcmt).to.equal(3);
- expect(ortbRequest.imp[0].video.ext.poddur).to.equal(30);
- expect(ortbRequest.imp[0].video.ext.rqddurs).to.deep.equal([1, 30]);
- });
- }
-
- if (FEATURES.VIDEO) {
- it('should properly build a video request with more than one player size', async function () {
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- sizes: [[640, 480], [800, 600]],
- mediaTypes: {
- video: {
- playerSize: [[640, 480], [800, 600]],
- mimes: ['video/mp4', 'video/x-flv'],
- maxduration: 30,
- api: [1, 2],
- protocols: [2, 3]
- }
- },
- params: {
- zoneId: 123,
- video: {
- skip: 1,
- minduration: 5,
- startdelay: 5,
- playbackmethod: [1, 3],
- placement: 2
- }
- },
- },
- ];
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- expect(request.url).to.match(/^https:\/\/grid-bidder\.criteo\.com\/openrtb_2_5\/pbjs\/auction\/request\?profileId=207&av=\d+&wv=[^&]+&cb=\d+&lsavail=[01]&debug=[01]&nolog=[01]$/);
- expect(request.method).to.equal('POST');
- const ortbRequest = request.data;
- expect(ortbRequest.imp[0].video.mimes).to.deep.equal(['video/mp4', 'video/x-flv']);
- expect(ortbRequest.imp[0].video.maxduration).to.equal(30);
- expect(ortbRequest.imp[0].video.api).to.deep.equal([1, 2]);
- expect(ortbRequest.imp[0].video.protocols).to.deep.equal([2, 3]);
- expect(ortbRequest.imp[0].video.skip).to.equal(1);
- expect(ortbRequest.imp[0].video.minduration).to.equal(5);
- expect(ortbRequest.imp[0].video.startdelay).to.equal(5);
- expect(ortbRequest.imp[0].video.playbackmethod).to.deep.equal([1, 3]);
- expect(ortbRequest.imp[0].video.placement).to.equal(2);
- expect(ortbRequest.imp[0].video.w).to.equal(640);
- expect(ortbRequest.imp[0].video.h).to.equal(480);
- expect(ortbRequest.imp[0].video.ext.playersizes).to.deep.equal(['640x480', '800x600']);
- expect(ortbRequest.imp[0].ext.bidder.zoneid).to.equal(123);
- });
- }
-
- if (FEATURES.VIDEO) {
- it('should properly build a video request when mediaTypes.video.skip=0', async function () {
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- sizes: [[300, 250]],
- mediaTypes: {
- video: {
- playerSize: [[300, 250]],
- mimes: ['video/mp4', 'video/MPV', 'video/H264', 'video/webm', 'video/ogg'],
- minduration: 1,
- maxduration: 30,
- playbackmethod: [2, 3, 4, 5, 6],
- api: [1, 2, 3, 4, 5, 6],
- protocols: [1, 2, 3, 4, 5, 6, 7, 8],
- skip: 0
- }
- },
- params: {
- networkId: 456
- }
- }
- ];
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- expect(request.url).to.match(/^https:\/\/grid-bidder\.criteo\.com\/openrtb_2_5\/pbjs\/auction\/request\?profileId=207&av=\d+&wv=[^&]+&cb=\d+&lsavail=[01]&debug=[01]&nolog=[01]&networkId=456$/);
- expect(request.method).to.equal('POST');
- const ortbRequest = request.data;
- expect(ortbRequest.imp[0].video.mimes).to.deep.equal(['video/mp4', 'video/MPV', 'video/H264', 'video/webm', 'video/ogg']);
- expect(ortbRequest.imp[0].video.minduration).to.equal(1);
- expect(ortbRequest.imp[0].video.maxduration).to.equal(30);
- expect(ortbRequest.imp[0].video.playbackmethod).to.deep.equal([2, 3, 4, 5, 6]);
- expect(ortbRequest.imp[0].video.api).to.deep.equal([1, 2, 3, 4, 5, 6]);
- expect(ortbRequest.imp[0].video.protocols).to.deep.equal([1, 2, 3, 4, 5, 6, 7, 8]);
- expect(ortbRequest.imp[0].video.skip).to.equal(0);
- expect(ortbRequest.imp[0].video.w).to.equal(300);
- expect(ortbRequest.imp[0].video.h).to.equal(250);
- expect(ortbRequest.imp[0].video.ext.playersizes).to.deep.equal(['300x250']);
- });
- }
-
- it('should properly build a request without first party data', async function () {
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123
- }
- },
- ];
-
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest({
- ...bidderRequest,
- ortb2: {}
- })).data;
- expect(ortbRequest.site.page).to.equal(refererUrl);
- expect(ortbRequest.imp).to.have.lengthOf(1);
- expect(ortbRequest.imp[0].tagid).to.equal('bid-123');
- expect(ortbRequest.imp[0].banner.format).to.have.lengthOf(1);
- expect(ortbRequest.imp[0].banner.format[0].w).to.equal(728);
- expect(ortbRequest.imp[0].banner.format[0].h).to.equal(90);
- expect(ortbRequest.imp[0].ext.bidder.zoneid).to.equal(123);
- expect(ortbRequest.user.ext.consent).to.equal('consentDataString');
- expect(ortbRequest.regs.ext.gdpr).to.equal(1);
- expect(ortbRequest.regs.ext.gdprversion).to.equal(1);
- });
-
- it('should properly build a request with first party data', async function () {
- const siteData = {
- keywords: ['power tools'],
- content: {
- data: [{
- name: 'some_provider',
- ext: {
- segtax: 3
- },
- segment: [
- {'id': '1001'},
- {'id': '1002'}
- ]
- }]
- },
- ext: {
- data: {
- pageType: 'article'
- }
- }
- };
- const userData = {
- gender: 'M',
- data: [{
- name: 'some_provider',
- ext: {
- segtax: 3
- },
- segment: [
- {'id': '1001'},
- {'id': '1002'}
- ]
- }],
- ext: {
- data: {
- registered: true
- }
- }
- };
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123,
- ext: {
- bidfloor: 0.75
- }
- },
- ortb2Imp: {
- ext: {
- data: {
- someContextAttribute: 'abc'
- }
- }
- }
- },
- ];
-
- const ortb2 = {
- site: siteData,
- user: userData
- };
-
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest({...bidderRequest, ortb2})).data;
- expect(ortbRequest.user).to.deep.equal({...userData, ext: {...userData.ext, consent: 'consentDataString'}});
- expect(ortbRequest.site).to.deep.equal({
- ...siteData,
- page: refererUrl,
- domain: 'criteo.com',
- publisher: {...ortbRequest.site.publisher, domain: 'criteo.com'}
- });
- expect(ortbRequest.imp[0].ext.bidfloor).to.equal(0.75);
- expect(ortbRequest.imp[0].ext.data.someContextAttribute).to.equal('abc')
- });
-
- it('should properly build a request when coppa flag is true', async function () {
- const bidRequests = [];
- const bidderRequest = {};
- config.setConfig({coppa: true});
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.regs.coppa).to.equal(1);
- });
-
- it('should properly build a request when coppa flag is false', async function () {
- const bidRequests = [];
- const bidderRequest = {};
- config.setConfig({coppa: false});
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.regs.coppa).to.equal(0);
- });
-
- it('should properly build a request when coppa flag is not defined', async function () {
- const bidRequests = [];
- const bidderRequest = {};
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.regs?.coppa).to.be.undefined;
- });
-
- it('should properly build a banner request with floors', async function () {
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [728, 90]]
- }
- },
- params: {
- networkId: 456,
- },
-
- getFloor: inputParams => {
- if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) {
- return {
- currency: 'USD',
- floor: 1.0
- };
- } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) {
- return {
- currency: 'USD',
- floor: 2.0
- };
- } else {
- return {}
- }
- }
- },
- ];
- const bidderRequest = {};
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.imp[0].ext.floors).to.deep.equal({
- 'banner': {
- '300x250': {'currency': 'USD', 'floor': 1},
- '728x90': {'currency': 'USD', 'floor': 2}
- }
- });
- });
-
- it('should properly build a request with static floors', async function () {
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [728, 90]]
- }
- },
- params: {
- networkId: 456,
- bidFloor: 1,
- bidFloorCur: 'EUR'
- },
- },
- ];
- const bidderRequest = {};
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.imp[0].ext.floors).to.deep.equal({
- 'banner': {
- '300x250': {'currency': 'EUR', 'floor': 1},
- '728x90': {'currency': 'EUR', 'floor': 1}
- }
- });
- });
-
- it('should properly build a video request with several player sizes with floors', async function () {
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- video: {
- playerSize: [[300, 250], [728, 90]]
- }
- },
- params: {
- networkId: 456,
- },
-
- getFloor: inputParams => {
- if (inputParams.mediaType === VIDEO && inputParams.size[0] === 300 && inputParams.size[1] === 250) {
- return {
- currency: 'USD',
- floor: 1.0
- };
- } else if (inputParams.mediaType === VIDEO && inputParams.size[0] === 728 && inputParams.size[1] === 90) {
- return {
- currency: 'USD',
- floor: 2.0
- };
- } else {
- return {}
- }
- }
- },
- ];
- const bidderRequest = {};
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.imp[0].ext.floors).to.deep.equal({
- 'video': {
- '300x250': {'currency': 'USD', 'floor': 1},
- '728x90': {'currency': 'USD', 'floor': 2}
- }
- });
- });
-
- if (FEATURES.VIDEO && FEATURES.NATIVE) {
- it('should properly build a multi format request with floors', async function () {
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [728, 90]]
- },
- video: {
- playerSize: [640, 480],
- },
- native: {}
- },
- params: {
- networkId: 456,
- },
- ortb2Imp: {
- ext: {
- data: {
- someContextAttribute: 'abc'
- }
- }
- },
-
- getFloor: inputParams => {
- if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) {
- return {
- currency: 'USD',
- floor: 1.0
- };
- } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) {
- return {
- currency: 'USD',
- floor: 2.0
- };
- } else if (inputParams.mediaType === VIDEO && inputParams.size[0] === 640 && inputParams.size[1] === 480) {
- return {
- currency: 'EUR',
- floor: 3.2
- };
- } else if (inputParams.mediaType === NATIVE && inputParams.size === '*') {
- return {
- currency: 'YEN',
- floor: 4.99
- };
- } else {
- return {}
- }
- }
- },
- ];
- const bidderRequest = {};
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.imp[0].banner).not.to.be.null;
- expect(ortbRequest.imp[0].video).not.to.be.null;
- expect(ortbRequest.imp[0].native.request_native).not.to.be.null;
- expect(ortbRequest.imp[0].ext.data.someContextAttribute).to.deep.equal('abc');
- expect(ortbRequest.imp[0].ext.floors).to.deep.equal({
- 'banner': {
- '300x250': {'currency': 'USD', 'floor': 1},
- '728x90': {'currency': 'USD', 'floor': 2}
- },
- 'video': {
- '640x480': {'currency': 'EUR', 'floor': 3.2}
- },
- 'native': {
- '*': {'currency': 'YEN', 'floor': 4.99}
- }
- });
- });
- }
-
- it('should properly build a request when imp.rwdd is present', async function () {
- const bidderRequest = {};
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123
- },
- ortb2Imp: {
- rwdd: 1
- }
- },
- ];
-
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.imp[0].ext.rwdd).to.equal(1);
- });
-
- it('should properly build a request when imp.rwdd is false', async function () {
- const bidderRequest = {};
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123
- },
- ortb2Imp: {
- rwdd: 0
- }
- },
- ];
-
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.imp[0].ext?.rwdd).to.equal(0);
- });
-
- it('should properly build a request when FLEDGE is enabled', async function () {
- const bidderRequest = {
- paapi: {
- enabled: true
- }
- };
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123
- },
- ortb2Imp: {
- ext: {
- igs: {
- ae: 1
- }
- }
- }
- },
- ];
-
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.imp[0].ext.igs.ae).to.equal(1);
- });
-
- it('should properly build a request when FLEDGE is disabled', async function () {
- const bidderRequest = {
- paapi: {
- enabled: false
- },
- };
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123
- },
- ortb2Imp: {
- ext: {
- igs: {
- ae: 1
- }
- }
- }
- },
- ];
-
- const ortbRequest = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest)).data;
- expect(ortbRequest.imp[0].ext.igs?.ae).to.be.undefined;
- });
-
- it('should properly transmit the pubid and slot uid if available', async function () {
- const bidderRequest = {
- ortb2: {
- site: {
- publisher: {
- id: 'pub-777'
- }
- }
- }
- };
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- ortb2Imp: {
- ext: {
- tid: 'transaction-123',
- },
- },
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- zoneId: 123,
- },
- },
- {
- bidder: 'criteo',
- adUnitCode: 'bid-234',
- ortb2Imp: {
- ext: {
- tid: 'transaction-234',
- },
- },
- mediaTypes: {
- banner: {
- sizes: [[300, 250], [728, 90]]
- }
- },
- params: {
- networkId: 456,
- pubid: 'pub-888',
- uid: 888
- },
- },
- ];
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const ortbRequest = request.data;
- expect(ortbRequest.site.publisher.id).to.equal('pub-888');
- expect(ortbRequest.imp[0].ext.bidder.uid).to.be.undefined;
- expect(ortbRequest.imp[1].ext.bidder.uid).to.equal(888);
- });
-
- it('should properly transmit device.ext.cdep if available', async function () {
- const bidderRequest = {
- ortb2: {
- device: {
- ext: {
- cdep: 'cookieDeprecationLabel'
- }
- }
- }
- };
- const bidRequests = [];
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const ortbRequest = request.data;
- expect(ortbRequest.device.ext.cdep).to.equal('cookieDeprecationLabel');
- });
-
- it('should interpret correctly gzip configuration given as a string', async function() {
- bidderConfigStub.returns({criteo: {gzipEnabled: 'false'}});
-
- const request = spec.buildRequests(defaultBidRequests, await addFPDToBidderRequest(bidderRequest));
- expect(request.options.endpointCompression).to.be.false;
- });
-
- it('should interpret correctly gzip configuration given as a boolean', async function () {
- bidderConfigStub.returns({criteo: {gzipEnabled: false}});
-
- const request = spec.buildRequests(defaultBidRequests, await addFPDToBidderRequest(bidderRequest));
- expect(request.options.endpointCompression).to.be.false;
- });
-
- it('should default to true when it receives an invalid configuration', async function () {
- bidderConfigStub.returns({criteo: {gzipEnabled: 'randomString'}});
-
- const request = spec.buildRequests(defaultBidRequests, await addFPDToBidderRequest(bidderRequest));
- expect(request.options.endpointCompression).to.be.true;
- })
- });
-
- describe('interpretResponse', function () {
- const refererUrl = 'https://criteo.com?pbt_debug=1&pbt_nolog=1';
- const bidderRequest = {
- refererInfo: {
- page: refererUrl,
- topmostLocation: refererUrl
- },
- timeout: 3000,
- gdprConsent: {
- gdprApplies: true,
- consentString: 'consentDataString',
- vendorData: {
- vendorConsents: {
- '91': 1
- },
- },
- apiVersion: 1,
- },
- };
-
- function mockResponse(winningBidId, mediaType) {
- return {
- id: 'test-requestId',
- seatbid: [
- {
- seat: 'criteo',
- bid: [
- {
- id: 'test-bidderId',
- impid: winningBidId,
- price: 1.23,
- adomain: ['criteo.com'],
- bundle: '',
- iurl: 'http://some_image/',
- cid: '123456',
- crid: 'test-crId',
- dealid: 'deal-code',
- w: 728,
- h: 90,
- adm: 'test-ad',
- adm_native: mediaType === NATIVE ? {
- ver: '1.2',
- assets: [
- {
- id: 10,
- title: {
- text: 'Some product'
- }
- },
- {
- id: 11,
- img: {
- type: 3,
- url: 'https://main_image_url.com',
- w: 400,
- h: 400
- }
- },
- {
- id: 12,
- data: {
- value: 'Some product'
- }
- },
- {
- id: 13,
- data: {
- value: '1,499 TL'
- }
- },
- {
- id: 15,
- data: {
- value: 'CTA'
- },
- link: {
- url: 'https://cta_url.com'
- }
- },
- {
- id: 17,
- img: {
- type: 1,
- url: 'https://main_image_url.com',
- w: 200,
- h: 200
- },
- link: {
- url: 'https://icon_image_url.com'
- }
- },
- {
- id: 16,
- data: {
- value: 'Some brand'
- }
- }
- ],
- eventtrackers: [
- {
- event: 1,
- method: 1,
- url: 'https://eventtrackers.com'
- },
- {
- event: 1,
- method: 1,
- url: 'https://test_in_isolation.criteo.com/tpd?dd=HTlW9l9xTEZqRHVlSHFiSWx5Q2VQMlEwSTJhNCUyQkxNazQ1Y29LR3ZmS2VTSDFsUGdkRHNoWjQ2UWp0SGtVZ1RTbHI0TFRpTlVqNWxiUkZOeGVFNjVraW53R0loRVJQNDJOY2R1eWxVdjBBQ1BEdVFvTyUyRlg3aWJaeUFha3UyemNNVGpmJTJCS1prc0FwRjZRJTJCQ2dpaFBJeVhZRmQlMkZURVZocUFRdm03OTdFZHZSbURNZWt4Uzh2M1NSUUxmTmhaTnNnRXd4VkZlOTdJOXdnNGZjaVolMkZWYmdYVjJJMkQ0eGxQaFIwQmVtWk1sQ09tNXlGY0Nwc09GTDladzExJTJGVExGNXJsdGpneERDeTMlMkJuNUlUcEU4NDFLMTZPc2ZoWFUwMmpGbDFpVjBPZUVtTlEwaWNOeHRyRFYyenRKd0lpJTJGTTElMkY1WGZ3Smo3aTh0bUJzdzZRdlZUSXppanNkamo3ekZNZjhKdjl2VDJ5eHV1YnVzdmdRdk5iWnprNXVFMVdmbGs0QU1QY0ozZQ'
- }
- ],
- privacy: 'https://cta_url.com',
- ext: {
- privacy: {
- imageurl: 'https://icon_image_url.com',
- clickurl: 'https://cta_url.com',
- longlegaltext: ''
- }
- }
- } : undefined,
- ext: {
- mediatype: mediaType,
- displayurl: mediaType === VIDEO ? 'http://test-ad' : undefined,
- dsa: {
- adrender: 1
- },
- meta: {
- networkName: 'Criteo'
- },
- videoPlayerType: mediaType === VIDEO ? 'RadiantMediaPlayer' : undefined,
- videoPlayerConfig: mediaType === VIDEO ? {} : undefined,
- cur: 'CUR'
- }
- }
- ]
- }
- ]
- };
- }
-
- it('should return an empty array when parsing an empty bid response', async function () {
- const bidRequests = [];
- const response = {};
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const bids = spec.interpretResponse(response, request);
- expect(bids).to.have.lengthOf(0);
- });
-
- it('should return an empty array when parsing a well-formed no bid response', async function () {
- const bidRequests = [];
- const response = {seatbid: []};
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const bids = spec.interpretResponse({body: response}, request);
- expect(bids).to.have.lengthOf(0);
- });
-
- it('should properly parse a banner bid response', async function () {
- const bidRequests = [{
- adUnitCode: 'test-requestId',
- bidId: 'test-bidId',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- networkId: 456,
- }
- }];
- const response = mockResponse('test-bidId', BANNER);
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const bids = spec.interpretResponse({body: response}, request);
- expect(bids).to.have.lengthOf(1);
- expect(bids[0].mediaType).to.equal(BANNER);
- expect(bids[0].requestId).to.equal('test-bidId');
- expect(bids[0].seatBidId).to.equal('test-bidderId')
- expect(bids[0].cpm).to.equal(1.23);
- expect(bids[0].currency).to.equal('CUR');
- expect(bids[0].width).to.equal(728);
- expect(bids[0].height).to.equal(90);
- expect(bids[0].ad).to.equal('test-ad');
- expect(bids[0].creativeId).to.equal('test-crId');
- expect(bids[0].dealId).to.equal('deal-code');
- expect(bids[0].meta.advertiserDomains[0]).to.equal('criteo.com');
- expect(bids[0].meta.networkName).to.equal('Criteo');
- expect(bids[0].meta.dsa.adrender).to.equal(1);
- });
-
- if (FEATURES.VIDEO) {
- it('should properly parse a bid response with a video', async function () {
- const bidRequests = [{
- adUnitCode: 'test-requestId',
- bidId: 'test-bidId',
- mediaTypes: {
- video: {
- context: 'instream',
- mimes: ['video/mpeg'],
- playerSize: [640, 480],
- protocols: [5, 6],
- maxduration: 30,
- api: [1, 2]
- }
- },
- params: {
- zoneId: 123,
- },
- }];
- const response = mockResponse('test-bidId', VIDEO);
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const bids = spec.interpretResponse({body: response}, request);
- expect(bids).to.have.lengthOf(1);
- expect(bids[0].mediaType).to.equal(VIDEO);
- expect(bids[0].requestId).to.equal('test-bidId');
- expect(bids[0].seatBidId).to.equal('test-bidderId')
- expect(bids[0].cpm).to.equal(1.23);
- expect(bids[0].currency).to.equal('CUR');
- expect(bids[0].vastUrl).to.equal('http://test-ad');
- expect(bids[0].vastXml).to.equal('test-ad');
- expect(bids[0].playerWidth).to.equal(640);
- expect(bids[0].playerHeight).to.equal(480);
- expect(bids[0].renderer).to.equal(undefined);
- });
- }
-
- if (FEATURES.VIDEO) {
- it('should properly parse a bid response with an outstream video', async function () {
- const bidRequests = [{
- adUnitCode: 'test-requestId',
- bidId: 'test-bidId',
- mediaTypes: {
- video: {
- context: 'outstream',
- mimes: ['video/mpeg'],
- playerSize: [640, 480],
- protocols: [5, 6],
- maxduration: 30,
- api: [1, 2]
- }
- },
- params: {
- networkId: 456,
- },
- }];
- const response = mockResponse('test-bidId', VIDEO);
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const bids = spec.interpretResponse({body: response}, request);
- expect(bids).to.have.lengthOf(1);
- expect(bids[0].mediaType).to.equal(VIDEO);
- expect(bids[0].requestId).to.equal('test-bidId');
- expect(bids[0].seatBidId).to.equal('test-bidderId')
- expect(bids[0].cpm).to.equal(1.23);
- expect(bids[0].currency).to.equal('CUR');
- expect(bids[0].vastUrl).to.equal('http://test-ad');
- expect(bids[0].vastXml).to.equal('test-ad');
- expect(bids[0].playerWidth).to.equal(640);
- expect(bids[0].playerHeight).to.equal(480);
- expect(bids[0].renderer.url).to.equal('https://static.criteo.net/js/ld/publishertag.renderer.js');
- expect(typeof bids[0].renderer.config.documentResolver).to.equal('function');
- expect(typeof bids[0].renderer._render).to.equal('function');
- });
- }
-
- if (FEATURES.NATIVE) {
- it('should properly parse a native bid response', async function () {
- const bidRequests = [{
- adUnitCode: 'test-requestId',
- bidId: 'test-bidId',
- params: {
- zoneId: '123',
- },
- native: true,
- }];
- const response = mockResponse('test-bidId', NATIVE);
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const bids = spec.interpretResponse({body: response}, request);
- expect(bids).to.have.lengthOf(1);
- expect(bids[0].mediaType).to.equal(NATIVE);
- expect(bids[0].requestId).to.equal('test-bidId');
- expect(bids[0].seatBidId).to.equal('test-bidderId')
- expect(bids[0].cpm).to.equal(1.23);
- expect(bids[0].currency).to.equal('CUR');
- expect(bids[0].width).to.equal(728);
- expect(bids[0].height).to.equal(90);
- expect(bids[0].ad).to.equal(undefined);
- expect(bids[0].native.ortb).not.to.be.null;
- expect(bids[0].native.ortb).to.equal(response.seatbid[0].bid[0].adm); // adm_native field was moved to adm
- expect(bids[0].creativeId).to.equal('test-crId');
- expect(bids[0].dealId).to.equal('deal-code');
- expect(bids[0].meta.advertiserDomains[0]).to.equal('criteo.com');
- expect(bids[0].meta.networkName).to.equal('Criteo');
- expect(bids[0].meta.dsa.adrender).to.equal(1);
- });
- }
-
- it('should properly parse a bid response when banner win with twin ad units', async function () {
- const bidRequests = [{
- adUnitCode: 'test-requestId',
- bidId: 'test-bidId',
- mediaTypes: {
- video: {
- context: 'instream',
- mimes: ['video/mpeg'],
- playerSize: [640, 480],
- protocols: [5, 6],
- maxduration: 30,
- api: [1, 2]
- }
- },
- params: {
- networkId: 456,
- },
- }, {
- adUnitCode: 'test-requestId',
- bidId: 'test-bidId2',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- networkId: 456,
- }
- }];
- const response = mockResponse('test-bidId2', BANNER);
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const bids = spec.interpretResponse({body: response}, request);
- expect(bids).to.have.lengthOf(1);
- expect(bids[0].mediaType).to.equal(BANNER);
- expect(bids[0].requestId).to.equal('test-bidId2');
- expect(bids[0].seatBidId).to.equal('test-bidderId')
- expect(bids[0].cpm).to.equal(1.23);
- expect(bids[0].currency).to.equal('CUR');
- expect(bids[0].width).to.equal(728);
- expect(bids[0].height).to.equal(90);
- expect(bids[0].ad).to.equal('test-ad');
- expect(bids[0].creativeId).to.equal('test-crId');
- expect(bids[0].dealId).to.equal('deal-code');
- expect(bids[0].meta.advertiserDomains[0]).to.equal('criteo.com');
- expect(bids[0].meta.networkName).to.equal('Criteo');
- expect(bids[0].meta.dsa.adrender).to.equal(1);
- });
-
- if (FEATURES.VIDEO) {
- it('should properly parse a bid response when video win with twin ad units', async function () {
- const bidRequests = [{
- adUnitCode: 'test-requestId',
- bidId: 'test-bidId',
- mediaTypes: {
- video: {
- context: 'instream',
- mimes: ['video/mpeg'],
- playerSize: [640, 480],
- protocols: [5, 6],
- maxduration: 30,
- api: [1, 2]
- }
- },
- params: {
- zoneId: '123'
- },
- }, {
- adUnitCode: 'test-requestId',
- bidId: 'test-bidId2',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- networkId: 456,
- }
- }];
- const response = mockResponse('test-bidId', VIDEO);
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const bids = spec.interpretResponse({body: response}, request);
- expect(bids).to.have.lengthOf(1);
- expect(bids[0].mediaType).to.equal(VIDEO);
- expect(bids[0].requestId).to.equal('test-bidId');
- expect(bids[0].seatBidId).to.equal('test-bidderId')
- expect(bids[0].cpm).to.equal(1.23);
- expect(bids[0].currency).to.equal('CUR');
- expect(bids[0].vastUrl).to.equal('http://test-ad');
- expect(bids[0].vastXml).to.equal('test-ad');
- expect(bids[0].playerWidth).to.equal(640);
- expect(bids[0].playerHeight).to.equal(480);
- expect(bids[0].renderer).to.equal(undefined);
- });
- }
-
- if (FEATURES.NATIVE) {
- it('should properly parse a bid response when native win with twin ad units', async function () {
- const bidRequests = [{
- adUnitCode: 'test-requestId',
- bidId: 'test-bidId',
- mediaTypes: {
- native: {}
- },
- params: {
- networkId: 456,
- },
- }, {
- adUnitCode: 'test-requestId',
- bidId: 'test-bidId2',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- networkId: 456,
- }
- }];
- const response = mockResponse('test-bidId', NATIVE);
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const bids = spec.interpretResponse({body: response}, request);
- expect(bids).to.have.lengthOf(1);
- expect(bids[0].mediaType).to.equal(NATIVE);
- expect(bids[0].requestId).to.equal('test-bidId');
- expect(bids[0].seatBidId).to.equal('test-bidderId')
- expect(bids[0].cpm).to.equal(1.23);
- expect(bids[0].currency).to.equal('CUR');
- expect(bids[0].width).to.equal(728);
- expect(bids[0].height).to.equal(90);
- expect(bids[0].ad).to.equal(undefined);
- expect(bids[0].native.ortb).not.to.be.null;
- expect(bids[0].native.ortb).to.equal(response.seatbid[0].bid[0].adm); // adm_native field was moved to adm
- expect(bids[0].creativeId).to.equal('test-crId');
- expect(bids[0].dealId).to.equal('deal-code');
- expect(bids[0].meta.advertiserDomains[0]).to.equal('criteo.com');
- expect(bids[0].meta.networkName).to.equal('Criteo');
- expect(bids[0].meta.dsa.adrender).to.equal(1);
- });
- }
-
- it('should properly parse a bid response with FLEDGE auction configs', async function () {
- const auctionConfig1 = {
- auctionSignals: {},
- decisionLogicUrl: 'https://grid-mercury.criteo.com/fledge/decision',
- interestGroupBuyers: ['https://first-buyer-domain.com', 'https://second-buyer-domain.com'],
- perBuyerSignals: {
- 'https://first-buyer-domain.com': {
- foo: 'bar',
- },
- 'https://second-buyer-domain.com': {
- foo: 'baz'
- },
- },
- perBuyerTimeout: {
- '*': 500,
- 'buyer1': 100,
- 'buyer2': 200
- },
- perBuyerGroupLimits: {
- '*': 60,
- 'buyer1': 300,
- 'buyer2': 400
- },
- seller: 'https://seller-domain.com',
- sellerTimeout: 500,
- sellerSignals: {
- foo: 'bar',
- foo2: 'bar2',
- floor: 1,
- currency: 'USD',
- perBuyerTimeout: {
- 'buyer1': 100,
- 'buyer2': 200
- },
- perBuyerGroupLimits: {
- 'buyer1': 300,
- 'buyer2': 400
- },
- },
- sellerCurrency: 'USD',
- };
- const auctionConfig2 = {
- auctionSignals: {},
- decisionLogicUrl: 'https://grid-mercury.criteo.com/fledge/decision',
- interestGroupBuyers: ['https://first-buyer-domain.com', 'https://second-buyer-domain.com'],
- perBuyerSignals: {
- 'https://first-buyer-domain.com': {
- foo: 'bar',
- },
- 'https://second-buyer-domain.com': {
- foo: 'baz'
- },
- },
- perBuyerTimeout: {
- '*': 500,
- 'buyer1': 100,
- 'buyer2': 200
- },
- perBuyerGroupLimits: {
- '*': 60,
- 'buyer1': 300,
- 'buyer2': 400
- },
- seller: 'https://seller-domain.com',
- sellerTimeout: 500,
- sellerSignals: {
- foo: 'bar',
- floor: 1,
- perBuyerTimeout: {
- 'buyer1': 100,
- 'buyer2': 200
- },
- perBuyerGroupLimits: {
- 'buyer1': 300,
- 'buyer2': 400
- },
- },
- sellerCurrency: '???'
- };
- const bidRequests = [
- {
- bidId: 'test-bidId',
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- transactionId: 'transaction-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- bidFloor: 1,
- bidFloorCur: 'EUR'
- }
- },
- {
- bidId: 'test-bidId-2',
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- transactionId: 'transaction-123',
- mediaTypes: {
- banner: {
- sizes: [[728, 90]]
- }
- },
- params: {
- bidFloor: 1,
- bidFloorCur: 'EUR'
- }
- },
- ];
- const response = {
- ext: {
- igi: [{
- impid: 'test-bidId',
- igs: [{
- impid: 'test-bidId',
- bidId: 'test-bidId',
- config: auctionConfig1
- }]
- }, {
- impid: 'test-bidId-2',
- igs: [{
- impid: 'test-bidId-2',
- bidId: 'test-bidId-2',
- config: auctionConfig2
- }]
- }]
- },
- };
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const interpretedResponse = spec.interpretResponse({body: response}, request);
- expect(interpretedResponse).to.have.property('bids');
- expect(interpretedResponse).to.have.property('paapi');
- expect(interpretedResponse.bids).to.have.lengthOf(0);
- expect(interpretedResponse.paapi).to.have.lengthOf(2);
- expect(interpretedResponse.paapi[0]).to.deep.equal({
- bidId: 'test-bidId',
- impid: 'test-bidId',
- config: auctionConfig1,
- });
- expect(interpretedResponse.paapi[1]).to.deep.equal({
- bidId: 'test-bidId-2',
- impid: 'test-bidId-2',
- config: auctionConfig2,
- });
- });
-
- [{
- hasBidResponseLevelPafData: true,
- hasBidResponseBidLevelPafData: true,
- shouldContainsBidMetaPafData: true
- },
- {
- hasBidResponseLevelPafData: false,
- hasBidResponseBidLevelPafData: true,
- shouldContainsBidMetaPafData: false
- },
- {
- hasBidResponseLevelPafData: true,
- hasBidResponseBidLevelPafData: false,
- shouldContainsBidMetaPafData: false
- },
- {
- hasBidResponseLevelPafData: false,
- hasBidResponseBidLevelPafData: false,
- shouldContainsBidMetaPafData: false
- }].forEach(testCase =>
- it('should properly forward or not meta paf data', async () => {
- const bidPafContentId = 'abcdef';
- const pafTransmission = {
- version: '12'
- };
- const bidRequests = [{
- bidId: 'test-bidId',
- adUnitCode: 'adUnitId',
- sizes: [[300, 250]],
- params: {
- networkId: 456,
- }
- }];
- const response = {
- id: 'test-requestId',
- seatbid: [{
- seat: 'criteo',
- bid: [
- {
- id: 'test-bidderId',
- impid: 'test-bidId',
- w: 728,
- h: 90,
- ext: {
- mediatype: BANNER,
- paf: testCase.hasBidResponseBidLevelPafData ? {
- content_id: bidPafContentId
- } : undefined
- }
- }
- ]
- }],
- ext: (testCase.hasBidResponseLevelPafData ? {
- paf: {
- transmission: pafTransmission
- }
- } : undefined)
- };
-
- const request = spec.buildRequests(bidRequests, await addFPDToBidderRequest(bidderRequest));
- const bids = spec.interpretResponse({body: response}, request);
-
- expect(bids).to.have.lengthOf(1);
-
- const expectedBidMetaPafData = {
- paf: {
- content_id: bidPafContentId,
- transmission: pafTransmission
- }
- };
-
- if (testCase.shouldContainsBidMetaPafData) {
- expect(bids[0].meta).to.deep.equal(expectedBidMetaPafData);
- } else {
- expect(bids[0].meta).not.to.deep.equal(expectedBidMetaPafData);
- }
- })
- )
- });
-
- describe('when pubtag prebid adapter is not available', function () {
- it('should not warn if sendId is provided on required fields for native bidRequest', async () => {
- const bidderRequest = {};
- const bidRequestsWithSendId = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- sizes: [[728, 90]],
- mediaTypes: {
- native: {}
- },
- nativeOrtbRequest: {
- assets: [{
- required: 1,
- id: 1,
- img: {
- type: 3,
- wmin: 100,
- hmin: 100,
- }
- }]
- },
- params: {
- zoneId: 123,
- publisherSubId: '123'
- },
- nativeParams: {
- image: {
- sendId: true
- },
- icon: {
- sendId: true
- },
- clickUrl: {
- sendId: true
- },
- displayUrl: {
- sendId: true
- },
- privacyLink: {
- sendId: true
- },
- privacyIcon: {
- sendId: true
- }
- }
- }
- ];
-
- const request = spec.buildRequests(bidRequestsWithSendId, await addFPDToBidderRequest(bidderRequest));
- expect(logWarnStub.withArgs('Criteo: all native assets containing URL should be sent as placeholders with sendId(icon, image, clickUrl, displayUrl, privacyLink, privacyIcon)').notCalled).to.be.true;
- });
-
- it('should warn only once if sendId is not provided on required fields for native bidRequest', async () => {
- const bidderRequest = {};
- const bidRequests = [
- {
- bidder: 'criteo',
- adUnitCode: 'bid-123',
- mediaTypes: {
- native: {}
- },
- nativeOrtbRequest: {
- assets: [{
- required: 1,
- id: 1,
- img: {
- type: 3,
- wmin: 100,
- hmin: 100,
- }
- }]
- },
- params: {
- zoneId: 123,
- publisherSubId: '123'
- },
- },
- {
- bidder: 'criteo',
- adUnitCode: 'bid-456',
- transactionId: 'transaction-456',
- mediaTypes: {
- native: {}
- },
- nativeOrtbRequest: {
- assets: [{
- required: 1,
- id: 1,
- img: {
- type: 3,
- wmin: 100,
- hmin: 100,
- }
- }]
- },
- params: {
- zoneId: 456,
- publisherSubId: '456'
- },
- },
- ];
-
- const nativeParamsWithoutSendId = [
- {
- nativeParams: {
- image: {
- sendId: false
- },
- }
- },
- {
- nativeParams: {
- icon: {
- sendId: false
- },
- }
- },
- {
- nativeParams: {
- clickUrl: {
- sendId: false
- },
- }
- },
- {
- nativeParams: {
- displayUrl: {
- sendId: false
- },
- }
- },
- {
- nativeParams: {
- privacyLink: {
- sendId: false
- },
- }
- },
- {
- nativeParams: {
- privacyIcon: {
- sendId: false
- },
- }
- }
- ];
-
- for (const nativeParams of nativeParamsWithoutSendId) {
- let transformedBidRequests = {...bidRequests};
- transformedBidRequests = [Object.assign(transformedBidRequests[0], nativeParams), Object.assign(transformedBidRequests[1], nativeParams)];
- spec.buildRequests(transformedBidRequests, await addFPDToBidderRequest(bidderRequest));
- }
- expect(logWarnStub.withArgs('Criteo: all native assets containing URL should be sent as placeholders with sendId(icon, image, clickUrl, displayUrl, privacyLink, privacyIcon)').callCount).to.equal(nativeParamsWithoutSendId.length * bidRequests.length);
- });
- });
-});
diff --git a/test/spec/modules/cwireBidAdapter_spec.js b/test/spec/modules/cwireBidAdapter_spec.js
deleted file mode 100644
index 3cbf8a631..000000000
--- a/test/spec/modules/cwireBidAdapter_spec.js
+++ /dev/null
@@ -1,484 +0,0 @@
-import { expect } from "chai";
-import { newBidder } from "../../../src/adapters/bidderFactory.js";
-import { BID_ENDPOINT, spec, storage } from "../../../modules/cwireBidAdapter.js";
-import { deepClone, logInfo } from "../../../src/utils.js";
-import * as utils from "src/utils.js";
-import sinon, { stub } from "sinon";
-import { config } from "../../../src/config.js";
-import * as autoplayLib from "../../../libraries/autoplayDetection/autoplay.js";
-
-describe("C-WIRE bid adapter", () => {
- config.setConfig({ debug: true });
- let sandbox;
- const adapter = newBidder(spec);
- const bidRequests = [
- {
- bidder: "cwire",
- params: {
- pageId: "4057",
- placementId: "ad-slot-bla",
- },
- adUnitCode: "adunit-code",
- sizes: [
- [300, 250],
- [300, 600],
- ],
- bidId: "30b31c1838de1e",
- bidderRequestId: "22edbae2733bf6",
- auctionId: "1d1a030790a475",
- transactionId: "04f2659e-c005-4eb1-a57c-fa93145e3843",
- },
- ];
- const response = {
- body: {
- cwid: "2ef90743-7936-4a82-8acf-e73382a64e94",
- hash: "17112D98BBF55D3A",
- bids: [
- {
- html: "Hello world
",
- cpm: 100,
- currency: "CHF",
- dimensions: [1, 1],
- netRevenue: true,
- creativeId: "3454",
- requestId: "2c634d4ca5ccfb",
- placementId: 177,
- transactionId: "b4b32618-1350-4828-b6f0-fbb5c329e9a4",
- ttl: 360,
- },
- ],
- },
- };
-
- beforeEach(function () {
- sandbox = sinon.createSandbox();
- });
-
- afterEach(function () {
- sandbox.restore();
- });
- describe("inherited functions", function () {
- it("exists and is a function", function () {
- expect(adapter.callBids).to.exist.and.to.be.a("function");
- expect(spec.isBidRequestValid).to.exist.and.to.be.a("function");
- expect(spec.buildRequests).to.exist.and.to.be.a("function");
- expect(spec.interpretResponse).to.exist.and.to.be.a("function");
- });
- });
- describe("buildRequests", function () {
- it("sends bid request to ENDPOINT via POST", function () {
- const request = spec.buildRequests(bidRequests);
- expect(request.url).to.equal(BID_ENDPOINT);
- expect(request.method).to.equal("POST");
- });
- });
- describe("buildRequests with given creative", function () {
- let utilsStub;
-
- beforeEach(function () {
- utilsStub = stub(utils, "getParameterByName").callsFake(function () {
- return "str-str";
- });
- });
-
- afterEach(function () {
- utilsStub.restore();
- });
-
- it("should add creativeId if url parameter given", function () {
- // set from bid.params
- const bidRequest = deepClone(bidRequests[0]);
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
- expect(payload.cwcreative).to.exist;
- expect(payload.cwcreative).to.deep.equal("str-str");
- });
- });
-
- describe("buildRequests reads adUnit offsetWidth and offsetHeight", function () {
- beforeEach(function () {
- const documentStub = sandbox.stub(document, "getElementById");
- documentStub.withArgs(`${bidRequests[0].adUnitCode}`).returns({
- offsetWidth: 200,
- offsetHeight: 250,
- getBoundingClientRect() {
- return { width: 200, height: 250 };
- },
- });
- });
- it("width and height should be set", function () {
- const bidRequest = deepClone(bidRequests[0]);
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
- const el = document.getElementById(`${bidRequest.adUnitCode}`);
-
- logInfo(JSON.stringify(payload));
-
- expect(el).to.exist;
- expect(payload.slots[0].cwExt.dimensions.width).to.equal(200);
- expect(payload.slots[0].cwExt.dimensions.height).to.equal(250);
- expect(payload.slots[0].cwExt.style.maxHeight).to.not.exist;
- expect(payload.slots[0].cwExt.style.maxWidth).to.not.exist;
- });
- afterEach(function () {
- sandbox.restore();
- });
- });
- describe("buildRequests reads style attributes", function () {
- beforeEach(function () {
- const documentStub = sandbox.stub(document, "getElementById");
- documentStub.withArgs(`${bidRequests[0].adUnitCode}`).returns({
- style: {
- maxWidth: "400px",
- maxHeight: "350px",
- },
- getBoundingClientRect() {
- return { width: 0, height: 0 };
- },
- });
- });
- it("css maxWidth should be set", function () {
- const bidRequest = deepClone(bidRequests[0]);
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
- const el = document.getElementById(`${bidRequest.adUnitCode}`);
-
- logInfo(JSON.stringify(payload));
-
- expect(el).to.exist;
- expect(payload.slots[0].cwExt.style.maxWidth).to.eq("400px");
- expect(payload.slots[0].cwExt.style.maxHeight).to.eq("350px");
- });
- afterEach(function () {
- sandbox.restore();
- });
- });
-
- describe("buildRequests reads feature flags", function () {
- beforeEach(function () {
- sandbox.stub(utils, "getParameterByName").callsFake(function () {
- return "feature1,feature2";
- });
- });
-
- it("read from url parameter", function () {
- const bidRequest = deepClone(bidRequests[0]);
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- logInfo(JSON.stringify(payload));
-
- expect(payload.featureFlags).to.exist;
- expect(payload.featureFlags).to.include.members(["feature1", "feature2"]);
- });
- afterEach(function () {
- sandbox.restore();
- });
- });
-
- describe("buildRequests reads cwgroups flag", function () {
- beforeEach(function () {
- sandbox.stub(utils, "getParameterByName").callsFake(function () {
- return "group1,group2";
- });
- });
-
- it("read from url parameter", function () {
- const bidRequest = deepClone(bidRequests[0]);
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- logInfo(JSON.stringify(payload));
-
- expect(payload.refgroups).to.exist;
- expect(payload.refgroups).to.include.members(["group1", "group2"]);
- });
- afterEach(function () {
- sandbox.restore();
- });
- });
-
- describe("buildRequests reads debug flag", function () {
- beforeEach(function () {
- sandbox.stub(utils, "getParameterByName").callsFake(function () {
- return "true";
- });
- });
-
- it("read from url parameter", function () {
- const bidRequest = deepClone(bidRequests[0]);
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- logInfo(JSON.stringify(payload));
-
- expect(payload.debug).to.exist;
- expect(payload.debug).to.equal(true);
- });
- afterEach(function () {
- sandbox.restore();
- });
- });
-
- describe("buildRequests reads cw_id from Localstorage", function () {
- before(function () {
- sandbox.stub(storage, "localStorageIsEnabled").callsFake(() => true);
- sandbox.stub(storage, "setDataInLocalStorage");
- sandbox
- .stub(storage, "getDataFromLocalStorage")
- .callsFake((key) => "taerfagerg");
- });
-
- it("cw_id is set", function () {
- const bidRequest = deepClone(bidRequests[0]);
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- logInfo(JSON.stringify(payload));
-
- expect(payload.cwid).to.exist;
- expect(payload.cwid).to.equal("taerfagerg");
- });
- afterEach(function () {
- sandbox.restore();
- });
- });
-
- describe("buildRequests maps flattens params for legacy compat", function () {
- beforeEach(function () {
- const documentStub = sandbox.stub(document, "getElementById");
- documentStub.withArgs(`${bidRequests[0].adUnitCode}`).returns({
- getBoundingClientRect() {
- return { width: 0, height: 0 };
- },
- });
- });
- it("pageId flattened", function () {
- const bidRequest = deepClone(bidRequests[0]);
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- logInfo(JSON.stringify(payload));
-
- expect(payload.slots[0].pageId).to.exist;
- });
- afterEach(function () {
- sandbox.restore();
- });
- });
-
- describe("pageId and placementId are required params", function () {
- it("invalid request", function () {
- const bidRequest = deepClone(bidRequests[0]);
- delete bidRequest.params;
-
- const valid = spec.isBidRequestValid(bidRequest);
- expect(valid).to.be.false;
- });
-
- it("valid request", function () {
- const bidRequest = deepClone(bidRequests[0]);
- bidRequest.params.pageId = 42;
- bidRequest.params.placementId = 42;
-
- const valid = spec.isBidRequestValid(bidRequest);
- expect(valid).to.be.true;
- });
-
- it("cwcreative must be of type string", function () {
- const bidRequest = deepClone(bidRequests[0]);
- bidRequest.params.pageId = 42;
- bidRequest.params.placementId = 42;
-
- const valid = spec.isBidRequestValid(bidRequest);
- expect(valid).to.be.true;
- });
-
- it("build request adds pageId", function () {
- const bidRequest = deepClone(bidRequests[0]);
-
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.slots[0].pageId).to.exist;
- });
- });
-
- describe("process serverResponse", function () {
- it("html to ad mapping", function () {
- const bidResponse = deepClone(response);
- const bids = spec.interpretResponse(bidResponse, {});
-
- expect(bids[0].ad).to.exist;
- });
- });
-
- describe("add user-syncs", function () {
- it("empty user-syncs if no consent given", function () {
- const userSyncs = spec.getUserSyncs({}, {}, {}, {});
-
- expect(userSyncs).to.be.empty;
- });
- it("empty user-syncs if no syncOption enabled", function () {
- const gdprConsent = {
- vendorData: {
- purpose: {
- consents: 1,
- },
- },
- gdprApplies: false,
- consentString: "testConsentString",
- };
- const userSyncs = spec.getUserSyncs({}, {}, gdprConsent, {});
-
- expect(userSyncs).to.be.empty;
- });
-
- it("user-syncs with enabled pixel option", function () {
- const gdprConsent = {
- vendorData: {
- purpose: {
- consents: 1,
- },
- },
- gdprApplies: false,
- consentString: "testConsentString",
- };
- const synOptions = { pixelEnabled: true, iframeEnabled: true };
- const userSyncs = spec.getUserSyncs(synOptions, {}, gdprConsent, {});
-
- expect(userSyncs[0].type).to.equal("image");
- expect(userSyncs[0].url).to.equal(
- "https://ib.adnxs.com/getuid?https://prebid.cwi.re/v1/cookiesync?xandrId=$UID&gdpr=0&gdpr_consent=testConsentString"
- );
- });
-
- it("user-syncs with enabled iframe option", function () {
- const gdprConsent = {
- vendorData: {
- purpose: {
- consents: {
- 1: true,
- },
- },
- },
- gdprApplies: true,
- consentString: "abc123",
- };
- const synOptions = { iframeEnabled: true };
- const userSyncs = spec.getUserSyncs(synOptions, {}, gdprConsent, {});
-
- expect(userSyncs[0].type).to.equal("iframe");
- expect(userSyncs[0].url).to.equal(
- "https://ib.adnxs.com/getuid?https://prebid.cwi.re/v1/cookiesync?xandrId=$UID&gdpr=1&gdpr_consent=abc123"
- );
- });
- });
-
- describe("buildRequests includes autoplay", function () {
- afterEach(function () {
- sandbox.restore();
- });
-
- it("should include autoplay: true when autoplay is enabled", function () {
- sandbox.stub(autoplayLib, "isAutoplayEnabled").returns(true);
-
- const bidRequest = deepClone(bidRequests[0]);
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.slots[0].params.autoplay).to.equal(true);
- });
-
- it("should include autoplay: false when autoplay is disabled", function () {
- sandbox.stub(autoplayLib, "isAutoplayEnabled").returns(false);
-
- const bidRequest = deepClone(bidRequests[0]);
- const request = spec.buildRequests([bidRequest]);
- const payload = JSON.parse(request.data);
-
- expect(payload.slots[0].params.autoplay).to.equal(false);
- });
- });
-
- describe("buildRequests with floor", function () {
- it("should include floor in params when getFloor is defined", function () {
- const bid = {
- bidId: "123",
- adUnitCode: "test-div",
- mediaTypes: {
- banner: {
- sizes: [[300, 250]],
- },
- },
- params: {
- pageId: 4057,
- placementId: "abc123",
- },
- getFloor: function ({ currency, mediaType, size }) {
- expect(currency).to.equal("USD");
- expect(mediaType).to.equal("*");
- expect(size).to.equal("*");
- return {
- currency: "USD",
- floor: 1.23,
- };
- },
- };
-
- const bidderRequest = {
- refererInfo: {
- page: "https://example.com",
- },
- };
-
- const request = spec.buildRequests([bid], bidderRequest);
-
- const payload = JSON.parse(request.data);
- const slot = payload.slots[0];
-
- expect(slot.params).to.have.property("floor");
- expect(slot.params.floor).to.deep.equal({
- currency: "USD",
- floor: 1.23,
- });
- });
-
- it("should not include floor in params if getFloor is not defined", function () {
- const bid = {
- bidId: "456",
- adUnitCode: "test-div",
- mediaTypes: {
- banner: {
- sizes: [[300, 250]],
- },
- },
- params: {
- pageId: 4057,
- placementId: "abc123",
- },
- // no getFloor
- };
-
- const bidderRequest = {
- refererInfo: {
- page: "https://example.com",
- },
- };
-
- const request = spec.buildRequests([bid], bidderRequest);
- const payload = JSON.parse(request.data);
- const slot = payload.slots[0];
-
- expect(slot.params.floor).to.deep.equal({});
- });
- });
-});
diff --git a/test/spec/modules/dailyhuntBidAdapter_spec.js b/test/spec/modules/dailyhuntBidAdapter_spec.js
deleted file mode 100644
index e42621e7d..000000000
--- a/test/spec/modules/dailyhuntBidAdapter_spec.js
+++ /dev/null
@@ -1,403 +0,0 @@
-import { expect } from 'chai';
-import { spec } from 'modules/dailyhuntBidAdapter.js';
-
-const PROD_PREBID_ENDPOINT_URL = 'https://pbs.dailyhunt.in/openrtb2/auction?partner=dailyhunt';
-const PROD_PREBID_TEST_ENDPOINT_URL = 'https://qa-pbs-van.dailyhunt.in/openrtb2/auction?partner=dailyhunt';
-
-const _encodeURIComponent = function (a) {
- if (!a) { return }
- let b = window.encodeURIComponent(a);
- b = b.replace(/'/g, '%27');
- return b;
-}
-
-describe('DailyhuntAdapter', function () {
- describe('isBidRequestValid', function () {
- const bid = {
- 'bidder': 'dailyhunt',
- 'params': {
- placement_id: 1,
- publisher_id: 1,
- partner_name: 'dailyhunt'
- }
- };
-
- it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should return false when required params are not passed', function () {
- const invalidBid = Object.assign({}, bid);
- delete invalidBid.params;
- invalidBid.params = {};
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
- });
- describe('buildRequests', function() {
- const bidRequests = [
- {
- bidder: 'dailyhunt',
- params: {
- placement_id: 1,
- publisher_id: 1,
- partner_name: 'dailyhunt',
- bidfloor: 0.1,
- device: {
- ip: '47.9.247.217'
- },
- site: {
- cat: ['1', '2', '3']
- }
- },
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
- },
- adUnitCode: 'adunit-code',
- sizes: [[300, 50]],
- bidId: '30b31c1838de1e',
- bidderRequestId: '22edbae2733bf6',
- auctionId: '1d1a030790a475',
- transactionId: '04f2659e-c005-4eb1-a57c-fa93145e3843'
- }
- ];
- const nativeBidRequests = [
- {
- bidder: 'dailyhunt',
- params: {
- placement_id: 1,
- publisher_id: 1,
- partner_name: 'dailyhunt',
- },
- nativeParams: {
- title: {
- required: true,
- len: 80
- },
- image: {
- required: true,
- sizes: [150, 50]
- },
- },
- mediaTypes: {
- native: {
- title: {
- required: true
- },
- }
- },
- adUnitCode: 'adunit-code',
- sizes: [[300, 250], [300, 50]],
- bidId: '30b31c1838de1e',
- bidderRequestId: '22edbae2733bf6',
- auctionId: '1d1a030790a475',
- transactionId: '04f2659e-c005-4eb1-a57c-fa93145e3843'
- }
- ];
- const videoBidRequests = [
- {
- bidder: 'dailyhunt',
- params: {
- placement_id: 1,
- publisher_id: 1,
- partner_name: 'dailyhunt'
- },
- nativeParams: {
- video: {
- context: 'instream'
- }
- },
- mediaTypes: {
- video: {
- context: 'instream'
- }
- },
- adUnitCode: 'adunit-code',
- sizes: [[300, 250], [300, 50]],
- bidId: '30b31c1838de1e',
- bidderRequestId: '22edbae2733bf6',
- auctionId: '1d1a030790a475',
- transactionId: '04f2659e-c005-4eb1-a57c-fa93145e3843'
- }
- ];
- const bidderRequest = {
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- 'bidderCode': 'dailyhunt',
- 'bids': [
- {
- ...bidRequests[0]
- }
- ],
- 'refererInfo': {
- 'referer': 'http://m.dailyhunt.in/'
- }
- };
- const nativeBidderRequest = {
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- 'bidderCode': 'dailyhunt',
- 'bids': [
- {
- ...nativeBidRequests[0]
- }
- ],
- 'refererInfo': {
- 'referer': 'http://m.dailyhunt.in/'
- }
- };
- const videoBidderRequest = {
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- 'bidderCode': 'dailyhunt',
- 'bids': [
- {
- ...videoBidRequests[0]
- }
- ],
- 'refererInfo': {
- 'referer': 'http://m.dailyhunt.in/'
- }
- };
-
- it('sends display bid request to ENDPOINT via POST', function () {
- const request = spec.buildRequests(bidRequests, bidderRequest)[0];
- expect(request.url).to.equal(PROD_PREBID_ENDPOINT_URL);
- expect(request.method).to.equal('POST');
- });
-
- it('sends native bid request to ENDPOINT via POST', function () {
- const request = spec.buildRequests(nativeBidRequests, nativeBidderRequest)[0];
- expect(request.url).to.equal(PROD_PREBID_ENDPOINT_URL);
- expect(request.method).to.equal('POST');
- });
-
- it('sends video bid request to ENDPOINT via POST', function () {
- const request = spec.buildRequests(videoBidRequests, videoBidderRequest)[0];
- expect(request.url).to.equal(PROD_PREBID_ENDPOINT_URL);
- expect(request.method).to.equal('POST');
- });
- });
- describe('interpretResponse', function () {
- const bidResponses = {
- id: 'da32def7-6779-403c-ada7-0b201dbc9744',
- seatbid: [
- {
- bid: [
- {
- id: 'id1',
- impid: 'banner-impid',
- price: 1.4,
- adm: 'adm',
- adid: '66658',
- crid: 'asd5ddbf014cac993.66466212',
- dealid: 'asd5ddbf014cac993.66466212',
- w: 300,
- h: 250,
- nurl: 'winUrl',
- ext: {
- prebid: {
- type: 'banner'
- }
- }
- },
- {
- id: '5caccc1f-94a6-4230-a1f9-6186ee65da99',
- impid: 'video-impid',
- price: 1.4,
- nurl: 'winUrl',
- adm: 'adm',
- adid: '980',
- crid: '2394',
- w: 300,
- h: 250,
- ext: {
- prebid: {
- 'type': 'video'
- },
- bidder: {
- cacheKey: 'cache_key',
- vastUrl: 'vastUrl'
- }
- }
- },
- {
- id: '74973faf-cce7-4eff-abd0-b59b8e91ca87',
- impid: 'native-impid',
- price: 50,
- nurl: 'winUrl',
- adm: '{"native":{"ver":"1.2","assets":[{"id":1,"required":1,"title":{"text":"Discover Amazing Products Today!"}},{"id":2,"required":1,"img":{"type":3,"url":"https://cdn.prod.website-files.com/64aabfa2adf7363205ea0135/67c168c650acb91b6ce4dfdf_%EC%8D%B8%EB%84%A4%EC%9D%BC_EN.webp","w":600,"h":315}},{"id":3,"data":{"label":"CTA","value":"Click Here To Visit Site","type":12}}],"link":{"url":"https://dailyhunt.in/news/india/english/for+you?launch=true&mode=pwa"},"imptrackers":["https://example.com/impression"]}}',
- adid: '968',
- crid: '2370',
- w: 300,
- h: 250,
- ext: {
- prebid: {
- type: 'native'
- },
- bidder: null
- }
- },
- {
- id: '5caccc1f-94a6-4230-a1f9-6186ee65da99',
- impid: 'video-outstream-impid',
- price: 1.4,
- nurl: 'winUrl',
- adm: 'adm',
- adid: '980',
- crid: '2394',
- w: 300,
- h: 250,
- ext: {
- prebid: {
- 'type': 'video'
- },
- bidder: {
- cacheKey: 'cache_key',
- vastUrl: 'vastUrl'
- }
- }
- },
- ],
- seat: 'dailyhunt'
- }
- ],
- ext: {
- responsetimemillis: {
- dailyhunt: 119
- }
- }
- };
-
- it('should get correct bid response', function () {
- const expectedResponse = [
- {
- requestId: '1',
- cpm: 1.4,
- creativeId: 'asd5ddbf014cac993.66466212',
- width: 300,
- height: 250,
- ttl: 360,
- netRevenue: true,
- currency: 'USD',
- ad: 'adm',
- mediaType: 'banner',
- winUrl: 'winUrl',
- adomain: 'dailyhunt'
- },
- {
- requestId: '2',
- cpm: 1.4,
- creativeId: '2394',
- width: 300,
- height: 250,
- ttl: 360,
- netRevenue: true,
- currency: 'USD',
- mediaType: 'video',
- winUrl: 'winUrl',
- adomain: 'dailyhunt',
- videoCacheKey: 'cache_key',
- vastUrl: 'vastUrl',
- },
- {
- requestId: '3',
- cpm: 1.4,
- creativeId: '2370',
- width: 300,
- height: 250,
- ttl: 360,
- netRevenue: true,
- currency: 'USD',
- mediaType: 'native',
- winUrl: 'winUrl',
- adomain: 'dailyhunt',
- native: {
- clickUrl: "https://dailyhunt.in/news/india/english/for+you?launch=true&mode=pwa",
- clickTrackers: [],
- impressionTrackers: ["https://example.com/impression"],
- javascriptTrackers: [],
- title: "Discover Amazing Products Today!",
- cta: "Click Here To Visit Site",
- image: {
- height: 315,
- url: "https://cdn.prod.website-files.com/64aabfa2adf7363205ea0135/67c168c650acb91b6ce4dfdf_%EC%8D%B8%EB%84%A4%EC%9D%BC_EN.webp",
- width: 600,
- },
- }
- },
- {
- requestId: '4',
- cpm: 1.4,
- creativeId: '2394',
- width: 300,
- height: 250,
- ttl: 360,
- netRevenue: true,
- currency: 'USD',
- mediaType: 'video',
- winUrl: 'winUrl',
- adomain: 'dailyhunt',
- vastXml: 'adm',
- },
- ];
- const bidderRequest = {
- bids: [
- {
- bidId: 'banner-impid',
- adUnitCode: 'code1',
- requestId: '1'
- },
- {
- bidId: 'video-impid',
- adUnitCode: 'code2',
- requestId: '2',
- mediaTypes: {
- video: {
- context: 'instream'
- }
- }
- },
- {
- bidId: 'native-impid',
- adUnitCode: 'code3',
- requestId: '3'
- },
- {
- bidId: 'video-outstream-impid',
- adUnitCode: 'code4',
- requestId: '4',
- mediaTypes: {
- video: {
- context: 'outstream'
- }
- }
- },
- ]
- }
- const result = spec.interpretResponse({ body: bidResponses }, bidderRequest);
- result.forEach((r, i) => {
- expect(Object.keys(r)).to.have.members(Object.keys(expectedResponse[i]));
- });
- });
- })
- describe('onBidWon', function () {
- it('should hit win url when bid won', function () {
- const bid = {
- requestId: '1',
- cpm: 1.4,
- creativeId: 'asd5ddbf014cac993.66466212',
- width: 300,
- height: 250,
- ttl: 360,
- netRevenue: true,
- currency: 'USD',
- ad: 'adm',
- mediaType: 'banner',
- winUrl: 'winUrl'
- };
- expect(spec.onBidWon(bid)).to.equal(undefined);
- });
- })
-})
diff --git a/test/spec/modules/dailymotionBidAdapter_spec.js b/test/spec/modules/dailymotionBidAdapter_spec.js
deleted file mode 100644
index d4cafe831..000000000
--- a/test/spec/modules/dailymotionBidAdapter_spec.js
+++ /dev/null
@@ -1,2404 +0,0 @@
-import { config } from 'src/config.js';
-import { expect } from 'chai';
-import { spec } from 'modules/dailymotionBidAdapter.js';
-import { BANNER, VIDEO } from '../../../src/mediaTypes.js';
-
-describe('dailymotionBidAdapterTests', () => {
- // Validate that isBidRequestValid only validates requests with apiKey
- it('validates isBidRequestValid', () => {
- expect(config.runWithBidder('dailymotion', () => spec.isBidRequestValid())).to.be.false;
-
- const bidWithEmptyApi = {
- params: {
- apiKey: '',
- },
- mediaTypes: {
- [VIDEO]: {
- context: 'instream',
- },
- },
- };
-
- expect(config.runWithBidder('dailymotion', () => spec.isBidRequestValid(bidWithEmptyApi))).to.be.false;
-
- const bidWithApi = {
- params: {
- apiKey: 'test_api_key',
- },
- mediaTypes: {
- [VIDEO]: {
- context: 'instream',
- },
- },
- };
-
- expect(config.runWithBidder('dailymotion', () => spec.isBidRequestValid(bidWithApi))).to.be.true;
-
- const bidWithEmptyMediaTypes = {
- params: {
- apiKey: '',
- },
- };
-
- expect(config.runWithBidder('dailymotion', () => spec.isBidRequestValid(bidWithEmptyMediaTypes))).to.be.false;
-
- const bidWithEmptyVideoAdUnit = {
- params: {
- apiKey: '',
- },
- mediaTypes: {
- [VIDEO]: {},
- },
- };
-
- expect(config.runWithBidder('dailymotion', () => spec.isBidRequestValid(bidWithEmptyVideoAdUnit))).to.be.false;
-
- const bidWithBannerMediaType = {
- params: {
- apiKey: 'test_api_key',
- },
- mediaTypes: {
- [BANNER]: {},
- },
- };
-
- expect(config.runWithBidder('dailymotion', () => spec.isBidRequestValid(bidWithBannerMediaType))).to.be.false;
-
- const bidWithOutstreamContext = {
- params: {
- apiKey: 'test_api_key',
- },
- mediaTypes: {
- video: {
- context: 'outstream',
- },
- },
- };
-
- expect(config.runWithBidder('dailymotion', () => spec.isBidRequestValid(bidWithOutstreamContext))).to.be.false;
- });
-
- // Validate request generation
- it('validates buildRequests', () => {
- const bidRequestData = [{
- auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
- bidId: 123456,
- adUnitCode: 'preroll',
- mediaTypes: {
- video: {
- api: [2, 7],
- mimes: ['video/mp4'],
- minduration: 5,
- maxduration: 30,
- playbackmethod: [3],
- plcmt: 1,
- protocols: [1, 2, 3, 4, 5, 6, 7, 8],
- skip: 1,
- skipafter: 5,
- skipmin: 10,
- startdelay: 0,
- w: 1280,
- h: 720,
- },
- },
- sizes: [[1920, 1080]],
- params: {
- apiKey: 'test_api_key',
- dmTs: '123456',
- video: {
- description: 'this is a test video',
- duration: 556,
- iabcat1: ['IAB-1'],
- iabcat2: ['6', '17'],
- id: '54321',
- lang: 'FR',
- private: false,
- tags: 'tag_1,tag_2,tag_3',
- title: 'test video',
- url: 'https://test.com/test',
- topics: 'topic_1, topic_2',
- livestream: 1,
- isCreatedForKids: true,
- videoViewsInSession: 2,
- autoplay: true,
- playerName: 'dailymotion',
- playerVolume: 8,
- },
- },
- }];
-
- const bidderRequestData = {
- refererInfo: {
- page: 'https://publisher.com',
- },
- uspConsent: '1YN-',
- gdprConsent: {
- apiVersion: 2,
- consentString: 'xxx',
- gdprApplies: true,
- },
- gppConsent: {
- gppString: 'xxx',
- applicableSections: [5],
- },
- ortb2: {
- regs: {
- coppa: 1,
- },
- site: {
- content: {
- data: [
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '200' }],
- },
- ],
- },
- },
- },
- };
-
- config.setConfig({
- userSync: {
- syncEnabled: true,
- filterSettings: {
- all: {
- bidders: '*',
- filter: 'include'
- }
- }
- }
- });
-
- const [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- const { data: reqData } = request;
-
- expect(request.options.withCredentials).to.eql(false);
- expect(request.url).to.equal('https://pb.dmxleo.com');
-
- expect(reqData.pbv).to.eql('$prebid.version$');
- expect(reqData.userSyncEnabled).to.be.true;
- expect(reqData.bidder_request).to.eql({
- refererInfo: bidderRequestData.refererInfo,
- uspConsent: bidderRequestData.uspConsent,
- gdprConsent: bidderRequestData.gdprConsent,
- gppConsent: bidderRequestData.gppConsent,
- });
- expect(reqData.config.api_key).to.eql(bidRequestData[0].params.apiKey);
- expect(reqData.config.ts).to.eql(bidRequestData[0].params.dmTs);
- expect(reqData.request.auctionId).to.eql(bidRequestData[0].auctionId);
- expect(reqData.request.bidId).to.eql(bidRequestData[0].bidId);
- expect(reqData.request.mediaTypes.video).to.eql(bidRequestData[0].mediaTypes.video);
- expect(reqData.video_metadata).to.eql({
- description: bidRequestData[0].params.video.description,
- iabcat1: ['IAB-1'],
- iabcat2: bidRequestData[0].params.video.iabcat2,
- id: bidRequestData[0].params.video.id,
- lang: bidRequestData[0].params.video.lang,
- private: bidRequestData[0].params.video.private,
- tags: bidRequestData[0].params.video.tags,
- title: bidRequestData[0].params.video.title,
- url: bidRequestData[0].params.video.url,
- topics: bidRequestData[0].params.video.topics,
- duration: bidRequestData[0].params.video.duration,
- livestream: !!bidRequestData[0].params.video.livestream,
- isCreatedForKids: bidRequestData[0].params.video.isCreatedForKids,
- context: {
- siteOrAppCat: [],
- siteOrAppContentCat: [],
- videoViewsInSession: bidRequestData[0].params.video.videoViewsInSession,
- autoplay: bidRequestData[0].params.video.autoplay,
- playerName: bidRequestData[0].params.video.playerName,
- playerVolume: bidRequestData[0].params.video.playerVolume,
- },
- });
- });
-
- it('validates buildRequests with global consent', () => {
- const bidRequestData = [{
- auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
- bidId: 123456,
- adUnitCode: 'preroll',
- mediaTypes: {
- video: {
- api: [2, 7],
- mimes: ['video/mp4'],
- minduration: 5,
- maxduration: 30,
- playbackmethod: [3],
- plcmt: 1,
- protocols: [1, 2, 3, 4, 5, 6, 7, 8],
- skip: 1,
- skipafter: 5,
- skipmin: 10,
- startdelay: 0,
- w: 1280,
- h: 720,
- },
- },
- sizes: [[1920, 1080]],
- params: {
- apiKey: 'test_api_key',
- video: {
- description: 'this is a test video',
- duration: 556,
- iabcat1: ['IAB-1'],
- iabcat2: ['6', '17'],
- id: '54321',
- lang: 'FR',
- private: false,
- tags: 'tag_1,tag_2,tag_3',
- title: 'test video',
- url: 'https://test.com/test',
- topics: 'topic_1, topic_2',
- livestream: 1,
- isCreatedForKids: true,
- videoViewsInSession: 2,
- autoplay: true,
- playerName: 'dailymotion',
- playerVolume: 8,
- },
- },
- }];
-
- const bidderRequestData = {
- refererInfo: {
- page: 'https://publisher.com',
- },
- uspConsent: '1YN-',
- gdprConsent: {
- apiVersion: 2,
- consentString: 'xxx',
- gdprApplies: true,
- vendorData: {
- hasGlobalConsent: true
- }
- },
- gppConsent: {
- gppString: 'xxx',
- applicableSections: [5],
- },
- ortb2: {
- regs: {
- coppa: 1,
- },
- site: {
- content: {
- data: [
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '200' }],
- },
- ],
- },
- },
- },
- };
-
- const [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- expect(request.options.withCredentials).to.eql(true);
- });
-
- it('validates buildRequests without gdpr applying', () => {
- const bidRequestData = [{
- auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
- bidId: 123456,
- adUnitCode: 'preroll',
- mediaTypes: {
- video: {
- api: [2, 7],
- mimes: ['video/mp4'],
- minduration: 5,
- maxduration: 30,
- playbackmethod: [3],
- plcmt: 1,
- protocols: [1, 2, 3, 4, 5, 6, 7, 8],
- skip: 1,
- skipafter: 5,
- skipmin: 10,
- startdelay: 0,
- w: 1280,
- h: 720,
- },
- },
- sizes: [[1920, 1080]],
- params: {
- apiKey: 'test_api_key',
- video: {
- description: 'this is a test video',
- duration: 556,
- iabcat1: ['IAB-1'],
- iabcat2: ['6', '17'],
- id: '54321',
- lang: 'FR',
- private: false,
- tags: 'tag_1,tag_2,tag_3',
- title: 'test video',
- url: 'https://test.com/test',
- topics: 'topic_1, topic_2',
- livestream: 1,
- isCreatedForKids: true,
- videoViewsInSession: 2,
- autoplay: true,
- playerName: 'dailymotion',
- playerVolume: 8,
- },
- },
- }];
-
- const bidderRequestData = {
- refererInfo: {
- page: 'https://publisher.com',
- },
- uspConsent: '1YN-',
- gdprConsent: {
- apiVersion: 2,
- consentString: 'xxx',
- gdprApplies: false,
- },
- gppConsent: {
- gppString: 'xxx',
- applicableSections: [5],
- },
- ortb2: {
- regs: {
- coppa: 1,
- },
- site: {
- content: {
- data: [
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '200' }],
- },
- ],
- },
- },
- },
- };
-
- const [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- expect(request.options.withCredentials).to.eql(true);
- });
-
- it('validates buildRequests with detailed consent without legitimate interest', () => {
- const bidRequestData = [{
- auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
- bidId: 123456,
- adUnitCode: 'preroll',
- mediaTypes: {
- video: {
- api: [2, 7],
- mimes: ['video/mp4'],
- minduration: 5,
- maxduration: 30,
- playbackmethod: [3],
- plcmt: 1,
- protocols: [1, 2, 3, 4, 5, 6, 7, 8],
- skip: 1,
- skipafter: 5,
- skipmin: 10,
- startdelay: 0,
- w: 1280,
- h: 720,
- },
- },
- sizes: [[1920, 1080]],
- params: {
- apiKey: 'test_api_key',
- video: {
- description: 'this is a test video',
- duration: 556,
- iabcat1: ['IAB-1'],
- iabcat2: ['6', '17'],
- id: '54321',
- lang: 'FR',
- private: false,
- tags: 'tag_1,tag_2,tag_3',
- title: 'test video',
- url: 'https://test.com/test',
- topics: 'topic_1, topic_2',
- livestream: 1,
- isCreatedForKids: true,
- videoViewsInSession: 2,
- autoplay: true,
- playerName: 'dailymotion',
- playerVolume: 8,
- },
- },
- }];
-
- const bidderRequestData = {
- refererInfo: {
- page: 'https://publisher.com',
- },
- uspConsent: '1YN-',
- gdprConsent: {
- apiVersion: 2,
- consentString: 'xxx',
- gdprApplies: true,
- vendorData: {
- hasGlobalConsent: false,
- purpose: {
- consents: {
- 1: true,
- 2: true,
- 3: true,
- 4: true,
- 7: true,
- 9: true,
- 10: true,
- },
- },
- vendor: {
- consents: {
- 573: true
- }
- },
- },
- },
- gppConsent: {
- gppString: 'xxx',
- applicableSections: [5],
- },
- ortb2: {
- regs: {
- coppa: 1,
- },
- site: {
- content: {
- data: [
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '200' }],
- },
- ],
- },
- },
- },
- };
-
- const [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- expect(request.options.withCredentials).to.eql(false);
- });
-
- it('validates buildRequests with detailed consent, with legitimate interest', () => {
- const bidRequestData = [{
- auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
- bidId: 123456,
- adUnitCode: 'preroll',
- mediaTypes: {
- video: {
- api: [2, 7],
- mimes: ['video/mp4'],
- minduration: 5,
- maxduration: 30,
- playbackmethod: [3],
- plcmt: 1,
- protocols: [1, 2, 3, 4, 5, 6, 7, 8],
- skip: 1,
- skipafter: 5,
- skipmin: 10,
- startdelay: 0,
- w: 1280,
- h: 720,
- },
- },
- sizes: [[1920, 1080]],
- params: {
- apiKey: 'test_api_key',
- video: {
- description: 'this is a test video',
- duration: 556,
- iabcat1: ['IAB-1'],
- iabcat2: ['6', '17'],
- id: '54321',
- lang: 'FR',
- private: false,
- tags: 'tag_1,tag_2,tag_3',
- title: 'test video',
- url: 'https://test.com/test',
- topics: 'topic_1, topic_2',
- livestream: 1,
- isCreatedForKids: true,
- videoViewsInSession: 2,
- autoplay: true,
- playerName: 'dailymotion',
- playerVolume: 8,
- },
- },
- }];
-
- const bidderRequestData = {
- refererInfo: {
- page: 'https://publisher.com',
- },
- uspConsent: '1YN-',
- gdprConsent: {
- apiVersion: 2,
- consentString: 'xxx',
- gdprApplies: true,
- vendorData: {
- hasGlobalConsent: false,
- purpose: {
- consents: {
- 1: true,
- 3: true,
- 4: true,
- },
- legitimateInterests: {
- 2: true,
- 7: true,
- 9: true,
- 10: true,
- },
- },
- vendor: {
- consents: {
- 573: true
- }
- },
- },
- },
- gppConsent: {
- gppString: 'xxx',
- applicableSections: [5],
- },
- ortb2: {
- regs: {
- coppa: 1,
- },
- site: {
- content: {
- data: [
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '200' }],
- },
- ],
- },
- },
- },
- };
-
- const [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- expect(request.options.withCredentials).to.eql(true);
- });
-
- it('validates buildRequests with detailed consent and legitimate interest but publisher forces consent', () => {
- const bidRequestData = [{
- auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
- bidId: 123456,
- adUnitCode: 'preroll',
- mediaTypes: {
- video: {
- api: [2, 7],
- mimes: ['video/mp4'],
- minduration: 5,
- maxduration: 30,
- playbackmethod: [3],
- plcmt: 1,
- protocols: [1, 2, 3, 4, 5, 6, 7, 8],
- skip: 1,
- skipafter: 5,
- skipmin: 10,
- startdelay: 0,
- w: 1280,
- h: 720,
- },
- },
- sizes: [[1920, 1080]],
- params: {
- apiKey: 'test_api_key',
- video: {
- description: 'this is a test video',
- duration: 556,
- iabcat1: ['IAB-1'],
- iabcat2: ['6', '17'],
- id: '54321',
- lang: 'FR',
- private: false,
- tags: 'tag_1,tag_2,tag_3',
- title: 'test video',
- url: 'https://test.com/test',
- topics: 'topic_1, topic_2',
- livestream: 1,
- isCreatedForKids: true,
- videoViewsInSession: 2,
- autoplay: true,
- playerName: 'dailymotion',
- playerVolume: 8,
- },
- },
- }];
-
- const bidderRequestData = {
- refererInfo: {
- page: 'https://publisher.com',
- },
- uspConsent: '1YN-',
- gdprConsent: {
- apiVersion: 2,
- consentString: 'xxx',
- gdprApplies: true,
- vendorData: {
- hasGlobalConsent: false,
- publisher: {
- restrictions: {
- 2: { 573: 1 },
- 7: { 573: 1 },
- 9: { 573: 1 },
- 10: { 573: 1 },
- },
- },
- purpose: {
- consents: {
- 1: true,
- 3: true,
- 4: true,
- },
- legitimateInterests: {
- 2: true,
- 7: true,
- 9: true,
- 10: true,
- },
- },
- vendor: {
- consents: {
- 573: true
- }
- },
- },
- },
- gppConsent: {
- gppString: 'xxx',
- applicableSections: [5],
- },
- ortb2: {
- regs: {
- coppa: 1,
- },
- site: {
- content: {
- data: [
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '200' }],
- },
- ],
- },
- },
- },
- };
-
- const [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- expect(request.options.withCredentials).to.eql(false);
- });
-
- it('validates buildRequests with detailed consent, no legitimate interest and publisher forces consent', () => {
- const bidRequestData = [{
- auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
- bidId: 123456,
- adUnitCode: 'preroll',
- mediaTypes: {
- video: {
- api: [2, 7],
- mimes: ['video/mp4'],
- minduration: 5,
- maxduration: 30,
- playbackmethod: [3],
- plcmt: 1,
- protocols: [1, 2, 3, 4, 5, 6, 7, 8],
- skip: 1,
- skipafter: 5,
- skipmin: 10,
- startdelay: 0,
- w: 1280,
- h: 720,
- },
- },
- sizes: [[1920, 1080]],
- params: {
- apiKey: 'test_api_key',
- video: {
- description: 'this is a test video',
- duration: 556,
- iabcat1: ['IAB-1'],
- iabcat2: ['6', '17'],
- id: '54321',
- lang: 'FR',
- private: false,
- tags: 'tag_1,tag_2,tag_3',
- title: 'test video',
- url: 'https://test.com/test',
- topics: 'topic_1, topic_2',
- livestream: 1,
- isCreatedForKids: true,
- videoViewsInSession: 2,
- autoplay: true,
- playerName: 'dailymotion',
- playerVolume: 8,
- },
- },
- }];
-
- const bidderRequestData = {
- refererInfo: {
- page: 'https://publisher.com',
- },
- uspConsent: '1YN-',
- gdprConsent: {
- apiVersion: 2,
- consentString: 'xxx',
- gdprApplies: true,
- vendorData: {
- hasGlobalConsent: false,
- publisher: {
- restrictions: {
- 2: { 573: 1 },
- 7: { 573: 1 },
- 9: { 573: 1 },
- 10: { 573: 1 },
- },
- },
- purpose: {
- consents: {
- 1: true,
- 2: true,
- 3: true,
- 4: true,
- 7: true,
- 9: true,
- 10: true,
- },
- },
- vendor: {
- consents: {
- 573: true
- }
- },
- },
- },
- gppConsent: {
- gppString: 'xxx',
- applicableSections: [5],
- },
- ortb2: {
- regs: {
- coppa: 1,
- },
- site: {
- content: {
- data: [
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '200' }],
- },
- ],
- },
- },
- },
- };
-
- const [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- expect(request.options.withCredentials).to.eql(true);
- });
-
- it('validates buildRequests with detailed consent but publisher full restriction on purpose 1', () => {
- const bidRequestData = [{
- auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
- bidId: 123456,
- adUnitCode: 'preroll',
- mediaTypes: {
- video: {
- api: [2, 7],
- mimes: ['video/mp4'],
- minduration: 5,
- maxduration: 30,
- playbackmethod: [3],
- plcmt: 1,
- protocols: [1, 2, 3, 4, 5, 6, 7, 8],
- skip: 1,
- skipafter: 5,
- skipmin: 10,
- startdelay: 0,
- w: 1280,
- h: 720,
- },
- },
- sizes: [[1920, 1080]],
- params: {
- apiKey: 'test_api_key',
- video: {
- description: 'this is a test video',
- duration: 556,
- iabcat1: ['IAB-1'],
- iabcat2: ['6', '17'],
- id: '54321',
- lang: 'FR',
- private: false,
- tags: 'tag_1,tag_2,tag_3',
- title: 'test video',
- url: 'https://test.com/test',
- topics: 'topic_1, topic_2',
- xid: 'x123456',
- livestream: 1,
- isCreatedForKids: true,
- videoViewsInSession: 2,
- autoplay: true,
- playerVolume: 8,
- },
- },
- }];
-
- const bidderRequestData = {
- refererInfo: {
- page: 'https://publisher.com',
- },
- uspConsent: '1YN-',
- gdprConsent: {
- apiVersion: 2,
- consentString: 'xxx',
- gdprApplies: true,
- vendorData: {
- hasGlobalConsent: false,
- publisher: {
- restrictions: {
- 1: {
- 573: 0,
- },
- },
- },
- purpose: {
- consents: {
- 1: true,
- 2: true,
- 3: true,
- 4: true,
- 7: true,
- 9: true,
- 10: true,
- },
- },
- vendor: {
- consents: {
- 573: true
- }
- },
- },
- },
- gppConsent: {
- gppString: 'xxx',
- applicableSections: [5],
- },
- ortb2: {
- regs: {
- coppa: 1,
- },
- site: {
- content: {
- data: [
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '200' }],
- },
- ],
- },
- },
- },
- };
-
- const [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- expect(request.options.withCredentials).to.eql(false);
- });
-
- it('validates buildRequests with detailed consent but publisher restriction 2 on consent purpose 1', () => {
- const bidRequestData = [{
- auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
- bidId: 123456,
- adUnitCode: 'preroll',
- mediaTypes: {
- video: {
- api: [2, 7],
- mimes: ['video/mp4'],
- minduration: 5,
- maxduration: 30,
- playbackmethod: [3],
- plcmt: 1,
- protocols: [1, 2, 3, 4, 5, 6, 7, 8],
- skip: 1,
- skipafter: 5,
- skipmin: 10,
- startdelay: 0,
- w: 1280,
- h: 720,
- },
- },
- sizes: [[1920, 1080]],
- params: {
- apiKey: 'test_api_key',
- video: {
- description: 'this is a test video',
- duration: 556,
- iabcat1: ['IAB-1'],
- iabcat2: ['6', '17'],
- id: '54321',
- lang: 'FR',
- private: false,
- tags: 'tag_1,tag_2,tag_3',
- title: 'test video',
- url: 'https://test.com/test',
- topics: 'topic_1, topic_2',
- xid: 'x123456',
- livestream: 1,
- isCreatedForKids: true,
- videoViewsInSession: 2,
- autoplay: true,
- playerVolume: 8,
- },
- },
- }];
-
- const bidderRequestData = {
- refererInfo: {
- page: 'https://publisher.com',
- },
- uspConsent: '1YN-',
- gdprConsent: {
- apiVersion: 2,
- consentString: 'xxx',
- gdprApplies: true,
- vendorData: {
- hasGlobalConsent: false,
- publisher: {
- restrictions: {
- 1: {
- 573: 2,
- },
- },
- },
- purpose: {
- consents: {
- 1: true,
- 3: true,
- 4: true,
- },
- legitimateInterests: {
- 2: true,
- 7: true,
- 9: true,
- 10: true,
- },
- },
- vendor: {
- consents: {
- 573: true
- }
- },
- },
- },
- gppConsent: {
- gppString: 'xxx',
- applicableSections: [5],
- },
- ortb2: {
- regs: {
- coppa: 1,
- },
- site: {
- content: {
- data: [
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '200' }],
- },
- ],
- },
- },
- },
- };
-
- const [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- expect(request.options.withCredentials).to.eql(false);
- });
-
- it('validates buildRequests with detailed consent, legitimate interest and publisher restriction on purpose 1', () => {
- const bidRequestData = [{
- auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
- bidId: 123456,
- adUnitCode: 'preroll',
- mediaTypes: {
- video: {
- api: [2, 7],
- mimes: ['video/mp4'],
- minduration: 5,
- maxduration: 30,
- playbackmethod: [3],
- plcmt: 1,
- protocols: [1, 2, 3, 4, 5, 6, 7, 8],
- skip: 1,
- skipafter: 5,
- skipmin: 10,
- startdelay: 0,
- w: 1280,
- h: 720,
- },
- },
- sizes: [[1920, 1080]],
- params: {
- apiKey: 'test_api_key',
- video: {
- description: 'this is a test video',
- duration: 556,
- iabcat1: ['IAB-1'],
- iabcat2: ['6', '17'],
- id: '54321',
- lang: 'FR',
- private: false,
- tags: 'tag_1,tag_2,tag_3',
- title: 'test video',
- url: 'https://test.com/test',
- topics: 'topic_1, topic_2',
- xid: 'x123456',
- livestream: 1,
- isCreatedForKids: true,
- videoViewsInSession: 2,
- autoplay: true,
- playerVolume: 8,
- },
- },
- }];
-
- const bidderRequestData = {
- refererInfo: {
- page: 'https://publisher.com',
- },
- uspConsent: '1YN-',
- gdprConsent: {
- apiVersion: 2,
- consentString: 'xxx',
- gdprApplies: true,
- vendorData: {
- hasGlobalConsent: false,
- publisher: {
- restrictions: {
- 1: {
- 573: 1,
- },
- },
- },
- purpose: {
- consents: {
- 1: true,
- 3: true,
- 4: true,
- },
- legitimateInterests: {
- 2: true,
- 7: true,
- 9: true,
- 10: true,
- },
- },
- vendor: {
- consents: {
- 573: true
- }
- },
- },
- },
- gppConsent: {
- gppString: 'xxx',
- applicableSections: [5],
- },
- ortb2: {
- regs: {
- coppa: 1,
- },
- site: {
- content: {
- data: [
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '200' }],
- },
- ],
- },
- },
- },
- };
-
- const [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- expect(request.options.withCredentials).to.eql(true);
- });
-
- it('validates buildRequests with detailed consent and legitimate interest but publisher restriction on legitimate interest 2', () => {
- const bidRequestData = [{
- auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
- bidId: 123456,
- adUnitCode: 'preroll',
- mediaTypes: {
- video: {
- api: [2, 7],
- mimes: ['video/mp4'],
- minduration: 5,
- maxduration: 30,
- playbackmethod: [3],
- plcmt: 1,
- protocols: [1, 2, 3, 4, 5, 6, 7, 8],
- skip: 1,
- skipafter: 5,
- skipmin: 10,
- startdelay: 0,
- w: 1280,
- h: 720,
- },
- },
- sizes: [[1920, 1080]],
- params: {
- apiKey: 'test_api_key',
- video: {
- description: 'this is a test video',
- duration: 556,
- iabcat1: ['IAB-1'],
- iabcat2: ['6', '17'],
- id: '54321',
- lang: 'FR',
- private: false,
- tags: 'tag_1,tag_2,tag_3',
- title: 'test video',
- url: 'https://test.com/test',
- topics: 'topic_1, topic_2',
- xid: 'x123456',
- livestream: 1,
- isCreatedForKids: true,
- videoViewsInSession: 2,
- autoplay: true,
- playerVolume: 8,
- },
- },
- }];
-
- const bidderRequestData = {
- refererInfo: {
- page: 'https://publisher.com',
- },
- uspConsent: '1YN-',
- gdprConsent: {
- apiVersion: 2,
- consentString: 'xxx',
- gdprApplies: true,
- vendorData: {
- hasGlobalConsent: false,
- publisher: {
- restrictions: {
- 2: {
- 573: 2,
- },
- },
- },
- purpose: {
- consents: {
- 1: true,
- 3: true,
- 4: true,
- },
- legitimateInterests: {
- 2: true,
- 7: true,
- 9: true,
- 10: true,
- },
- },
- vendor: {
- consents: {
- 573: true
- }
- },
- },
- },
- gppConsent: {
- gppString: 'xxx',
- applicableSections: [5],
- },
- ortb2: {
- regs: {
- coppa: 1,
- },
- site: {
- content: {
- data: [
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '200' }],
- },
- ],
- },
- },
- },
- };
-
- const [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- expect(request.options.withCredentials).to.eql(true);
- });
-
- it('validates buildRequests with insufficient consent', () => {
- const bidRequestData = [{
- auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
- bidId: 123456,
- adUnitCode: 'preroll',
- mediaTypes: {
- video: {
- api: [2, 7],
- mimes: ['video/mp4'],
- minduration: 5,
- maxduration: 30,
- playbackmethod: [3],
- plcmt: 1,
- protocols: [1, 2, 3, 4, 5, 6, 7, 8],
- skip: 1,
- skipafter: 5,
- skipmin: 10,
- startdelay: 0,
- w: 1280,
- h: 720,
- },
- },
- sizes: [[1920, 1080]],
- params: {
- apiKey: 'test_api_key',
- video: {
- description: 'this is a test video',
- duration: 556,
- iabcat1: ['IAB-1'],
- iabcat2: ['6', '17'],
- id: '54321',
- lang: 'FR',
- private: false,
- tags: 'tag_1,tag_2,tag_3',
- title: 'test video',
- url: 'https://test.com/test',
- topics: 'topic_1, topic_2',
- livestream: 1,
- isCreatedForKids: true,
- videoViewsInSession: 2,
- autoplay: true,
- playerName: 'dailymotion',
- playerVolume: 8,
- },
- },
- }];
-
- const bidderRequestData = {
- refererInfo: {
- page: 'https://publisher.com',
- },
- uspConsent: '1YN-',
- gdprConsent: {
- apiVersion: 2,
- consentString: 'xxx',
- gdprApplies: true,
- vendorData: {
- hasGlobalConsent: false,
- purpose: {
- consents: {
- 1: true,
- 3: true,
- 4: true,
- },
- },
- vendor: {
- consents: {
- 573: true
- }
- },
- },
- },
- gppConsent: {
- gppString: 'xxx',
- applicableSections: [5],
- },
- ortb2: {
- regs: {
- coppa: 1,
- },
- site: {
- content: {
- data: [
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '200' }],
- },
- ],
- },
- },
- },
- };
-
- const [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- expect(request.options.withCredentials).to.eql(false);
- });
-
- it('validates buildRequests with content values from App', () => {
- const bidRequestData = [{
- getFloor: () => ({ currency: 'USD', floor: 3 }),
- auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
- bidId: 123456,
- adUnitCode: 'preroll',
- mediaTypes: {
- video: {
- api: [2, 7],
- mimes: ['video/mp4'],
- minduration: 5,
- maxduration: 30,
- playbackmethod: [3],
- plcmt: 1,
- protocols: [1, 2, 3, 4, 5, 6, 7, 8],
- skip: 1,
- skipafter: 5,
- skipmin: 10,
- startdelay: 0,
- w: 1280,
- h: 720,
- },
- },
- sizes: [[1920, 1080]],
- params: {
- apiKey: 'test_api_key',
- video: {
- description: 'this is a test video',
- iabcat2: ['6', '17'],
- id: '54321',
- lang: 'FR',
- private: false,
- tags: 'tag_1,tag_2,tag_3',
- title: 'test video',
- url: 'https://test.com/test',
- topics: 'topic_1, topic_2',
- livestream: 1,
- // Test invalid values
- isCreatedForKids: 'false',
- videoViewsInSession: -1,
- autoplay: 'true',
- playerName: 'dailymotion',
- playerVolume: 12,
- },
- },
- }];
-
- const bidderRequestData = {
- timeout: 4242,
- refererInfo: {
- page: 'https://publisher.com',
- },
- uspConsent: '1YN-',
- gdprConsent: {
- apiVersion: 2,
- consentString: 'xxx',
- gdprApplies: true,
- },
- gppConsent: {
- gppString: 'xxx',
- applicableSections: [5],
- },
- ortb2: {
- bcat: ['IAB-1'],
- badv: ['bcav-1'],
- regs: {
- coppa: 1,
- },
- device: {
- lmt: 1,
- ifa: 'xxx',
- devicetype: 2,
- make: 'make',
- model: 'model',
- os: 'os',
- osv: 'osv',
- language: 'language',
- geo: {
- country: 'country',
- region: 'region',
- city: 'city',
- zip: 'zip',
- metro: 'metro'
- },
- ext: {
- atts: 2,
- ifa_type: 'ifa_type'
- },
- },
- app: {
- bundle: 'app-bundle',
- storeurl: 'https://play.google.com/store/apps/details?id=app-bundle',
- content: {
- len: 556,
- cattax: 3,
- data: [
- {
- name: 'dataprovider.com',
- ext: { segtax: 4 },
- segment: [{ id: 'IAB-1' }],
- },
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '200' }],
- },
- ],
- },
- },
- },
- };
-
- config.setConfig({
- userSync: {
- syncEnabled: true,
- filterSettings: {
- iframe: {
- bidders: ['dailymotion'],
- filter: 'include'
- }
- }
- }
- });
-
- const [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- const { data: reqData } = request;
-
- expect(request.url).to.equal('https://pb.dmxleo.com');
-
- expect(reqData.pbv).to.eql('$prebid.version$');
-
- const expectedOrtb = {
- 'app': {
- 'bundle': 'app-bundle',
- 'content': {
- 'cattax': 3,
- 'data': [
- {
- 'ext': {
- 'segtax': 4
- },
- 'name': 'dataprovider.com',
- 'segment': [
- {
- 'id': 'IAB-1'
- }
- ]
- },
- {
- 'ext': {
- 'segtax': 5
- },
- 'name': 'dataprovider.com',
- 'segment': [
- {
- 'id': '200'
- }
- ],
- }
- ],
- 'len': 556,
- },
- 'storeurl': 'https://play.google.com/store/apps/details?id=app-bundle',
- },
- 'badv': [
- 'bcav-1'
- ],
- 'bcat': [
- 'IAB-1'
- ],
- 'device': {
- 'devicetype': 2,
- 'ext': {
- 'atts': 2,
- 'ifa_type': 'ifa_type'
- },
- 'geo': {
- 'city': 'city',
- 'country': 'country',
- 'metro': 'metro',
- 'region': 'region',
- 'zip': 'zip',
- },
- 'ifa': 'xxx',
- 'language': 'language',
- 'lmt': 1,
- 'make': 'make',
- 'model': 'model',
- 'os': 'os',
- 'osv': 'osv',
- },
- 'imp': [{
- 'bidfloor': 3,
- 'bidfloorcur': 'USD',
- 'id': 123456,
- 'secure': 1,
- ...(FEATURES.VIDEO ? {
- 'video': {
- 'api': [
- 2,
- 7
- ],
- 'h': 720,
- 'maxduration': 30,
- 'mimes': [
- 'video/mp4'
- ],
- 'minduration': 5,
- 'playbackmethod': [
- 3
- ],
- 'plcmt': 1,
- 'protocols': [
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8
- ],
- 'skip': 1,
- 'skipafter': 5,
- 'skipmin': 10,
- 'startdelay': 0,
- 'w': 1280,
- }
- } : {}),
- }
- ],
- 'regs': {
- 'coppa': 1,
- },
- 'test': 0,
- 'tmax': 4242,
- }
-
- expect(reqData.ortb.id).to.be.not.empty;
- delete reqData.ortb.id; // ortb id is generated randomly
- expect(reqData.ortb).to.eql(expectedOrtb);
- expect(reqData.userSyncEnabled).to.be.true;
- expect(reqData.bidder_request).to.eql({
- refererInfo: bidderRequestData.refererInfo,
- uspConsent: bidderRequestData.uspConsent,
- gdprConsent: bidderRequestData.gdprConsent,
- gppConsent: bidderRequestData.gppConsent,
- });
- expect(reqData.config.api_key).to.eql(bidRequestData[0].params.apiKey);
- expect(reqData.request.auctionId).to.eql(bidRequestData[0].auctionId);
- expect(reqData.request.bidId).to.eql(bidRequestData[0].bidId);
-
- expect(reqData.request.mediaTypes.video).to.eql(bidRequestData[0].mediaTypes.video);
-
- expect(reqData.video_metadata).to.eql({
- description: bidRequestData[0].params.video.description,
- iabcat1: ['IAB-1'],
- iabcat2: bidRequestData[0].params.video.iabcat2,
- id: bidRequestData[0].params.video.id,
- lang: bidRequestData[0].params.video.lang,
- private: bidRequestData[0].params.video.private,
- tags: bidRequestData[0].params.video.tags,
- title: bidRequestData[0].params.video.title,
- url: bidRequestData[0].params.video.url,
- topics: bidRequestData[0].params.video.topics,
- // Overriden through bidder params
- duration: bidderRequestData.ortb2.app.content.len,
- livestream: !!bidRequestData[0].params.video.livestream,
- isCreatedForKids: null,
- context: {
- siteOrAppCat: [],
- siteOrAppContentCat: [],
- videoViewsInSession: null,
- autoplay: null,
- playerName: 'dailymotion',
- playerVolume: null,
- },
- });
- });
-
- it('validates buildRequests with fallback values on ortb2 (gpp, iabcat2, id...)', () => {
- const bidRequestData = [{
- auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
- bidId: 123456,
- adUnitCode: 'preroll',
- mediaTypes: {
- video: {
- api: [2, 7],
- startdelay: 0,
- },
- },
- sizes: [[1920, 1080]],
- params: {
- apiKey: 'test_api_key',
- video: {
- description: 'this is a test video',
- duration: 556,
- private: false,
- title: 'test video',
- topics: 'topic_1, topic_2',
- isCreatedForKids: false,
- videoViewsInSession: 10,
- autoplay: false,
- playerName: 'dailymotion',
- playerVolume: 0,
- },
- },
- }];
-
- const bidderRequestData = {
- refererInfo: {
- page: 'https://publisher.com',
- },
- uspConsent: '1YN-',
- gdprConsent: {
- apiVersion: 2,
- consentString: 'xxx',
- gdprApplies: true,
- },
- ortb2: {
- tmax: 31416,
- regs: {
- gpp: 'xxx',
- gpp_sid: [5],
- coppa: 0,
- },
- site: {
- cat: ['IAB-1'],
- content: {
- id: '54321',
- language: 'FR',
- keywords: 'tag_1,tag_2,tag_3',
- title: 'test video',
- url: 'https://test.com/test',
- livestream: 1,
- cat: ['IAB-2'],
- cattax: 1,
- data: [
- undefined, // Undefined to check proper handling of edge cases
- {}, // Empty object to check proper handling of edge cases
- { ext: {} }, // Empty ext to check proper handling of edge cases
- {
- name: 'dataprovider.com',
- ext: { segtax: 22 }, // Invalid segtax to check proper handling of edge cases
- segment: [{ id: '400' }],
- },
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: undefined, // Invalid segment to check proper handling of edge cases
- },
- {
- name: 'dataprovider.com',
- ext: { segtax: 4 },
- segment: undefined, // Invalid segment to check proper handling of edge cases
- },
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: 2222 }], // Invalid segment id to check proper handling of edge cases
- },
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '6' }],
- },
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '6' }], // Check that same cat won't be duplicated
- },
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '17' }, { id: '20' }],
- },
- ],
- },
- },
- },
- };
-
- config.setConfig({
- userSync: {
- syncEnabled: true,
- filterSettings: {
- image: {
- bidders: ['dailymotion'],
- filter: 'include'
- },
- iframe: {
- bidders: ['dailymotion'],
- filter: 'exclude',
- },
- }
- }
- });
-
- const [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- const { data: reqData } = request;
-
- expect(request.url).to.equal('https://pb.dmxleo.com');
-
- const expectedOrtb = {
- 'imp': [{
- 'id': 123456,
- 'secure': 1,
- ...(FEATURES.VIDEO ? {
- 'video': {
- 'api': [
- 2,
- 7
- ],
- 'startdelay': 0,
- }
- } : {})
- }
- ],
- 'regs': {
- 'coppa': 0,
- 'gpp': 'xxx',
- 'gpp_sid': [
- 5
- ],
- },
- 'site': {
- 'cat': [
- 'IAB-1',
- ],
- 'content': {
- 'cat': [
- 'IAB-2',
- ],
- 'cattax': 1,
- 'data': [
- undefined,
- {},
- {
- 'ext': {}
- },
- {
- 'ext': {
- 'segtax': 22
- },
- 'name': 'dataprovider.com',
- 'segment': [
- {
- 'id': '400'
- }
- ]
- },
- {
- 'ext': {
- 'segtax': 5
- },
- 'name': 'dataprovider.com',
- 'segment': undefined
- },
- {
- 'ext': {
- 'segtax': 4
- },
- 'name': 'dataprovider.com',
- 'segment': undefined
- },
- {
- 'ext': {
- 'segtax': 5
- },
- 'name': 'dataprovider.com',
- 'segment': [
- {
- 'id': 2222
- }
- ]
- },
- {
- 'ext': {
- 'segtax': 5
- },
- 'name': 'dataprovider.com',
- 'segment': [
- {
- 'id': '6'
- }
- ]
- },
- {
- 'ext': {
- 'segtax': 5
- },
- 'name': 'dataprovider.com',
- 'segment': [
- {
- 'id': '6'
- }
- ]
- },
- {
- 'ext': {
- 'segtax': 5
- },
- 'name': 'dataprovider.com',
- 'segment': [
- {
- 'id': '17'
- },
- {
- 'id': '20'
- }
- ]
- }
- ],
- 'id': '54321',
- 'keywords': 'tag_1,tag_2,tag_3',
- 'language': 'FR',
- 'livestream': 1,
- 'title': 'test video',
- 'url': 'https://test.com/test',
- }
- },
- 'test': 0,
- 'tmax': 31416
- }
-
- expect(reqData.pbv).to.eql('$prebid.version$');
- expect(reqData.ortb.id).to.be.not.empty;
- delete reqData.ortb.id; // ortb id is generated randomly
- expect(reqData.ortb).to.eql(expectedOrtb);
-
- expect(reqData.userSyncEnabled).to.be.true;
- expect(reqData.bidder_request).to.eql({
- refererInfo: bidderRequestData.refererInfo,
- uspConsent: bidderRequestData.uspConsent,
- gdprConsent: bidderRequestData.gdprConsent,
- gppConsent: {
- gppString: bidderRequestData.ortb2.regs.gpp,
- applicableSections: bidderRequestData.ortb2.regs.gpp_sid,
- },
- });
- expect(reqData.config.api_key).to.eql(bidRequestData[0].params.apiKey);
- expect(reqData.request.auctionId).to.eql(bidRequestData[0].auctionId);
- expect(reqData.request.bidId).to.eql(bidRequestData[0].bidId);
-
- expect(reqData.request.mediaTypes.video).to.eql({
- ...bidRequestData[0].mediaTypes.video,
- mimes: [],
- minduration: 0,
- maxduration: 0,
- playbackmethod: [],
- plcmt: undefined,
- protocols: [],
- skip: 0,
- skipafter: 0,
- skipmin: 0,
- w: 0,
- h: 0,
- });
-
- expect(reqData.video_metadata).to.eql({
- description: bidRequestData[0].params.video.description,
- iabcat1: ['IAB-2'],
- iabcat2: ['6', '17', '20'],
- id: bidderRequestData.ortb2.site.content.id,
- lang: bidderRequestData.ortb2.site.content.language,
- private: bidRequestData[0].params.video.private,
- tags: bidderRequestData.ortb2.site.content.keywords,
- title: bidderRequestData.ortb2.site.content.title,
- url: bidderRequestData.ortb2.site.content.url,
- topics: bidRequestData[0].params.video.topics,
- duration: bidRequestData[0].params.video.duration,
- livestream: !!bidderRequestData.ortb2.site.content.livestream,
- isCreatedForKids: bidRequestData[0].params.video.isCreatedForKids,
- context: {
- siteOrAppCat: bidderRequestData.ortb2.site.cat,
- siteOrAppContentCat: bidderRequestData.ortb2.site.content.cat,
- videoViewsInSession: bidRequestData[0].params.video.videoViewsInSession,
- autoplay: bidRequestData[0].params.video.autoplay,
- playerName: bidRequestData[0].params.video.playerName,
- playerVolume: bidRequestData[0].params.video.playerVolume,
- },
- });
- });
-
- it('validates buildRequests - with default values on empty bid & bidder request', () => {
- const bidRequestDataWithApi = [{
- params: {
- apiKey: 'test_api_key',
- },
- }];
-
- config.setConfig({
- userSync: {
- syncEnabled: false,
- }
- });
-
- const [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestDataWithApi, {}),
- );
-
- const { data: reqData } = request;
-
- expect(request.url).to.equal('https://pb.dmxleo.com');
- expect(reqData.config.api_key).to.eql(bidRequestDataWithApi[0].params.apiKey);
- expect(reqData.pbv).to.eql('$prebid.version$');
-
- expect(reqData.ortb.id).to.be.not.empty;
- delete reqData.ortb.id; // ortb id is generated randomly
- expect(reqData.ortb).to.eql({
- 'imp': [
- {
- 'id': undefined,
- 'secure': 1
- },
- ],
- 'test': 0
- });
- expect(reqData.userSyncEnabled).to.be.false;
- expect(reqData.bidder_request).to.eql({
- gdprConsent: {
- apiVersion: 1,
- consentString: '',
- gdprApplies: false,
- },
- refererInfo: {
- page: '',
- },
- uspConsent: '',
- gppConsent: {
- gppString: '',
- applicableSections: [],
- },
- });
-
- expect(reqData.request).to.eql({
- auctionId: '',
- bidId: '',
- adUnitCode: '',
- mediaTypes: {
- video: {
- api: [],
- mimes: [],
- minduration: 0,
- maxduration: 0,
- playbackmethod: [],
- plcmt: undefined,
- protocols: [],
- skip: 0,
- skipafter: 0,
- skipmin: 0,
- startdelay: undefined,
- w: 0,
- h: 0,
- },
- },
- sizes: [],
- });
-
- expect(reqData.video_metadata).to.eql({
- description: '',
- duration: 0,
- iabcat1: [],
- iabcat2: [],
- id: '',
- lang: '',
- private: false,
- tags: '',
- title: '',
- url: '',
- topics: '',
- livestream: false,
- isCreatedForKids: null,
- context: {
- siteOrAppCat: [],
- siteOrAppContentCat: [],
- videoViewsInSession: null,
- autoplay: null,
- playerName: '',
- playerVolume: null,
- },
- });
- });
-
- describe('validates buildRequests for video metadata iabcat1 and iabcat2', () => {
- let bidRequestData;
- let bidderRequestData;
- let request;
-
- beforeEach(() => {
- bidRequestData = [{
- auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
- bidId: 123456,
- adUnitCode: 'preroll',
- mediaTypes: {
- video: {
- api: [2, 7],
- startdelay: 0,
- },
- },
- sizes: [[1920, 1080]],
- params: {
- apiKey: 'test_api_key',
- video: {
- iabcat1: ['video-params-iabcat1'],
- iabcat2: ['video-params-iabcat2'],
- },
- },
- }];
-
- bidderRequestData = {
- timeout: 4242,
- refererInfo: {
- page: 'https://publisher.com',
- },
- ortb2: {
- site: {
- content: {
- data: [
- {
- name: 'dataprovider.com',
- ext: { segtax: 4 },
- segment: [{ id: '1' }],
- },
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '6' }],
- },
- {
- name: 'dataprovider.com',
- ext: { segtax: 5 },
- segment: [{ id: '17' }, { id: '20' }],
- },
- ]
- },
- }
- }
- };
-
- config.setConfig({
- userSync: {
- syncEnabled: true,
- filterSettings: {
- image: {
- bidders: ['dailymotion'],
- filter: 'include'
- },
- iframe: {
- bidders: ['dailymotion'],
- filter: 'exclude',
- },
- },
- },
- });
-
- [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
- });
-
- it('get iabcat1 and iabcat 2 from params video', () => {
- expect(request.data.video_metadata.iabcat1).to.eql(bidRequestData[0].params.video.iabcat1);
- expect(request.data.video_metadata.iabcat2).to.eql(bidRequestData[0].params.video.iabcat2);
- })
-
- it('get iabcat1 from content.cat and iabcat2 from data.segment', () => {
- const iabCatTestsCases = [[], null, {}];
-
- iabCatTestsCases.forEach((iabCat) => {
- bidRequestData[0].params.video.iabcat1 = iabCat;
- bidRequestData[0].params.video.iabcat2 = iabCat;
- bidderRequestData.ortb2.site.content.cat = ['video-content-cat'];
- bidderRequestData.ortb2.site.content.cattax = 1;
-
- [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- expect(request.data.video_metadata.iabcat1).to.eql(bidderRequestData.ortb2.site.content.cat);
- expect(request.data.video_metadata.iabcat2).to.eql(['6', '17', '20']);
- })
- })
-
- it('get iabcat2 from content.cat and iabcat1 from data.segment', () => {
- const iabCatTestsCases = [[], null, {}];
- const cattaxV2 = [2, 5, 6];
-
- cattaxV2.forEach((cattax) => {
- iabCatTestsCases.forEach((iabCat) => {
- bidRequestData[0].params.video.iabcat1 = iabCat;
- bidRequestData[0].params.video.iabcat2 = iabCat;
- bidderRequestData.ortb2.site.content.cat = ['video-content-cat'];
- bidderRequestData.ortb2.site.content.cattax = cattax;
-
- [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- expect(request.data.video_metadata.iabcat1).to.eql(['1']);
- expect(request.data.video_metadata.iabcat2).to.eql(bidderRequestData.ortb2.site.content.cat);
- })
- })
- })
-
- it('get iabcat1 and iabcat2 from data.segmnet', () => {
- const contentCatTestCases = [[], null, {}];
- const cattaxTestCases = [1, 2, 5, 6];
-
- cattaxTestCases.forEach((cattax) => {
- contentCatTestCases.forEach((contentCat) => {
- bidRequestData[0].params.video.iabcat1 = [];
- bidRequestData[0].params.video.iabcat2 = [];
- bidderRequestData.ortb2.site.content.cat = contentCat;
- bidderRequestData.ortb2.site.content.cattax = cattax;
-
- [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequestData, bidderRequestData),
- );
-
- expect(request.data.video_metadata.iabcat1).to.eql(['1']);
- expect(request.data.video_metadata.iabcat2).to.eql(['6', '17', '20']);
- })
- })
- })
- });
-
- it('validates buildRequests - with null floor as object for getFloor function', () => {
- const bidRequest = [{
- params: {
- apiKey: 'test_api_key',
- },
- getFloor: () => null
- }];
-
- config.setConfig({
- userSync: {
- syncEnabled: false,
- }
- });
-
- const [request] = config.runWithBidder(
- 'dailymotion',
- () => spec.buildRequests(bidRequest, {}),
- );
-
- const { data: reqData } = request;
-
- expect(reqData.ortb.id).to.be.not.empty;
- delete reqData.ortb.id; // ortb id is generated randomly
- expect(reqData.ortb).to.eql({
- 'imp': [
- {
- 'id': undefined,
- 'secure': 1
- },
- ],
- 'test': 0
- });
- })
-
- it('validates buildRequests - with empty/undefined validBidRequests', () => {
- expect(spec.buildRequests([], {})).to.have.lengthOf(0);
-
- expect(spec.buildRequests(undefined, {})).to.have.lengthOf(0);
- });
-
- it('validates interpretResponse', () => {
- const serverResponse = {
- body: {
- ad: 'https://fakecacheserver/cache?uuid=1234',
- cacheId: '1234',
- cpm: 20.0,
- creativeId: '5678',
- currency: 'USD',
- dealId: 'deal123',
- nurl: 'https://bid/nurl',
- requestId: 'test_requestid',
- vastUrl: 'https://fakecacheserver/cache?uuid=1234',
- },
- };
-
- const bids = spec.interpretResponse(serverResponse);
- expect(bids).to.have.lengthOf(1);
-
- const [bid] = bids;
- expect(bid).to.eql(serverResponse.body);
- });
-
- it('validates interpretResponse - without bid (no cpm)', () => {
- const serverResponse = {
- body: {
- requestId: 'test_requestid',
- },
- };
-
- const bids = spec.interpretResponse(serverResponse);
- expect(bids).to.have.lengthOf(0);
- });
-
- it('validates interpretResponse - with empty/undefined serverResponse', () => {
- expect(spec.interpretResponse({})).to.have.lengthOf(0);
-
- expect(spec.interpretResponse(undefined)).to.have.lengthOf(0);
- });
-
- it('validates getUserSyncs', () => {
- // Nothing sent in getUserSyncs
- expect(config.runWithBidder('dailymotion', () => spec.getUserSyncs())).to.eql([]);
-
- // No server response
- {
- const responses = [];
- const syncOptions = { iframeEnabled: true, pixelEnabled: true };
-
- expect(config.runWithBidder(
- 'dailymotion',
- () => spec.getUserSyncs(syncOptions, responses),
- )).to.eql([]);
- }
-
- // No permissions
- {
- const responses = [{ body: { userSyncs: [{ url: 'https://usersyncurl.com', type: 'image' }] } }];
- const syncOptions = { iframeEnabled: false, pixelEnabled: false };
-
- expect(config.runWithBidder(
- 'dailymotion',
- () => spec.getUserSyncs(syncOptions, responses),
- )).to.eql([]);
- }
-
- // Has permissions but no userSyncs urls
- {
- const responses = [{}];
- const syncOptions = { iframeEnabled: false, pixelEnabled: true };
-
- expect(config.runWithBidder(
- 'dailymotion',
- () => spec.getUserSyncs(syncOptions, responses),
- )).to.eql([]);
- }
-
- // Return userSyncs urls for pixels
- {
- const responses = [{
- body: {
- userSyncs: [
- { url: 'https://usersyncurl.com', type: 'image' },
- { url: 'https://usersyncurl2.com', type: 'image' },
- { url: 'https://usersyncurl3.com', type: 'iframe' }
- ],
- }
- }];
-
- const syncOptions = { iframeEnabled: false, pixelEnabled: true };
-
- expect(config.runWithBidder(
- 'dailymotion',
- () => spec.getUserSyncs(syncOptions, responses),
- )).to.eql([
- { type: 'image', url: 'https://usersyncurl.com' },
- { type: 'image', url: 'https://usersyncurl2.com' },
- ]);
- }
-
- // Return userSyncs urls for iframes
- {
- const responses = [{
- body: {
- userSyncs: [
- { url: 'https://usersyncurl.com', type: 'image' },
- { url: 'https://usersyncurl2.com', type: 'image' },
- { url: 'https://usersyncurl3.com', type: 'iframe' }
- ],
- }
- }];
-
- const syncOptions = { iframeEnabled: true, pixelEnabled: true };
-
- expect(config.runWithBidder(
- 'dailymotion',
- () => spec.getUserSyncs(syncOptions, responses),
- )).to.eql([
- { type: 'iframe', url: 'https://usersyncurl3.com' },
- ]);
- }
- });
-});
diff --git a/test/spec/modules/datablocksBidAdapter_spec.js b/test/spec/modules/datablocksBidAdapter_spec.js
deleted file mode 100644
index 9e2b311e5..000000000
--- a/test/spec/modules/datablocksBidAdapter_spec.js
+++ /dev/null
@@ -1,533 +0,0 @@
-import { expect } from 'chai';
-import { spec, BotClientTests } from '../../../modules/datablocksBidAdapter.js';
-
-import { getStorageManager } from '../../../src/storageManager.js';
-import {deepClone} from '../../../src/utils.js';
-
-const bid = {
- bidId: '2dd581a2b6281d',
- bidder: 'datablocks',
- bidderRequestId: '145e1d6a7837c9',
- params: {
- source_id: 7560,
- host: 'v5demo.datablocks.net'
- },
- adUnitCode: '/19968336/header-bid-tag-0',
- auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2',
- mediaTypes: {
- banner: {
- sizes: [
- [300, 250]
- ]
- }
- },
- sizes: [
- [300, 250]
- ],
- transactionId: '1ccbee15-f6f6-46ce-8998-58fe5542e8e1'
-};
-
-const bid2 = {
- bidId: '2dd581a2b624324g',
- bidder: 'datablocks',
- bidderRequestId: '145e1d6a7837543',
- params: {
- source_id: 7560,
- host: 'v5demo.datablocks.net'
- },
- adUnitCode: '/19968336/header-bid-tag-0',
- auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2',
- mediaTypes: {
- banner: {
- sizes:
- [728, 90]
- }
- },
- transactionId: '1ccbee15-f6f6-46ce-8998-58fe55425432'
-};
-
-const nativeBid = {
- adUnitCode: '/19968336/header-bid-tag-0',
- auctionId: '160c78a4-f808-410f-b682-d8728f3a79ee',
- bidId: '332045ee374a99',
- bidder: 'datablocks',
- bidderRequestId: '15d9012765e36c',
- mediaTypes: {
- native: {
- title: {
- required: true
- },
- body: {
- required: true
- },
- image: {
- required: true
- }
- }
- },
- nativeParams: {
- title: {
- required: true
- },
- body: {
- required: true,
- data: {
- len: 250
- }
- },
- image: {
- required: true,
- sizes: [728, 90]
- }
- },
- params: {
- source_id: 7560,
- host: 'v5demo.datablocks.net'
- },
- transactionId: '0a4e9788-4def-4b94-bc25-564d7cac99f6'
-}
-
-const bidderRequest = {
- auctionId: '8bfef1be-d3ac-4d18-8859-754c7b4cf017',
- auctionStart: Date.now(),
- biddeCode: 'datablocks',
- bidderRequestId: '10c47a5fc3c41',
- bids: [bid, bid2, nativeBid],
- refererInfo: {
- numIframes: 0,
- reachedTop: true,
- referer: 'https://7560.v5demo.datablocks.net/test',
- stack: ['https://7560.v5demo.datablocks.net/test']
- },
- start: Date.now(),
- timeout: 10000
-};
-
-const res_object = {
- body: {
- 'id': '10c47a5fc3c41',
- 'bidid': '217868445-30021-19053-0',
- 'seatbid': [
- {
- 'id': '22621593137287',
- 'impid': '1',
- 'adm': 'John is great',
- 'adomain': ['medianet.com'],
- 'price': 0.430000,
- 'cid': '2524568',
- 'adid': '0',
- 'crid': '0',
- 'cat': [],
- 'w': 300,
- 'h': 250,
- 'ext': {
- 'type': 'CPM',
- 'mtype': 'banner'
- }
- },
- {
- 'id': '22645215457415',
- 'impid': '2',
- 'adm': 'john is the best',
- 'adomain': ['td.com'],
- 'price': 0.580000,
- 'cid': '2524574',
- 'adid': '0',
- 'crid': '0',
- 'cat': [],
- 'w': 728,
- 'h': 90,
- 'ext': {
- 'type': 'CPM',
- 'mtype': 'banner'
- }
- },
-
- {
- 'id': '22645215457416',
- 'impid': '3',
- 'adm': '{"native":{"ver":"1.2","assets":[{"id":1,"required":1,"title":{"text":"John is amazing"}},{"id":5,"required":1,"data":{"value":"Sponsored by John"}},{"id":3,"required":1,"img":{"url":"https://example.image.com/", "h":"360", "w":"360"}}],"link":{"url":"https://click.example.com/c/264597/?fcid=29699699045816"},"imptrackers":["https://impression.example.com/i/264597/?fcid=29699699045816"]}}',
- 'adomain': ['td.com'],
- 'price': 10.00,
- 'cid': '2524574',
- 'adid': '0',
- 'crid': '0',
- 'cat': [],
- 'ext': {
- 'type': 'CPM',
- 'mtype': 'native'
- }
- }
- ],
- 'cur': 'USD',
- 'ext': {
- 'version': '1.2.93',
- 'buyerid': '1234567',
- 'syncs': [
- {
- 'type': 'iframe',
- 'url': 'https://s.0cf.io'
- },
- {
- 'type': 'image',
- 'url': 'https://us.dblks.net/set_uid/'
- }
- ]
- }
- }
-}
-
-const bid_request = {
- method: 'POST',
- url: 'https://prebid.datablocks.net/openrtb/?sid=2523014',
- options: {
- withCredentials: true
- },
- data: {
- 'id': 'c09c6e47-8bdb-4884-a46d-93165322b368',
- 'imp': [{
- 'id': '1',
- 'tagid': '/19968336/header-bid-tag-0',
- 'placement_id': 0,
- 'secure': true,
- 'banner': {
- 'w': 300,
- 'h': 250,
- 'format': [{
- 'w': 300,
- 'h': 250
- }, {
- 'w': 300,
- 'h': 600
- }]
- }
- }, {
- 'id': '2',
- 'tagid': '/19968336/header-bid-tag-1',
- 'placement_id': 12345,
- 'secure': true,
- 'banner': {
- 'w': 729,
- 'h': 90,
- 'format': [{
- 'w': 729,
- 'h': 90
- }, {
- 'w': 970,
- 'h': 250
- }]
- }
- }, {
- 'id': '3',
- 'tagid': '/19968336/prebid_multiformat_test',
- 'placement_id': 0,
- 'secure': true,
- 'native': {
- 'ver': '1.2',
- 'request': {
- 'assets': [{
- 'required': 1,
- 'id': 1,
- 'title': {}
- }, {
- 'required': 1,
- 'id': 3,
- 'img': {
- 'type': 3
- }
- }, {
- 'required': 1,
- 'id': 5,
- 'data': {
- 'type': 1
- }
- }],
- 'context': 1,
- 'plcmttype': 1,
- 'ver': '1.2'
- }
- }
- }],
- 'site': {
- 'domain': 'test.datablocks.net',
- 'page': 'https://test.datablocks.net/index.html',
- 'schain': {},
- 'ext': {
- 'p_domain': 'https://test.datablocks.net',
- 'rt': true,
- 'frames': 0,
- 'stack': ['https://test.datablocks.net/index.html'],
- 'timeout': 3000
- },
- 'keywords': 'HTML, CSS, JavaScript'
- },
- 'device': {
- 'ip': 'peer',
- 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36',
- 'js': 1,
- 'language': 'en',
- 'buyerid': '1234567',
- 'ext': {
- 'pb_eids': [{
- 'source': 'criteo.com',
- 'uids': [{
- 'id': 'test',
- 'atype': 1
- }]
- }],
- 'syncs': {
- '1000': 'db_4044853',
- '1001': true
- },
- 'coppa': 0,
- 'gdpr': {},
- 'usp': {},
- 'client_info': {
- 'wiw': 2560,
- 'wih': 1281,
- 'saw': 2560,
- 'sah': 1417,
- 'scd': 24,
- 'sw': 2560,
- 'sh': 1440,
- 'whl': 4,
- 'wxo': 0,
- 'wyo': 0,
- 'wpr': 2,
- 'is_bot': false,
- 'is_hid': false,
- 'vs': 'hidden'
- },
- 'fpd': {}
- }
- }
- }
-}
-
-describe('DatablocksAdapter', function() {
- before(() => {
- // stub out queue metric to avoid it polluting the global xhr mock during other tests
- sinon.stub(spec, 'queue_metric').callsFake(() => null);
- });
-
- after(() => {
- spec.queue_metric.restore();
- });
-
- describe('All needed functions are available', function() {
- it(`isBidRequestValid is present and type function`, function () {
- expect(spec.isBidRequestValid).to.exist.and.to.be.a('function')
- });
-
- it(`buildRequests is present and type function`, function () {
- expect(spec.buildRequests).to.exist.and.to.be.a('function')
- });
-
- it(`getUserSyncs is present and type function`, function () {
- expect(spec.getUserSyncs).to.exist.and.to.be.a('function')
- });
-
- it(`onBidWon is present and type function`, function () {
- expect(spec.onBidWon).to.exist.and.to.be.a('function')
- });
-
- it(`onSetTargeting is present and type function`, function () {
- expect(spec.onSetTargeting).to.exist.and.to.be.a('function')
- });
-
- it(`interpretResponse is present and type function`, function () {
- expect(spec.interpretResponse).to.exist.and.to.be.a('function')
- });
-
- it(`store_dbid is present and type function`, function () {
- expect(spec.store_dbid).to.exist.and.to.be.a('function')
- });
-
- it(`get_dbid is present and type function`, function () {
- expect(spec.get_dbid).to.exist.and.to.be.a('function')
- });
-
- it(`store_syncs is present and type function`, function () {
- expect(spec.store_syncs).to.exist.and.to.be.a('function')
- });
-
- it(`get_syncs is present and type function`, function () {
- expect(spec.get_syncs).to.exist.and.to.be.a('function')
- });
-
- it(`queue_metric is present and type function`, function () {
- expect(spec.queue_metric).to.exist.and.to.be.a('function')
- });
-
- it(`send_metrics is present and type function`, function () {
- expect(spec.send_metrics).to.exist.and.to.be.a('function')
- });
-
- it(`get_client_info is present and type function`, function () {
- expect(spec.get_client_info).to.exist.and.to.be.a('function')
- });
-
- it(`get_viewability is present and type function`, function () {
- expect(spec.get_viewability).to.exist.and.to.be.a('function')
- });
- });
-
- describe('get / store dbid', function() {
- it('Should return true / undefined', function() {
- expect(spec.store_dbid('12345')).to.be.true;
- expect(spec.get_dbid()).to.be.a('string');
- });
- })
-
- describe('get / store syncs', function() {
- it('Should return true / array', function() {
- expect(spec.store_syncs([{id: 1, uid: 'test'}])).to.be.true;
- expect(spec.get_syncs()).to.be.a('object');
- });
- })
-
- describe('get_viewability', function() {
- it('Should return undefined', function() {
- expect(spec.get_viewability()).to.equal(undefined);
- });
- })
-
- describe('get client info', function() {
- it('Should return object', function() {
- const client_info = spec.get_client_info()
- expect(client_info).to.be.a('object');
- expect(client_info).to.have.all.keys('wiw', 'wih', 'saw', 'sah', 'scd', 'sw', 'sh', 'whl', 'wxo', 'wyo', 'wpr', 'is_bot', 'is_hid', 'vs');
- });
-
- it('bot test should return boolean', function() {
- const bot_test = new BotClientTests();
- expect(bot_test.doTests()).to.be.a('boolean');
- });
- })
-
- describe('isBidRequestValid', function() {
- it('Should return true when source_id and Host are set', function() {
- expect(spec.isBidRequestValid(bid)).to.be.true;
- });
- it('Should return false when host/source_id is not set', function() {
- const moddedBid = deepClone(bid);
- delete moddedBid.params.source_id;
- expect(spec.isBidRequestValid(moddedBid)).to.be.false;
- });
-
- it('Should return true when viewability reporting is opted out', function() {
- const moddedBid = Object.assign({}, bid);
- moddedBid.params.vis_optout = true;
- spec.isBidRequestValid(moddedBid);
- expect(spec.db_obj.vis_optout).to.be.true;
- });
- })
-
- describe('getUserSyncs', function() {
- it('Should return array of syncs', function() {
- expect(spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [res_object], {gdprApplies: true, gdpr: 1, gdpr_consent: 'consent_string'}, {})).to.be.an('array');
- });
- });
-
- describe('onSetTargeting', function() {
- it('Should return undefined', function() {
- expect(spec.onSetTargeting()).to.equal(undefined);
- });
- });
-
- describe('onBidWon', function() {
- it('Should return undefined', function() {
- const won_bid = {params: [{source_id: 1}], requestId: 1, adUnitCode: 'unit', auctionId: 1, size: '300x250', cpm: 10, adserverTargeting: {hb_pb: 10}, timeToRespond: 10, ttl: 10};
- expect(spec.onBidWon(won_bid)).to.equal(undefined);
- });
- });
-
- describe('buildRequests', function() {
- let request;
- before(() => {
- request = spec.buildRequests([bid, bid2, nativeBid], bidderRequest);
- expect(request).to.exist;
- })
-
- it('Returns POST method', function() {
- expect(request.method).to.exist;
- expect(request.method).to.equal('POST');
- });
-
- it('Returns valid URL', function() {
- expect(request.url).to.exist;
- expect(request.url).to.equal('https://v5demo.datablocks.net/openrtb/?sid=7560');
- });
-
- it('Creates an array of request objects', function() {
- expect(request.data.imp).to.be.an('array').that.is.not.empty;
- });
-
- it('Should be a valid openRTB request', function() {
- const data = request.data;
-
- expect(data).to.be.an('object');
- expect(data).to.have.all.keys('device', 'imp', 'site', 'id');
- expect(data.id).to.be.a('string');
- expect(data.imp).to.be.a('array');
- expect(data.device.ip).to.equal('peer');
-
- const imps = data['imp'];
- imps.forEach((imp, index) => {
- const curBid = bidderRequest.bids[index];
- if (imp.banner) {
- expect(imp.banner).to.be.a('object');
- expect(imp).to.have.all.keys('banner', 'id', 'secure', 'tagid', 'placement_id', 'ortb2', 'floor');
- } else if (imp.native) {
- expect(imp).to.have.all.keys('native', 'id', 'secure', 'tagid', 'placement_id', 'ortb2', 'floor');
- expect(imp.native).to.have.all.keys('request', 'ver');
- expect(imp.native.request).to.be.a('object');
- } else {
- expect(true).to.equal(false);
- }
-
- expect(imp.id).to.be.a('string');
- expect(imp.id).to.equal(curBid.bidId);
- expect(imp.tagid).to.be.a('string');
- expect(imp.tagid).to.equal(curBid.adUnitCode);
- expect(imp.secure).to.equal(false);
- })
- });
-
- it('Returns empty data if no valid requests are passed', function() {
- const test_request = spec.buildRequests([]);
- expect(test_request).to.be.an('array').that.is.empty;
- });
- });
-
- describe('interpretResponse', function() {
- const response = spec.interpretResponse(res_object, bid_request);
-
- it('Returns an array of valid server responses if response object is valid', function() {
- expect(response).to.be.an('array').that.is.not.empty;
-
- response.forEach(bid => {
- expect(parseInt(bid.requestId)).to.be.a('number').greaterThan(0);
- expect(bid.cpm).to.be.a('number');
- expect(bid.creativeId).to.be.a('string');
- expect(bid.currency).to.be.a('string');
- expect(bid.netRevenue).to.be.a('boolean');
- expect(bid.ttl).to.be.a('number');
- expect(bid.mediaType).to.be.a('string');
-
- if (bid.mediaType === 'banner') {
- expect(bid.width).to.be.a('number');
- expect(bid.height).to.be.a('number');
- expect(bid.ad).to.be.a('string');
- } else if (bid.mediaType === 'native') {
- expect(bid.native).to.be.a('object');
- }
- })
-
- it('Returns an empty array if invalid response is passed', function() {
- serverResponses = spec.interpretResponse('invalid_response');
- expect(serverResponses).to.be.an('array').that.is.empty;
- });
- });
- });
-});
diff --git a/test/spec/modules/datawrkzAnalyticsAdapter_spec.js b/test/spec/modules/datawrkzAnalyticsAdapter_spec.js
deleted file mode 100644
index 630c189a1..000000000
--- a/test/spec/modules/datawrkzAnalyticsAdapter_spec.js
+++ /dev/null
@@ -1,178 +0,0 @@
-import analyticsAdapter from "modules/datawrkzAnalyticsAdapter.js";
-import adapterManager from "src/adapterManager.js";
-import { EVENTS } from "src/constants.js";
-
-const {
- AUCTION_INIT,
- BID_REQUESTED,
- BID_RESPONSE,
- BID_TIMEOUT,
- BID_WON,
- AUCTION_END,
- AD_RENDER_SUCCEEDED,
- AD_RENDER_FAILED
-} = EVENTS;
-
-describe("DatawrkzAnalyticsAdapter", function () {
- let sandbox;
- let fetchStub;
-
- const auctionId = "auction_123";
- const adUnitCode = "div-gpt-ad-001";
- const bidder = "appnexus";
-
- beforeEach(function () {
- sandbox = sinon.createSandbox();
- fetchStub = sandbox.stub(window, "fetch");
-
- adapterManager.enableAnalytics({ provider: "datawrkzanalytics" });
- });
-
- afterEach(function () {
- sandbox.restore();
- analyticsAdapter.disableAnalytics();
- });
-
- it("should track AUCTION_INIT", function () {
- analyticsAdapter.track({ eventType: AUCTION_INIT, args: { auctionId } });
- });
-
- it("should track BID_REQUESTED", function () {
- analyticsAdapter.track({ eventType: AUCTION_INIT, args: { auctionId } });
-
- analyticsAdapter.track({
- eventType: BID_REQUESTED,
- args: { auctionId, bids: [{ adUnitCode, bidder }] },
- });
- });
-
- it("should track BID_RESPONSE", function () {
- analyticsAdapter.track({ eventType: AUCTION_INIT, args: { auctionId } });
-
- analyticsAdapter.track({
- eventType: BID_REQUESTED,
- args: { auctionId, bids: [{ adUnitCode, bidder }] },
- });
-
- analyticsAdapter.track({
- eventType: BID_RESPONSE,
- args: {
- auctionId,
- adUnitCode,
- bidder,
- cpm: 1.2,
- currency: "USD",
- timeToRespond: 120,
- },
- });
- });
-
- it("should track BID_TIMEOUT", function () {
- analyticsAdapter.track({ eventType: AUCTION_INIT, args: { auctionId } });
-
- analyticsAdapter.track({
- eventType: BID_REQUESTED,
- args: { auctionId, bids: [{ adUnitCode, bidder }] },
- });
-
- analyticsAdapter.track({
- eventType: BID_TIMEOUT,
- args: { auctionId, adUnitCode, bidder },
- });
- });
-
- it("should track BID_WON", function () {
- analyticsAdapter.track({ eventType: AUCTION_INIT, args: { auctionId } });
-
- analyticsAdapter.track({
- eventType: BID_REQUESTED,
- args: { auctionId, bids: [{ adUnitCode, bidder }] },
- });
-
- analyticsAdapter.track({
- eventType: BID_WON,
- args: { auctionId, adUnitCode, bidder, cpm: 2.5 },
- });
- });
-
- it("should send data on AUCTION_END", function () {
- const clock = sinon.useFakeTimers();
-
- analyticsAdapter.track({ eventType: AUCTION_INIT, args: { auctionId } });
- analyticsAdapter.track({
- eventType: BID_REQUESTED,
- args: { auctionId, bids: [{ adUnitCode, bidder }] },
- });
- analyticsAdapter.track({
- eventType: BID_RESPONSE,
- args: {
- auctionId,
- adUnitCode,
- bidder,
- cpm: 1.5,
- currency: "USD",
- timeToRespond: 300,
- },
- });
- analyticsAdapter.track({ eventType: AUCTION_END, args: { auctionId } });
-
- clock.tick(2000); // Fast-forward time by 2 seconds
-
- sinon.assert.calledOnce(fetchStub);
-
- const [url, options] = fetchStub.firstCall.args;
- expect(url).to.equal("https://prebid-api.highr.ai/analytics");
- expect(options.method).to.equal("POST");
- expect(options.headers["Content-Type"]).to.equal("application/json");
-
- const body = JSON.parse(options.body);
- expect(body.auctionId).to.equal(auctionId);
- expect(body.adunits[0].code).to.equal(adUnitCode);
- expect(body.adunits[0].bids[0].bidder).to.equal(bidder);
-
- clock.restore();
- });
-
- it("should send AD_RENDER_SUCCEEDED event", function () {
- analyticsAdapter.track({
- eventType: AD_RENDER_SUCCEEDED,
- args: {
- bid: { adId: "ad123", bidderCode: bidder, cpm: 2.0 },
- adId: "ad123",
- doc: ""
- }
- });
-
- sinon.assert.calledOnce(fetchStub);
- const [url, options] = fetchStub.firstCall.args;
- const payload = JSON.parse(options.body);
-
- expect(payload.eventType).to.equal(AD_RENDER_SUCCEEDED);
- expect(payload.bidderCode).to.equal("appnexus");
- expect(payload.successDoc).to.be.a("string");
- expect(payload.failureReason).to.be.null;
- expect(payload.failureMessage).to.be.null;
- });
-
- it("should send AD_RENDER_FAILED event", function () {
- analyticsAdapter.track({
- eventType: AD_RENDER_FAILED,
- args: {
- bid: { adId: "ad124", bidderCode: bidder, cpm: 1.5 },
- adId: "ad124",
- reason: "network",
- message: "Render failed due to network error"
- }
- });
-
- sinon.assert.calledOnce(fetchStub);
- const [url, options] = fetchStub.firstCall.args;
- const payload = JSON.parse(options.body);
-
- expect(payload.eventType).to.equal(AD_RENDER_FAILED);
- expect(payload.bidderCode).to.equal("appnexus");
- expect(payload.successDoc).to.be.null;
- expect(payload.failureReason).to.equal("network");
- expect(payload.failureMessage).to.equal("Render failed due to network error");
- });
-});
diff --git a/test/spec/modules/datawrkzBidAdapter_spec.js b/test/spec/modules/datawrkzBidAdapter_spec.js
deleted file mode 100644
index ad513c20b..000000000
--- a/test/spec/modules/datawrkzBidAdapter_spec.js
+++ /dev/null
@@ -1,652 +0,0 @@
-import { expect } from 'chai';
-import { config } from 'src/config.js';
-import { spec } from 'modules/datawrkzBidAdapter.js';
-import { newBidder } from 'src/adapters/bidderFactory.js';
-
-const BIDDER_CODE = 'datawrkz';
-const ENDPOINT_URL = 'https://at.datawrkz.com/exchange/openrtb23/';
-const SITE_ID = 'site_id';
-const FINAL_URL = ENDPOINT_URL + SITE_ID + '?hb=1';
-
-describe('datawrkzAdapterTests', function () {
- const adapter = newBidder(spec);
-
- describe('inherited functions', function () {
- it('exists and is a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function');
- });
- });
-
- describe('isBidRequestValid', function () {
- const bid = {
- 'bidder': BIDDER_CODE,
- 'params': {
- 'site_id': SITE_ID,
- 'bidfloor': '1.0'
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [[300, 250], [300, 600]],
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- };
-
- it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(bid)).to.equal(true);
- });
-
- it('should return false when params not found', function () {
- const invalidBid = Object.assign({}, bid);
- delete invalidBid.params;
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
-
- it('should return false when required site_id param not found', function () {
- const invalidBid = Object.assign({}, bid);
- invalidBid.params = {'bidfloor': '1.0'}
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
-
- it('should return false when adunit is adpod video', function () {
- const invalidBid = Object.assign({}, bid);
- invalidBid.params = {'bidfloor': '1.0', 'site_id': SITE_ID};
- invalidBid.mediaTypes = {
- 'video': {
- 'context': 'adpod'
- }
- }
- expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
- });
- });
-
- describe('buildRequests', function () {
- const consentString = '1YA-';
- const bidderRequest = {
- 'bidderCode': 'datawrkz',
- 'auctionId': '1d1a030790a475',
- 'bidderRequestId': '22edbae2733bf6',
- 'timeout': 3000,
- 'uspConsent': consentString,
- 'gdprConsent': {'gdprApplies': true},
- };
- const bannerBidRequests = [{
- 'bidder': BIDDER_CODE,
- 'params': {'site_id': SITE_ID, 'bidfloor': 1.00},
- 'mediaTypes': {'banner': {'sizes': [[300, 250], [300, 600]]}},
- 'adUnitCode': 'adUnitCode',
- 'transactionId': 'transactionId',
- 'sizes': [[300, 250], [300, 600]],
- 'bidId': 'bidId',
- 'bidderRequestId': 'bidderRequestId',
- 'auctionId': 'auctionId',
- }];
- const bannerBidRequestsSingleArraySlotAndDeals = [{
- 'bidder': BIDDER_CODE,
- 'params': {'site_id': SITE_ID, 'bidfloor': 1.00, 'deals': [{id: 'deal_1'}, {id: 'deal_2'}]},
- 'mediaTypes': {'banner': {}},
- 'adUnitCode': 'adUnitCode',
- 'transactionId': 'transactionId',
- 'sizes': [300, 250],
- 'bidId': 'bidId',
- 'bidderRequestId': 'bidderRequestId',
- 'auctionId': 'auctionId',
- }];
- const nativeBidRequests = [{
- 'bidder': BIDDER_CODE,
- 'params': {'site_id': SITE_ID, 'bidfloor': 1.00},
- 'mediaTypes': {'native': {
- 'title': {'required': true, 'len': 80},
- 'image': {'required': true, 'sizes': [[300, 250]]},
- 'icon': {'required': true, 'sizes': [[50, 50]]},
- 'sponsoredBy': {'required': true},
- 'cta': {'required': true},
- 'body': {'required': true, 'len': 100}
- }},
- 'adUnitCode': 'adUnitCode',
- 'transactionId': 'transactionId',
- 'bidId': 'bidId',
- 'bidderRequestId': 'bidderRequestId',
- 'auctionId': 'auctionId',
- }];
- const nativeBidRequestsSingleArraySlotAndDeals = [{
- 'bidder': BIDDER_CODE,
- 'params': {'site_id': SITE_ID, 'bidfloor': 1.00, 'deals': [{id: 'deal_1'}, {id: 'deal_2'}]},
- 'mediaTypes': {'native': {
- 'title': {'len': 80},
- 'image': {'sizes': [300, 250]},
- 'icon': {'sizes': [50, 50]},
- 'sponsoredBy': {},
- 'cta': {},
- 'body': {'len': 100}
- }},
- 'adUnitCode': 'adUnitCode',
- 'transactionId': 'transactionId',
- 'bidId': 'bidId',
- 'bidderRequestId': 'bidderRequestId',
- 'auctionId': 'auctionId',
- }];
- const instreamVideoBidRequests = [{
- 'bidder': BIDDER_CODE,
- 'params': {'site_id': SITE_ID, 'bidfloor': 1.00},
- 'mediaTypes': {'video': {'context': 'instream', 'playerSize': [[640, 480]]}},
- 'adUnitCode': 'adUnitCode',
- 'transactionId': 'transactionId',
- 'bidId': 'bidId',
- 'bidderRequestId': 'bidderRequestId',
- 'auctionId': 'auctionId',
- }];
- const instreamVideoBidRequestsSingleArraySlotAndDeals = [{
- 'bidder': BIDDER_CODE,
- 'params': {'site_id': SITE_ID, 'bidfloor': 1.00, 'deals': [{id: 'deal_1'}, {id: 'deal_2'}]},
- 'mediaTypes': {'video': {'context': 'instream', 'playerSize': [640, 480]}},
- 'adUnitCode': 'adUnitCode',
- 'transactionId': 'transactionId',
- 'bidId': 'bidId',
- 'bidderRequestId': 'bidderRequestId',
- 'auctionId': 'auctionId',
- }];
- const outstreamVideoBidRequests = [{
- 'bidder': BIDDER_CODE,
- 'params': {'site_id': SITE_ID, 'bidfloor': 1.00},
- 'mediaTypes': {'video': {'context': 'outstream', 'playerSize': [[640, 480]], 'mimes': ['video/mp4', 'video/x-flv']}},
- 'adUnitCode': 'adUnitCode',
- 'transactionId': 'transactionId',
- 'bidId': 'bidId',
- 'bidderRequestId': 'bidderRequestId',
- 'auctionId': 'auctionId',
- }];
- const outstreamVideoBidRequestsSingleArraySlotAndDeals = [{
- 'bidder': BIDDER_CODE,
- 'params': {'site_id': SITE_ID, 'bidfloor': 1.00, 'deals': [{id: 'deal_1'}, {id: 'deal_2'}]},
- 'mediaTypes': {'video': {'context': 'outstream', 'playerSize': [640, 480], 'mimes': ['video/mp4', 'video/x-flv']}},
- 'adUnitCode': 'adUnitCode',
- 'transactionId': 'transactionId',
- 'bidId': 'bidId',
- 'bidderRequestId': 'bidderRequestId',
- 'auctionId': 'auctionId',
- }];
- const bidRequestsWithNoMediaType = [{
- 'bidder': BIDDER_CODE,
- 'params': {'site_id': SITE_ID, 'bidfloor': 1.00},
- 'adUnitCode': 'adUnitCode',
- 'transactionId': 'transactionId',
- 'bidId': 'bidId',
- 'bidderRequestId': 'bidderRequestId',
- 'auctionId': 'auctionId',
- }];
-
- it('empty bid requests', function () {
- const requests = spec.buildRequests([], bidderRequest);
- assert.lengthOf(requests, 0);
- });
-
- it('mediaTypes missing in bid request', function () {
- const requests = spec.buildRequests(bidRequestsWithNoMediaType, bidderRequest);
- assert.lengthOf(requests, 0);
- });
-
- it('invalid media type in bid request', function () {
- bidRequestsWithNoMediaType[0].mediaTypes = {'test': {}};
- const requests = spec.buildRequests(bidRequestsWithNoMediaType, bidderRequest);
- assert.lengthOf(requests, 0);
- });
-
- it('size missing in bid request for banner', function () {
- delete bidRequestsWithNoMediaType[0].mediaTypes.test;
- bidRequestsWithNoMediaType[0].mediaTypes.banner = {};
- const requests = spec.buildRequests(bidRequestsWithNoMediaType, bidderRequest);
- assert.lengthOf(requests, 0);
- });
-
- it('size array empty in bid request for banner', function () {
- bidRequestsWithNoMediaType[0].mediaTypes.banner.sizes = [];
- const requests = spec.buildRequests(bidRequestsWithNoMediaType, bidderRequest);
- assert.lengthOf(requests, 0);
- });
-
- it('banner bidRequest with slot size as 2 dimensional array', function () {
- sinon.stub(config, 'getConfig').withArgs('coppa').returns(true);
- const requests = spec.buildRequests(bannerBidRequests, bidderRequest);
- config.getConfig.restore();
- const payload = JSON.parse(requests[0].data);
- expect(requests[0].method).to.equal('POST');
- expect(requests[0].url).to.equal(FINAL_URL);
- expect(payload.imp).to.exist;
- expect(payload).to.nested.include({'imp[0].banner.w': 300});
- expect(payload).to.nested.include({'imp[0].banner.h': 250});
- expect(payload).to.nested.include({'regs.ext.us_privacy': consentString});
- expect(payload).to.nested.include({'regs.ext.gdpr': '1'});
- expect(payload).to.nested.include({'regs.coppa': '1'});
- expect(requests[0].bidRequest).to.exist;
- expect(requests[0].bidRequest.requestedMediaType).to.equal('banner');
- });
-
- it('banner bidRequest with deals and slot size as 1 dimensional array', function () {
- const requests = spec.buildRequests(bannerBidRequestsSingleArraySlotAndDeals, bidderRequest);
- const payload = JSON.parse(requests[0].data);
- expect(requests[0].method).to.equal('POST');
- expect(requests[0].url).to.equal(FINAL_URL);
- expect(payload.imp).to.exist;
- expect(payload).to.nested.include({'imp[0].banner.w': 300});
- expect(payload).to.nested.include({'imp[0].banner.h': 250});
- expect(payload).to.nested.include({'imp[0].pmp.deals[0].id': 'deal_1'});
- expect(payload).to.nested.include({'imp[0].pmp.deals[1].id': 'deal_2'});
- expect(requests[0].bidRequest).to.exist;
- expect(requests[0].bidRequest.requestedMediaType).to.equal('banner');
- });
-
- it('native bidRequest fields with slot size as 2 dimensional array', function () {
- sinon.stub(config, 'getConfig').withArgs('coppa').returns(true);
- const requests = spec.buildRequests(nativeBidRequests, bidderRequest);
- config.getConfig.restore();
- const payload = JSON.parse(requests[0].data);
- expect(requests[0].method).to.equal('POST');
- expect(requests[0].url).to.equal(FINAL_URL);
- expect(payload.imp[0].native.request).to.exist;
- expect(payload).to.nested.include({'regs.ext.us_privacy': consentString});
- expect(payload).to.nested.include({'regs.ext.gdpr': '1'});
- expect(payload).to.nested.include({'regs.coppa': '1'});
- expect(requests[0].bidRequest).to.exist;
- expect(requests[0].bidRequest.requestedMediaType).to.equal('native');
- });
-
- it('native bidRequest fields with deals and slot size as 1 dimensional array', function () {
- const requests = spec.buildRequests(nativeBidRequestsSingleArraySlotAndDeals, bidderRequest);
- const payload = JSON.parse(requests[0].data);
- expect(requests[0].method).to.equal('POST');
- expect(requests[0].url).to.equal(FINAL_URL);
- expect(payload.imp).to.exist;
- expect(payload.imp[0].native.request).to.exist;
- expect(payload).to.nested.include({'imp[0].pmp.deals[0].id': 'deal_1'});
- expect(payload).to.nested.include({'imp[0].pmp.deals[1].id': 'deal_2'});
- expect(requests[0].bidRequest).to.exist;
- expect(requests[0].bidRequest.requestedMediaType).to.equal('native');
- });
-
- it('instream video bidRequest fields with slot size as 2 dimensional array', function () {
- sinon.stub(config, 'getConfig').withArgs('coppa').returns(true);
- const requests = spec.buildRequests(instreamVideoBidRequests, bidderRequest);
- config.getConfig.restore();
- const payload = JSON.parse(requests[0].data);
- expect(requests[0].method).to.equal('POST');
- expect(requests[0].url).to.equal(FINAL_URL);
- expect(payload).to.nested.include({'regs.ext.us_privacy': consentString});
- expect(payload).to.nested.include({'regs.ext.gdpr': '1'});
- expect(payload).to.nested.include({'regs.coppa': '1'});
- expect(requests[0].bidRequest).to.exist;
- expect(requests[0].bidRequest.requestedMediaType).to.equal('video');
- });
-
- it('instream video bidRequest with deals and slot size as 1 dimensional array', function () {
- const requests = spec.buildRequests(instreamVideoBidRequestsSingleArraySlotAndDeals, bidderRequest);
- const payload = JSON.parse(requests[0].data);
- expect(requests[0].method).to.equal('POST');
- expect(requests[0].url).to.equal(FINAL_URL);
- expect(requests[0].bidRequest).to.exist;
- expect(requests[0].bidRequest.requestedMediaType).to.equal('video');
- });
-
- it('outstream video bidRequest fields with slot size as 2 dimensional array', function () {
- sinon.stub(config, 'getConfig').withArgs('coppa').returns(true);
- const requests = spec.buildRequests(outstreamVideoBidRequests, bidderRequest);
- config.getConfig.restore();
- const payload = JSON.parse(requests[0].data);
- expect(requests[0].method).to.equal('POST');
- expect(requests[0].url).to.equal(FINAL_URL);
- expect(payload).to.nested.include({'imp[0].video.w': 640});
- expect(payload).to.nested.include({'imp[0].video.h': 480});
- expect(payload).to.nested.include({'regs.ext.us_privacy': consentString});
- expect(payload).to.nested.include({'regs.ext.gdpr': '1'});
- expect(payload).to.nested.include({'regs.coppa': '1'});
- expect(requests[0].bidRequest).to.exist;
- expect(requests[0].bidRequest.requestedMediaType).to.equal('video');
- });
-
- it('outstream video bidRequest fields with deals and slot size as 1 dimensional array', function () {
- const requests = spec.buildRequests(outstreamVideoBidRequestsSingleArraySlotAndDeals, bidderRequest);
- const payload = JSON.parse(requests[0].data);
- expect(requests[0].method).to.equal('POST');
- expect(requests[0].url).to.equal(FINAL_URL);
- expect(payload).to.nested.include({'imp[0].video.w': 640});
- expect(payload).to.nested.include({'imp[0].video.h': 480});
- expect(payload).to.nested.include({'imp[0].pmp.deals[0].id': 'deal_1'});
- expect(payload).to.nested.include({'imp[0].pmp.deals[1].id': 'deal_2'});
- expect(requests[0].bidRequest).to.exist;
- expect(requests[0].bidRequest.requestedMediaType).to.equal('video');
- });
- });
-
- describe('interpretResponse', function () {
- const bidRequest = {
- 'bidder': BIDDER_CODE,
- 'params': {'site_id': SITE_ID, 'bidfloor': 1.00},
- 'mediaTypes': {'banner': {'sizes': [[300, 250], [300, 600]]}},
- 'adUnitCode': 'adUnitCode',
- 'transactionId': 'transactionId',
- 'sizes': [[300, 250], [300, 600]],
- 'bidId': 'bidId',
- 'bidderRequestId': 'bidderRequestId',
- 'auctionId': 'auctionId',
- 'requestedMediaType': 'banner'
- };
- const nativeBidRequest = {
- 'bidder': BIDDER_CODE,
- 'params': {'site_id': SITE_ID, 'bidfloor': 1.00},
- 'mediaTypes': {'native': {
- 'title': {'required': true, 'len': 80},
- 'image': {'required': true, 'sizes': [300, 250]},
- 'icon': {'required': true, 'sizes': [50, 50]},
- 'sponsoredBy': {'required': true},
- 'cta': {'required': true},
- 'body': {'required': true}
- }},
- 'adUnitCode': 'adUnitCode',
- 'transactionId': 'transactionId',
- 'bidId': 'bidId',
- 'bidderRequestId': 'bidderRequestId',
- 'auctionId': 'auctionId',
- 'requestedMediaType': 'native',
- 'assets': [
- {'id': 1, 'required': 1, 'title': {'len': 80}},
- {'id': 2, 'required': 1, 'img': {'type': 3, 'w': 300, 'h': 250}},
- {'id': 3, 'required': 1, 'img': {'type': 1, 'w': 50, 'h': 50}},
- {'id': 4, 'required': 1, 'data': {'type': 1}},
- {'id': 5, 'required': 1, 'data': {'type': 12}},
- {'id': 6, 'required': 1, 'data': {'type': 2, 'len': 100}}
- ]
- };
- const instreamVideoBidRequest = {
- 'bidder': BIDDER_CODE,
- 'params': {'site_id': SITE_ID, 'bidfloor': 1.00},
- 'mediaTypes': {'video': {'context': 'instream', 'playerSize': [640, 480]}},
- 'adUnitCode': 'adUnitCode',
- 'transactionId': 'transactionId',
- 'bidId': 'bidId',
- 'bidderRequestId': 'bidderRequestId',
- 'auctionId': 'auctionId',
- 'requestedMediaType': 'video'
- };
- const outstreamVideoBidRequest = {
- 'bidder': BIDDER_CODE,
- 'params': {'site_id': SITE_ID,
- 'bidfloor': 1.00,
- 'outstreamType': 'slider_top_left',
- 'outstreamConfig':
- {'ad_unit_audio': 1, 'show_player_close_button_after': 5, 'hide_player_control': 0}},
- 'mediaTypes': {'video': {'context': 'outstream', 'playerSize': [640, 480]}},
- 'adUnitCode': 'adUnitCode',
- 'transactionId': 'transactionId',
- 'bidId': 'bidId',
- 'bidderRequestId': 'bidderRequestId',
- 'auctionId': 'auctionId',
- 'requestedMediaType': 'video'
- };
- const request = {
- 'method': 'POST',
- 'url': FINAL_URL,
- 'data': '',
- bidRequest
- };
-
- it('check empty response', function () {
- const result = spec.interpretResponse({}, request);
- expect(result).to.deep.equal([]);
- });
-
- it('check if id missing in response', function () {
- const serverResponse = {'body': {'seatbid': [{}]}, 'headers': {}};
- const result = spec.interpretResponse(serverResponse, request);
- expect(result).to.deep.equal([]);
- });
-
- it('check if seatbid present in response', function () {
- const serverResponse = {'body': {'id': 'id'}, 'headers': {}};
- const result = spec.interpretResponse(serverResponse, request);
- expect(result).to.deep.equal([]);
- });
-
- it('check empty array response seatbid', function () {
- const serverResponse = {'body': {'id': 'id', 'seatbid': []}, 'headers': {}};
- const result = spec.interpretResponse(serverResponse, request);
- expect(result).to.deep.equal([]);
- });
-
- it('check bid present in seatbid', function () {
- const serverResponse = {'body': {'id': 'id', 'seatbid': [{}]}, 'headers': {}};
- const result = spec.interpretResponse(serverResponse, request);
- expect(result).to.have.lengthOf(0);
- });
-
- it('check empty array bid in seatbid', function () {
- const serverResponse = {'body': {'id': 'id', 'seatbid': [{'bid': []}]}, 'headers': {}};
- const result = spec.interpretResponse(serverResponse, request);
- expect(result).to.have.lengthOf(0);
- });
-
- it('banner response missing bid price', function () {
- const serverResponse = {'body': {'id': 'id', 'seatbid': [{'bid': [{'id': 1}]}]}, 'headers': {}};
- const result = spec.interpretResponse(serverResponse, request);
- expect(result).to.have.lengthOf(1);
- expect(result[0].requestId).to.equal('bidId');
- expect(result[0].bidderCode).to.equal(request.bidRequest.bidder);
- });
-
- it('banner response', function () {
- const serverResponse = {
- 'body': {
- 'id': 'id',
- 'seatbid': [
- {
- 'bid': [
- {
- 'id': '1',
- 'price': 1,
- 'w': 300,
- 'h': 250,
- 'adm': 'test adm',
- 'nurl': 'url'
- }
- ]
- }
- ]
- },
- 'headers': {}
- };
- const result = spec.interpretResponse(serverResponse, request);
- expect(result).to.have.lengthOf(1);
- expect(result[0].requestId).to.equal('bidId');
- expect(result[0].cpm).to.equal(1);
- expect(result[0].size).to.equal(bidRequest.mediaTypes.banner.sizes);
- expect(result[0].width).to.equal(300);
- expect(result[0].height).to.equal(250);
- expect(result[0].ad).to.equal(decodeURIComponent(serverResponse.body.seatbid[0].bid[0].adm + '
'));
- expect(result[0].creativeId).to.equal('1');
- expect(result[0].bidderCode).to.equal(request.bidRequest.bidder);
- expect(result[0].mediaType).to.equal('banner');
- });
-
- it('native response missing bid price', function () {
- request.bidRequest = nativeBidRequest;
- const serverResponse = {
- 'body': {
- 'id': 'id',
- 'seatbid': [
- {
- 'bid': [
- {
- 'id': '1',
- 'w': 300,
- 'h': 250,
- 'adm': '{"native": {"link": {"url": "test_url"}, "imptrackers": [], "assets": [' +
- '{"id": 1, "title": {"text": "Test title"}},' +
- '{"id": 2, "img": {"type": 3,"url": "https://test/image", "w": 300, "h": 250}},' +
- '{"id": 3, "img": {"type": 1, "url": "https://test/icon", "w": 50, "h": 50}},' +
- '{"id": 4, "data": {"type": 1, "value": "Test sponsored by"}},' +
- '{"id": 5, "data": {"type": 12, "value": "Test CTA"}},' +
- '{"id": 6, "data": {"type": 2, "value": "Test body"}}]}}'
- }
- ]
- }
- ]
- },
- 'headers': {}
- };
- const result = spec.interpretResponse(serverResponse, request);
- expect(result).to.have.lengthOf(1);
- expect(result[0].requestId).to.equal('bidId');
- expect(result[0].bidderCode).to.equal(request.bidRequest.bidder);
- });
-
- it('native response', function () {
- request.bidRequest = nativeBidRequest;
- const serverResponse = {
- 'body': {
- 'id': 'id',
- 'seatbid': [
- {
- 'bid': [
- {
- 'id': '1',
- 'price': 1,
- 'w': 300,
- 'h': 250,
- 'adm': '{"native": {"link": {"url": "test_url"}, "imptrackers": ["tracker1", "tracker2"], "assets": [' +
- '{"id": 1, "title": {"text": "Test title"}},' +
- '{"id": 2, "img": {"type": 3,"url": "https://test/image", "w": 300, "h": 250}},' +
- '{"id": 3, "img": {"type": 1, "url": "https://test/icon", "w": 50, "h": 50}},' +
- '{"id": 4, "data": {"type": 1, "value": "Test sponsored by"}},' +
- '{"id": 5, "data": {"type": 12, "value": "Test CTA"}},' +
- '{"id": 6, "data": {"type": 2, "value": "Test body"}}]}}'
- }
- ]
- }
- ]
- },
- 'headers': {}
- };
-
- const result = spec.interpretResponse(serverResponse, request);
- expect(result).to.have.lengthOf(1);
- expect(result[0].requestId).to.equal('bidId');
- expect(result[0].cpm).to.equal(1);
- expect(result[0].native.clickUrl).to.equal('test_url');
- expect(result[0].native.impressionTrackers).to.have.lengthOf(2);
- expect(result[0].native.title).to.equal('Test title');
- expect(result[0].native.image.url).to.equal('https://test/image');
- expect(result[0].native.icon.url).to.equal('https://test/icon');
- expect(result[0].native.sponsored).to.equal('Test sponsored by');
- expect(result[0].native.cta).to.equal('Test CTA');
- expect(result[0].native.desc).to.equal('Test body');
- expect(result[0].creativeId).to.equal('1');
- expect(result[0].bidderCode).to.equal(request.bidRequest.bidder);
- expect(result[0].mediaType).to.equal('native');
- });
-
- it('video response missing bid price', function () {
- request.bidRequest = instreamVideoBidRequest;
- const serverResponse = {
- 'body': {
- 'id': 'id',
- 'seatbid': [
- {
- 'bid': [
- {
- 'id': '1',
- 'w': 640,
- 'h': 480,
- 'adm': '',
- 'ext': {
- 'vast_url': 'vast_url'
- }
- }
- ]
- }
- ]
- },
- 'headers': {}
- };
- const result = spec.interpretResponse(serverResponse, request);
- expect(result).to.have.lengthOf(1);
- expect(result[0].requestId).to.equal('bidId');
- expect(result[0].bidderCode).to.equal(request.bidRequest.bidder);
- });
-
- it('instream video response', function () {
- request.bidRequest = instreamVideoBidRequest;
- const serverResponse = {
- 'body': {
- 'id': 'id',
- 'seatbid': [
- {
- 'bid': [
- {
- 'id': '1',
- 'price': 1,
- 'w': 640,
- 'h': 480,
- 'adm': '',
- 'ext': {
- 'vast_url': 'test_vast_url?kcid=123&kaid=12&protocol=3'
- }
- }
- ]
- }
- ]
- },
- 'headers': {}
- };
-
- const result = spec.interpretResponse(serverResponse, request);
- expect(result).to.have.lengthOf(1);
- expect(result[0].requestId).to.equal('bidId');
- expect(result[0].cpm).to.equal(1);
- expect(result[0].width).to.equal(640);
- expect(result[0].height).to.equal(480);
- expect(result[0].vastUrl).to.equal('test_vast_url?kcid=123&kaid=12&protocol=3');
- expect(result[0].adserverTargeting.hb_kcid).to.equal('123');
- expect(result[0].adserverTargeting.hb_kaid).to.equal('12');
- expect(result[0].adserverTargeting.hb_protocol).to.equal('3');
- expect(result[0].creativeId).to.equal('1');
- expect(result[0].bidderCode).to.equal(request.bidRequest.bidder);
- expect(result[0].mediaType).to.equal('video');
- });
-
- it('outstream video response', function () {
- request.bidRequest = outstreamVideoBidRequest;
- const serverResponse = {
- 'body': {
- 'id': 'id',
- 'seatbid': [
- {
- 'bid': [
- {
- 'id': '1',
- 'price': 1,
- 'w': 640,
- 'h': 480,
- 'adm': '',
- 'ext': {
- 'vast_url': 'vast_url'
- }
- }
- ]
- }
- ]
- },
- 'headers': {}
- };
- const result = spec.interpretResponse(serverResponse, request);
- expect(result).to.have.lengthOf(1);
- expect(result[0].requestId).to.equal('bidId');
- expect(result[0].cpm).to.equal(1);
- expect(result[0].width).to.equal(640);
- expect(result[0].height).to.equal(480);
- expect(result[0].outstreamType).to.equal('slider_top_left');
- expect(result[0].ad).to.equal('');
- expect(result[0].renderer).to.exist;
- expect(result[0].creativeId).to.equal('1');
- expect(result[0].bidderCode).to.equal(request.bidRequest.bidder);
- expect(result[0].mediaType).to.equal('video');
- });
- });
-});
diff --git a/test/spec/modules/deepintentBidAdapter_spec.js b/test/spec/modules/deepintentBidAdapter_spec.js
deleted file mode 100644
index ead1c8ecc..000000000
--- a/test/spec/modules/deepintentBidAdapter_spec.js
+++ /dev/null
@@ -1,519 +0,0 @@
-import {expect} from 'chai';
-import {spec} from 'modules/deepintentBidAdapter.js';
-import * as utils from '../../../src/utils.js';
-
-describe('Deepintent adapter', function () {
- let request, videoBidRequests;
- let bannerResponse, videoBidResponse, invalidResponse;
-
- beforeEach(function () {
- request = [
- {
- bidder: 'deepintent',
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
- },
- params: {
- tagId: '100013',
- w: 728,
- h: 90,
- pos: 1,
- user: {
- id: 'di_testuid',
- buyeruid: 'di_testbuyeruid',
- yob: 2002,
- gender: 'F'
- },
- custom: {
- 'position': 'right-box'
- }
- }
- }
- ];
- videoBidRequests =
- [
- {
- code: 'video1',
- mediaTypes: {
- video: {
- playerSize: [640, 480],
- context: 'instream'
- }
- },
- bidder: 'deepintent',
- bidId: '22bddb28db77d',
- params: {
- tagId: '100013',
- video: {
- mimes: ['video/mp4', 'video/x-flv'],
- skippable: true,
- testwrongparam: 3,
- testwrongparam1: 'wrong',
- minduration: 5,
- maxduration: 30,
- startdelay: 5,
- playbackmethod: [1, 3],
- api: [1, 2],
- protocols: [2, 3],
- battr: [13, 14],
- minbitrate: 10,
- maxbitrate: 10
- }
- }
- }
- ];
- bannerResponse = {
- 'body': {
- 'id': '303e1fae-9677-41e2-9a92-15a23445363f',
- 'seatbid': [{
- 'bid': [{
- 'id': '11447bb1-a266-470d-b0d7-8810f5b1b75f',
- 'impid': 'a7e92b9b-d9db-4de8-9c3f-f90737335445',
- 'price': 0.6,
- 'adid': '10001',
- 'adm': "
\r\n
",
- 'adomain': ['deepintent.com'],
- 'cid': '103389',
- 'crid': '13665',
- 'w': 300,
- 'h': 250,
- 'dealId': 'dee_12312stdszzsx'
- }],
- 'seat': '10000'
- }],
- 'bidid': '0b08b09f-aaa1-4c14-b1c8-7debb1a7c1cd'
- }
- };
- invalidResponse = {
- 'body': {
- 'id': '303e1fae-9677-41e2-9a92-15a23445363f',
- 'seatbid': [{
- 'bid': [{
- 'id': '11447bb1-a266-470d-b0d7-8810f5b1b75f',
- 'impid': 'a7e92b9b-d9db-4de8-9c3f-f90737335445',
- 'price': 0.6,
- 'adid': '10001',
- 'adm': 'invalid response',
- 'adomain': ['deepintent.com'],
- 'cid': '103389',
- 'crid': '13665',
- 'w': 300,
- 'h': 250,
- 'dealId': 'dee_12312stdszzsx'
- }],
- 'seat': '10000'
- }],
- 'bidid': '0b08b09f-aaa1-4c14-b1c8-7debb1a7c1cd'
- }
- };
- videoBidResponse = {
- 'body': {
- 'id': '93D3BAD6-E2E2-49FB-9D89-920B1761C865',
- 'seatbid': [{
- 'bid': [{
- 'id': '74858439-49D7-4169-BA5D-44A046315B2F',
- 'impid': '22bddb28db77d',
- 'price': 1.3,
- 'adm': 'Acudeo CompatibleVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1https://dsptracker.com/{PSPM}00:00:04https://www.deepintent.com',
- 'h': 250,
- 'w': 300,
- 'ext': {
- 'deal_channel': 6
- }
- }]
- }]
- }
- };
- });
-
- describe('validations', function () {
- it('validBid : tagId is passed', function () {
- const bid = {
- bidder: 'deepintent',
- params: {
- tagId: '1232'
- }
- };
- const isValid = spec.isBidRequestValid(bid);
- expect(isValid).to.equals(true);
- });
- it('invalidBid : tagId is not passed', function () {
- const bid = {
- bidder: 'deepintent',
- params: {
- h: 200,
- w: 300
- }
- };
- const isValid = spec.isBidRequestValid(bid);
- expect(isValid).to.equals(false);
- });
- it('invalidBid : tagId is not a string', function () {
- const bid = {
- bidder: 'deepintent',
- params: {
- tagId: 12345
- }
- };
- const isValid = spec.isBidRequestValid(bid);
- expect(isValid).to.equals(false);
- });
- it('should check for context if video is present', function() {
- const bid = {
- bidder: 'deepintent',
- params: {
- tagId: '12345',
- video: {
- mimes: ['video/mp4', 'video/x-flv'],
- skippable: true,
- }
- },
- mediaTypes: {
- video: {
- playerSize: [640, 480],
- context: 'instream'
- }
- },
- };
- const isValid = spec.isBidRequestValid(bid);
- expect(isValid).to.equal(true);
- });
- it('should error out if context is not present and is Video', function() {
- const bid = {
- bidder: 'deepintent',
- params: {
- tagId: '12345',
- video: {
- mimes: ['video/mp4', 'video/x-flv'],
- skippable: true,
- }
- },
- mediaTypes: {
- video: {
- playerSize: [640, 480]
- }
- },
- };
- const isValid = spec.isBidRequestValid(bid);
- expect(isValid).to.equal(false);
- })
- });
- describe('request check', function () {
- it('unmutaable bid request check', function () {
- const oRequest = utils.deepClone(request);
- const bidRequest = spec.buildRequests(request);
- expect(request).to.deep.equal(oRequest);
- });
- it('bidder connection check', function () {
- const bRequest = spec.buildRequests(request);
- expect(bRequest.url).to.equal('https://prebid.deepintent.com/prebid');
- expect(bRequest.method).to.equal('POST');
- expect(bRequest.options.contentType).to.equal('application/json');
- });
- it('bid request check : Device', function () {
- const bRequest = spec.buildRequests(request);
- const data = JSON.parse(bRequest.data);
- expect(data.device.ua).to.be.a('string');
- expect(data.device.js).to.equal(1);
- expect(data.device.dnt).to.be.a('number');
- expect(data.device.h).to.be.a('number');
- expect(data.device.w).to.be.a('number');
- });
- it('bid request check : Impression', function () {
- const bRequest = spec.buildRequests(request);
- const data = JSON.parse(bRequest.data);
- expect(data.at).to.equal(1); // auction type
- expect(data.imp[0].id).to.equal(request[0].bidId);
- expect(data.imp[0].tagid).to.equal('100013');
- });
- it('bid request check : ad size', function () {
- const bRequest = spec.buildRequests(request);
- const data = JSON.parse(bRequest.data);
- expect(data.imp[0].banner).to.be.a('object');
- expect(data.imp[0].banner.w).to.equal(300);
- expect(data.imp[0].banner.h).to.equal(250);
- });
- it('bid request check : custom params', function () {
- const bRequest = spec.buildRequests(request);
- const data = JSON.parse(bRequest.data);
- expect(data.imp[0].ext).to.be.a('object');
- expect(data.imp[0].ext.deepintent.position).to.equal('right-box');
- });
- it('bid request check: position check', function () {
- const bRequest = spec.buildRequests(request);
- const data = JSON.parse(bRequest.data);
- expect(data.imp[0].banner.pos).to.equal(1);
- });
- it('bid request check: displaymanager check', function() {
- const bRequest = spec.buildRequests(request);
- const data = JSON.parse(bRequest.data);
- expect(data.imp[0].displaymanager).to.equal('di_prebid');
- expect(data.imp[0].displaymanagerver).to.equal('1.0.0');
- });
- it('bid request check: bidfloor check', function() {
- const requestClone = utils.deepClone(request);
- let bRequest = spec.buildRequests(requestClone);
- let data = JSON.parse(bRequest.data);
- expect(data.imp[0].bidfloor).to.not.exist;
-
- requestClone[0].params.bidfloor = 0;
- bRequest = spec.buildRequests(requestClone);
- data = JSON.parse(bRequest.data);
- expect(data.imp[0].bidfloor).to.equal(0);
-
- requestClone[0].params.bidfloor = 1.2;
- bRequest = spec.buildRequests(requestClone);
- data = JSON.parse(bRequest.data);
- expect(data.imp[0].bidfloor).to.equal(1.2);
- });
- it('bid request check: user object check', function () {
- const bRequest = spec.buildRequests(request);
- const data = JSON.parse(bRequest.data);
- expect(data.user).to.be.a('object');
- expect(data.user.id).to.equal('di_testuid');
- expect(data.user.buyeruid).to.equal('di_testbuyeruid');
- expect(data.user.yob).to.equal(2002);
- expect(data.user.gender).to.equal('F');
- });
- it('bid request check: CCPA Check', function () {
- const bidRequest = {
- uspConsent: '1NYN'
- };
- const bRequest = spec.buildRequests(request, bidRequest);
- const data = JSON.parse(bRequest.data);
- expect(data.regs.ext.us_privacy).to.equal('1NYN');
- const bidRequest2 = {};
- const bRequest2 = spec.buildRequests(request, bidRequest2);
- const data2 = JSON.parse(bRequest2.data);
- expect(data2.regs).to.equal(undefined);
- });
- it('bid Request check: GDPR Check', function () {
- const bidRequest = {
- gdprConsent: {
- consentString: 'kjfdnidasd123sadsd',
- gdprApplies: true
- }
- };
- const bRequest = spec.buildRequests(request, bidRequest);
- const data = JSON.parse(bRequest.data);
- expect(data.user.ext.consent).to.equal('kjfdnidasd123sadsd');
- expect(data.regs.ext.gdpr).to.equal(1);
- const bidRequest2 = {};
- const bRequest2 = spec.buildRequests(request, bidRequest2);
- const data2 = JSON.parse(bRequest2.data);
- expect(data2.regs).to.equal(undefined);
- expect(data2.user.ext).to.equal(undefined);
- });
- it('bid request check: Video params check ', function() {
- const bRequest = spec.buildRequests(videoBidRequests);
- const data = JSON.parse(bRequest.data);
- expect(data.imp[0].video).to.be.a('object');
- expect(data.imp[0].video.minduration).to.be.a('number');
- expect(data.imp[0].video.maxduration).to.be.a('number');
- expect(data.imp[0].video.startdelay).to.be.a('number');
- expect(data.imp[0].video.playbackmethod).to.be.an('array');
- expect(data.imp[0].video.api).to.be.an('array');
- expect(data.imp[0].video.protocols).to.be.an('array');
- expect(data.imp[0].video.battr).to.be.an('array');
- expect(data.imp[0].video.minbitrate).to.be.a('number');
- expect(data.imp[0].video.maxbitrate).to.be.a('number');
- expect(data.imp[0].video.w).to.be.a('number');
- });
- it('bid request param check : invalid video params', function() {
- const bRequest = spec.buildRequests(videoBidRequests);
- const data = JSON.parse(bRequest.data);
- expect(data.imp[0].video).to.be.a('object');
- expect(data.imp[0].video.testwrongparam).to.equal(undefined);
- expect(data.imp[0].video.testwrongparam1).to.equal(undefined);
- });
- });
- describe('user sync check', function () {
- it('user sync url check', function () {
- const syncOptions = {
- iframeEnabled: true
- };
- const userSync = spec.getUserSyncs(syncOptions);
- expect(userSync).to.be.an('array').with.length.above(0);
- expect(userSync[0].type).to.equal('iframe');
- expect(userSync[0].url).to.equal('https://cdn.deepintent.com/syncpixel.html');
- });
- });
- describe('response check', function () {
- it('bid response check: valid bid response', function () {
- const bRequest = spec.buildRequests(request);
- const data = JSON.parse(bRequest.data);
- const bResponse = spec.interpretResponse(bannerResponse, request);
- expect(bResponse).to.be.an('array').with.length.above(0);
- expect(bResponse[0].requestId).to.equal(bannerResponse.body.seatbid[0].bid[0].impid);
- expect(bResponse[0].width).to.equal(bannerResponse.body.seatbid[0].bid[0].w);
- expect(bResponse[0].height).to.equal(bannerResponse.body.seatbid[0].bid[0].h);
- expect(bResponse[0].currency).to.equal('USD');
- expect(bResponse[0].netRevenue).to.equal(false);
- expect(bResponse[0].mediaType).to.equal('banner');
- expect(bResponse[0].meta.advertiserDomains).to.deep.equal(['deepintent.com']);
- expect(bResponse[0].ttl).to.equal(300);
- expect(bResponse[0].creativeId).to.equal(bannerResponse.body.seatbid[0].bid[0].crid);
- expect(bResponse[0].dealId).to.equal(bannerResponse.body.seatbid[0].bid[0].dealId);
- });
- it('bid response check: valid video bid response', function() {
- const request = spec.buildRequests(videoBidRequests);
- const response = spec.interpretResponse(videoBidResponse, request);
- expect(response[0].mediaType).to.equal('video');
- expect(response[0].vastXml).to.not.equal(undefined);
- });
- it('invalid bid response check ', function() {
- const bRequest = spec.buildRequests(request);
- const response = spec.interpretResponse(invalidResponse, bRequest);
- expect(response[0].mediaType).to.equal(undefined);
- });
- it('invalid bid response check ', function() {
- const bRequest = spec.buildRequests(videoBidRequests);
- const response = spec.interpretResponse(invalidResponse, bRequest);
- expect(response[0].mediaType).to.equal(undefined);
- });
- });
- describe('GPP and coppa', function() {
- it('Request params check with GPP Consent', function () {
- const bidderReq = {gppConsent: {gppString: 'gpp-string-test', applicableSections: [5]}};
- const bRequest = spec.buildRequests(request, bidderReq);
- const data = JSON.parse(bRequest.data);
- expect(data.regs.gpp).to.equal('gpp-string-test');
- expect(data.regs.gpp_sid[0]).to.equal(5);
- });
- it('Request params check with GPP Consent read from ortb2', function () {
- const bidderReq = {
- ortb2: {
- regs: {
- gpp: 'gpp-test-string',
- gpp_sid: [5]
- }
- }
- };
- const bRequest = spec.buildRequests(request, bidderReq);
- const data = JSON.parse(bRequest.data);
- expect(data.regs.gpp).to.equal('gpp-test-string');
- expect(data.regs.gpp_sid[0]).to.equal(5);
- });
- it('should include coppa flag in bid request if coppa is set to true', () => {
- const bidderReq = {ortb2: {regs: {coppa: 1}}};
- const bRequest = spec.buildRequests(request, bidderReq);
- const data = JSON.parse(bRequest.data);
- expect(data.regs.coppa).to.equal(1);
- });
- });
- describe('deals functionality', function() {
- it('should add PMP deals when valid deals array is provided', function() {
- const requestWithDeals = [{
- bidder: 'deepintent',
- bidId: 'test-bid-id',
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
- },
- params: {
- tagId: '100013',
- deals: ['deal1234', 'deal5678']
- }
- }];
-
- const bRequest = spec.buildRequests(requestWithDeals);
- const data = JSON.parse(bRequest.data);
-
- expect(data.imp[0].pmp).to.be.an('object');
- expect(data.imp[0].pmp.private_auction).to.equal(0);
- expect(data.imp[0].pmp.deals).to.be.an('array').with.length(2);
- expect(data.imp[0].pmp.deals[0].id).to.equal('deal1234');
- expect(data.imp[0].pmp.deals[1].id).to.equal('deal5678');
- });
-
- it('should filter out invalid deal IDs and handle edge cases', function() {
- const requestWithMixedDeals = [{
- bidder: 'deepintent',
- bidId: 'test-bid-id',
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
- },
- params: {
- tagId: '100013',
- deals: ['abc', 'valid_deal', 12345, null, 'xy']
- }
- }];
-
- const bRequest = spec.buildRequests(requestWithMixedDeals);
- const data = JSON.parse(bRequest.data);
-
- expect(data.imp[0].pmp.deals).to.be.an('array').with.length(1);
- expect(data.imp[0].pmp.deals[0].id).to.equal('valid_deal');
- });
-
- it('should not add pmp when deals is not a valid array', function() {
- const requestWithInvalidDeals = [{
- bidder: 'deepintent',
- bidId: 'test-bid-id',
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
- },
- params: {
- tagId: '100013',
- deals: 'not-an-array'
- }
- }];
-
- const bRequest = spec.buildRequests(requestWithInvalidDeals);
- const data = JSON.parse(bRequest.data);
-
- expect(data.imp[0].pmp).to.be.undefined;
- });
-
- it('should add and clean deal custom targeting', function() {
- const requestWithDctr = [{
- bidder: 'deepintent',
- bidId: 'test-bid-id',
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
- },
- params: {
- tagId: '100013',
- dctr: ' key1=val1 | key2=val2 | | key3=val3 '
- }
- }];
-
- const bRequest = spec.buildRequests(requestWithDctr);
- const data = JSON.parse(bRequest.data);
-
- expect(data.imp[0].ext.key_val).to.equal('key1=val1|key2=val2|key3=val3');
- });
-
- it('should handle both deals and dctr together', function() {
- const requestWithBoth = [{
- bidder: 'deepintent',
- bidId: 'test-bid-id',
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
- },
- params: {
- tagId: '100013',
- deals: ['deal1234'],
- dctr: 'key1=val1|key2=val2'
- }
- }];
-
- const bRequest = spec.buildRequests(requestWithBoth);
- const data = JSON.parse(bRequest.data);
-
- expect(data.imp[0].pmp.deals[0].id).to.equal('deal1234');
- expect(data.imp[0].ext.key_val).to.equal('key1=val1|key2=val2');
- });
- });
-});
diff --git a/test/spec/modules/deltaprojectsBidAdapter_spec.js b/test/spec/modules/deltaprojectsBidAdapter_spec.js
deleted file mode 100644
index 30f709f0a..000000000
--- a/test/spec/modules/deltaprojectsBidAdapter_spec.js
+++ /dev/null
@@ -1,394 +0,0 @@
-import { expect } from 'chai';
-import {
- BIDDER_CODE,
- BIDDER_ENDPOINT_URL,
- spec, USERSYNC_URL,
- getBidFloor
-} from 'modules/deltaprojectsBidAdapter.js';
-
-const BID_REQ_REFER = 'http://example.com/page?param=val';
-const BID_REQ_DOMAIN = 'example.com'
-
-describe('deltaprojectsBidAdapter', function() {
- describe('isBidRequestValid', function () {
- function makeBid() {
- return {
- bidder: BIDDER_CODE,
- params: {
- publisherId: '12345'
- },
- adUnitCode: 'adunit-code',
- sizes: [
- [300, 250],
- ],
- bidId: '30b31c1838de1e',
- bidderRequestId: '22edbae2733bf6',
- auctionId: '1d1a030790a475',
- };
- }
-
- it('should return true when bidder set correctly', function () {
- expect(spec.isBidRequestValid(makeBid())).to.equal(true);
- });
-
- it('should return false when bid request is null', function () {
- expect(spec.isBidRequestValid(undefined)).to.equal(false);
- });
-
- it('should return false when publisher id is not set', function () {
- const bid = makeBid();
- delete bid.params.publisherId;
- expect(spec.isBidRequestValid(bid)).to.equal(false);
- });
- });
-
- describe('buildRequests', function () {
- const BIDREQ = {
- bidder: BIDDER_CODE,
- params: {
- tagId: '403370',
- siteId: 'example.com',
- },
- sizes: [
- [300, 250],
- ],
- bidId: '30b31c1838de1e',
- bidderRequestId: '22edbae2733bf6',
- auctionId: '1d1a030790a475',
- }
- const bidRequests = [BIDREQ];
- const bannerRequest = spec.buildRequests(bidRequests, {refererInfo: { page: BID_REQ_REFER, domain: BID_REQ_DOMAIN }})[0];
- const bannerRequestBody = bannerRequest.data;
-
- it('send bid request with test tag if it is set in the param', function () {
- const TEST_TAG = 1;
- const bidRequest = Object.assign({}, BIDREQ, {
- params: { ...BIDREQ.params, test: TEST_TAG },
- });
- const bidderRequest = { refererInfo: { referer: BID_REQ_REFER } };
- const request = spec.buildRequests([bidRequest], bidderRequest)[0];
- expect(request.data.test).to.equal(TEST_TAG);
- });
-
- it('send bid request with correct timeout', function () {
- const TMAX = 10;
- const bidderRequest = { refererInfo: { referer: BID_REQ_REFER }, timeout: TMAX };
- const request = spec.buildRequests(bidRequests, bidderRequest)[0];
- expect(request.data.tmax).to.equal(TMAX);
- });
-
- it('send bid request to the correct endpoint URL', function () {
- expect(bannerRequest.url).to.equal(BIDDER_ENDPOINT_URL);
- });
-
- it('sends bid request to our endpoint via POST', function () {
- expect(bannerRequest.method).to.equal('POST');
- });
-
- it('sends screen dimensions', function () {
- expect(bannerRequestBody.device.w).to.equal(screen.width);
- expect(bannerRequestBody.device.h).to.equal(screen.height);
- });
-
- it('includes the ad size in the bid request', function () {
- expect(bannerRequestBody.imp[0].banner.format[0].w).to.equal(BIDREQ.sizes[0][0]);
- expect(bannerRequestBody.imp[0].banner.format[0].h).to.equal(BIDREQ.sizes[0][1]);
- });
-
- it('sets domain and href correctly', function () {
- expect(bannerRequestBody.site.domain).to.equal(BIDREQ.params.siteId);
- expect(bannerRequestBody.site.page).to.equal(BID_REQ_REFER);
- });
-
- const gdprBidRequests = [{
- bidder: BIDDER_CODE,
- params: {
- tagId: '403370',
- siteId: 'example.com'
- },
- sizes: [
- [300, 250]
- ],
- bidId: '30b31c1838de1e',
- bidderRequestId: '22edbae2733bf6',
- auctionId: '1d1a030790a475'
- }];
- const consentString = 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==';
-
- const GDPR_REQ_REFERER = 'http://localhost:9876/'
- function getGdprRequestBody(gdprApplies, consentString) {
- const gdprRequest = spec.buildRequests(gdprBidRequests, {
- gdprConsent: {
- gdprApplies: gdprApplies,
- consentString: consentString,
- },
- refererInfo: {
- referer: GDPR_REQ_REFERER,
- },
- })[0];
- return gdprRequest.data;
- }
-
- it('should handle gdpr applies being present and true', function() {
- const gdprRequestBody = getGdprRequestBody(true, consentString);
- expect(gdprRequestBody.regs.ext.gdpr).to.equal(1);
- expect(gdprRequestBody.user.ext.consent).to.equal(consentString);
- })
-
- it('should handle gdpr applies being present and false', function() {
- const gdprRequestBody = getGdprRequestBody(false, consentString);
- expect(gdprRequestBody.regs.ext.gdpr).to.equal(0);
- expect(gdprRequestBody.user.ext.consent).to.equal(consentString);
- })
-
- it('should handle gdpr applies being undefined', function() {
- const gdprRequestBody = getGdprRequestBody(undefined, consentString);
- expect(gdprRequestBody.regs).to.deep.equal({ext: {}});
- expect(gdprRequestBody.user.ext.consent).to.equal(consentString);
- })
-
- it('should handle gdpr consent being undefined', function() {
- const gdprRequest = spec.buildRequests(gdprBidRequests, {refererInfo: { referer: GDPR_REQ_REFERER }})[0];
- const gdprRequestBody = gdprRequest.data;
- expect(gdprRequestBody.regs).to.deep.equal({ ext: {} });
- expect(gdprRequestBody.user).to.deep.equal({ ext: {} });
- })
- });
-
- describe('interpretResponse', function () {
- const bidRequests = [
- {
- bidder: BIDDER_CODE,
- params: {
- tagId: '403370',
- siteId: 'example.com',
- currency: 'USD',
- },
- sizes: [
- [300, 250],
- ],
- bidId: '30b31c1838de1e',
- bidderRequestId: '22edbae2733bf6',
- auctionId: '1d1a030790a475',
- },
- ];
- const request = spec.buildRequests(bidRequests, {refererInfo: { referer: BID_REQ_REFER }})[0];
- function makeResponse() {
- return {
- body: {
- id: '5e5c23a5ba71e78',
- seatbid: [
- {
- bid: [
- {
- id: '6vmb3isptf',
- crid: 'deltaprojectscreative',
- impid: '322add653672f68',
- price: 1.22,
- adm: '',
- attr: [5],
- h: 90,
- nurl: 'http://nurl',
- w: 728,
- }
- ],
- seat: 'MOCK'
- }
- ],
- bidid: '5e5c23a5ba71e78',
- cur: 'USD'
- }
- };
- }
- const expectedBid = {
- requestId: '322add653672f68',
- cpm: 1.22,
- width: 728,
- height: 90,
- creativeId: 'deltaprojectscreative',
- dealId: null,
- currency: 'USD',
- netRevenue: true,
- mediaType: 'banner',
- ttl: 60,
- ad: ''
- };
-
- it('should get incorrect bid response if response body is missing', function () {
- const response = makeResponse();
- delete response.body;
- const result = spec.interpretResponse(response, request);
- expect(result.length).to.equal(0);
- });
-
- it('should get incorrect bid response if id or seat id of response body is missing', function () {
- const response1 = makeResponse();
- delete response1.body.id;
- const result1 = spec.interpretResponse(response1, request);
- expect(result1.length).to.equal(0);
-
- const response2 = makeResponse();
- delete response2.body.seatbid;
- const result2 = spec.interpretResponse(response2, request);
- expect(result2.length).to.equal(0);
- });
-
- it('should get the correct bid response', function () {
- const result = spec.interpretResponse(makeResponse(), request);
- expect(result.length).to.equal(1);
- expect(result[0]).to.deep.equal(expectedBid);
- });
-
- it('should handle a missing crid', function () {
- const noCridResponse = makeResponse();
- delete noCridResponse.body.seatbid[0].bid[0].crid;
- const fallbackCrid = noCridResponse.body.seatbid[0].bid[0].id;
- const noCridResult = Object.assign({}, expectedBid, {'creativeId': fallbackCrid});
- const result = spec.interpretResponse(noCridResponse, request);
- expect(result.length).to.equal(1);
- expect(result[0]).to.deep.equal(noCridResult);
- });
-
- it('should handle a missing nurl', function () {
- const noNurlResponse = makeResponse();
- delete noNurlResponse.body.seatbid[0].bid[0].nurl;
- const noNurlResult = Object.assign({}, expectedBid);
- noNurlResult.ad = '';
- const result = spec.interpretResponse(noNurlResponse, request);
- expect(result.length).to.equal(1);
- expect(result[0]).to.deep.equal(noNurlResult);
- });
-
- it('handles empty bid response', function () {
- const response = {
- body: {
- id: '5e5c23a5ba71e78',
- seatbid: []
- }
- };
- const result = spec.interpretResponse(response, request);
- expect(result.length).to.equal(0);
- });
-
- it('should keep custom properties', () => {
- const customProperties = {test: 'a test message', param: {testParam: 1}};
- const expectedResult = Object.assign({}, expectedBid, {[spec.code]: customProperties});
- const response = makeResponse();
- response.body.seatbid[0].bid[0].ext = customProperties;
- const result = spec.interpretResponse(response, request);
- expect(result.length).to.equal(1);
- expect(result[0]).to.deep.equal(expectedResult);
- });
- });
-
- describe('onBidWon', function () {
- const OPEN_RTB_RESP = {
- body: {
- id: 'abc',
- seatbid: [
- {
- bid: [
- {
- 'id': 'abc*123*456',
- 'impid': 'xxxxxxx',
- 'price': 46.657196,
- 'adm': '