From 31280bf2dc869c36692df5add597d0c1de3a410d Mon Sep 17 00:00:00 2001 From: Jason Snellbaker Date: Mon, 9 Mar 2020 09:08:47 -0400 Subject: [PATCH] update audigent tests to fix larger test suite issue --- test/spec/modules/realTimeModule_spec.js | 62 ++++++++++++------------ 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/test/spec/modules/realTimeModule_spec.js b/test/spec/modules/realTimeModule_spec.js index 89b44333636..27440a3ec23 100644 --- a/test/spec/modules/realTimeModule_spec.js +++ b/test/spec/modules/realTimeModule_spec.js @@ -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, @@ -37,8 +37,8 @@ describe('Real time module', function() { } }; - const predictions = - {p: { + const predictions = { + p: { 'browsiAd_2': { 'w': [ '/57778053/Browsi_Demo_Low', @@ -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 = []; @@ -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 () { @@ -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 () { @@ -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 = []; @@ -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 }); }); }); });