Skip to content

Commit

Permalink
Fix test that hard-coded pbjs global. (prebid#1786)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpr authored and Matt Kendall committed Nov 10, 2017
1 parent cb2cd77 commit 71fa707
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/spec/modules/s2sTesting_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,15 @@ describe('s2sTesting', function () {
const AST = CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING;

function checkTargeting(bidder) {
var targeting = window.pbjs.bidderSettings[bidder][AST];
var targeting = window.$$PREBID_GLOBAL$$.bidderSettings[bidder][AST];
var srcTargeting = targeting[targeting.length - 1];
expect(srcTargeting.key).to.equal(`hb_source_${bidder}`);
expect(srcTargeting.val).to.be.a('function');
expect(window.pbjs.bidderSettings[bidder].alwaysUseBid).to.be.true;
expect(window.$$PREBID_GLOBAL$$.bidderSettings[bidder].alwaysUseBid).to.be.true;
}

function checkNoTargeting(bidder) {
var bs = window.pbjs.bidderSettings;
var bs = window.$$PREBID_GLOBAL$$.bidderSettings;
var targeting = bs[bidder] && bs[bidder][AST];
if (!targeting) {
expect(targeting).to.be.undefined;
Expand All @@ -332,22 +332,22 @@ describe('s2sTesting', function () {
}

function checkTargetingVal(bidResponse, expectedVal) {
var targeting = window.pbjs.bidderSettings[bidResponse.bidderCode][AST];
var targeting = window.$$PREBID_GLOBAL$$.bidderSettings[bidResponse.bidderCode][AST];
var targetingFunc = targeting[targeting.length - 1].val;
expect(targetingFunc(bidResponse)).to.equal(expectedVal);
}

beforeEach(() => {
// set bidderSettings
window.pbjs.bidderSettings = {};
window.$$PREBID_GLOBAL$$.bidderSettings = {};
});

it('should not set hb_source_<bidder> unless testing is on and includeSourceKvp is set', () => {
config.setConfig({s2sConfig: {bidders: ['rubicon', 'appnexus']}});
expect(window.pbjs.bidderSettings).to.eql({});
expect(window.$$PREBID_GLOBAL$$.bidderSettings).to.eql({});

config.setConfig({s2sConfig: {bidders: ['rubicon', 'appnexus'], testing: true}});
expect(window.pbjs.bidderSettings).to.eql({});
expect(window.$$PREBID_GLOBAL$$.bidderSettings).to.eql({});

config.setConfig({s2sConfig: {
bidders: ['rubicon', 'appnexus'],
Expand All @@ -357,7 +357,7 @@ describe('s2sTesting', function () {
appnexus: {bidSource: {server: 1}}
}
}});
expect(window.pbjs.bidderSettings).to.eql({});
expect(window.$$PREBID_GLOBAL$$.bidderSettings).to.eql({});

config.setConfig({s2sConfig: {
bidders: ['rubicon', 'appnexus'],
Expand All @@ -367,7 +367,7 @@ describe('s2sTesting', function () {
appnexus: {includeSourceKvp: true}
}
}});
expect(window.pbjs.bidderSettings).to.eql({});
expect(window.$$PREBID_GLOBAL$$.bidderSettings).to.eql({});
});

it('should set hb_source_<bidder> if includeSourceKvp is set', () => {
Expand Down

0 comments on commit 71fa707

Please sign in to comment.