Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

update audigent tests to fix larger test suite issue #4952

Merged
merged 1 commit into from
Mar 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 32 additions & 30 deletions test/spec/modules/realTimeModule_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import {
init as audigentInit,
setData as setAudigentData
} from 'modules/audigentRtdProvider.js';
import {config} from 'src/config.js';
import {makeSlot} from '../integration/faker/googletag.js';
import { config } from 'src/config.js';
import { makeSlot } from '../integration/faker/googletag.js';

let expect = require('chai').expect;

describe('Real time module', function() {
describe('Real time module', function () {
const conf = {
'realTimeData': {
'auctionDelay': 250,
Expand All @@ -37,8 +37,8 @@ describe('Real time module', function() {
}
};

const predictions =
{p: {
const predictions = {
p: {
'browsiAd_2': {
'w': [
'/57778053/Browsi_Demo_Low',
Expand All @@ -61,31 +61,35 @@ describe('Real time module', function() {
'p': 0.85
}
}
};
};

const audigentSegments = {
audigent_segments: {'a': 1, 'b': 2}
audigent_segments: { 'a': 1, 'b': 2 }
}

function getAdUnitMock(code = 'adUnit-code') {
return {
code,
mediaTypes: {banner: {}, native: {}},
mediaTypes: { banner: {}, native: {} },
sizes: [[300, 200], [300, 600]],
bids: [{bidder: 'sampleBidder', params: {placementId: 'banner-only-bidder'}}]
bids: [{ bidder: 'sampleBidder', params: { placementId: 'banner-only-bidder' } }]
};
}

function createSlots() {
const slot1 = makeSlot({code: '/57778053/Browsi_Demo_300x250', divId: 'browsiAd_1'});
const slot1 = makeSlot({ code: '/57778053/Browsi_Demo_300x250', divId: 'browsiAd_1' });
return [slot1];
}

describe('Real time module with browsi provider', function() {
describe('Real time module with browsi provider', function () {
afterEach(function () {
$$PREBID_GLOBAL$$.requestBids.removeAll();
});

after(function () {
config.resetConfig();
});

it('check module using bidsBackCallback', function () {
let adUnits1 = [getAdUnitMock('browsiAd_1')];
let targeting = [];
Expand All @@ -105,12 +109,10 @@ describe('Real time module', function() {
targeting.push(Object.keys(value).toString());
});
});
}
setTargetsAfterRequestBids(afterBidHook, adUnits1, true);

setTimeout(() => {
expect(targeting.indexOf('bv')).to.be.greaterThan(-1);
}, 200);
}
setTargetsAfterRequestBids(afterBidHook, adUnits1, true);
});

it('check module using requestBidsHook', function () {
Expand All @@ -130,16 +132,15 @@ describe('Real time module', function() {
targeting.push(Object.keys(value).toString());
});
});
}
requestBidsHook(afterBidHook, {adUnits: adUnits1});
setTimeout(() => {

expect(targeting.indexOf('bv')).to.be.greaterThan(-1);
dataReceived.adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid.realTimeData).to.have.property('bv');
});
});
}, 200);
}
requestBidsHook(afterBidHook, { adUnits: adUnits1 });
});

it('check object deep merge', function () {
Expand Down Expand Up @@ -199,17 +200,19 @@ describe('Real time module', function() {
})
});

describe('Real time module with Audigent provider', function() {
describe('Real time module with Audigent provider', function () {
before(function () {
init(config);
audigentInit(config);
config.setConfig(conf);
setAudigentData(audigentSegments);
});

afterEach(function () {
$$PREBID_GLOBAL$$.requestBids.removeAll();
config.resetConfig();
});

let targeting = [];
init(config);
audigentInit(config);
config.setConfig(conf);
setAudigentData(audigentSegments);

it('check module using requestBidsHook', function () {
let adUnits1 = [getAdUnitMock('audigentAd_1')];
let targeting = [];
Expand All @@ -227,17 +230,16 @@ describe('Real time module', function() {
targeting.push(Object.keys(value).toString());
});
});
}

requestBidsHook(afterBidHook, {adUnits: adUnits1});
setTimeout(() => {
dataReceived.adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid.realTimeData).to.have.property('audigent_segments');
expect(bid.realTimeData.audigent_segments).to.deep.equal(audigentSegments.audigent_segments);
});
});
}, 200);
}

requestBidsHook(afterBidHook, { adUnits: adUnits1 });
});
});
});