From a3bd17f37af74c2bca692f107365dd2a272f11f3 Mon Sep 17 00:00:00 2001 From: jsnellbaker <31102355+jsnellbaker@users.noreply.github.com> Date: Wed, 17 Oct 2018 14:35:26 -0400 Subject: [PATCH] add stub for adloader.loadScript in various adapter test files (#3193) * add stub for adloader in various adapter test files * remove unneeded commented line of code --- test/spec/modules/appnexusBidAdapter_spec.js | 12 ++++++++++++ test/spec/modules/beachfrontBidAdapter_spec.js | 12 ++++++++++++ test/spec/modules/consentManagement_spec.js | 4 ++-- test/spec/modules/rockyouBidAdapter_spec.js | 12 ++++++++++++ test/spec/modules/vubleBidAdapter_spec.js | 13 +++++++++++++ test/spec/modules/xhbBidAdapter_spec.js | 12 ++++++++++++ test/spec/modules/zedoBidAdapter_spec.js | 14 +++++++++++++- test/spec/unit/core/bidderFactory_spec.js | 12 ++++++++++++ 8 files changed, 88 insertions(+), 3 deletions(-) diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 9be87ac8628..37126475af8 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -4,9 +4,21 @@ import { newBidder } from 'src/adapters/bidderFactory'; import { deepClone } from 'src/utils'; const ENDPOINT = '//ib.adnxs.com/ut/v3/prebid'; +const adloader = require('src/adloader'); describe('AppNexusAdapter', function () { const adapter = newBidder(spec); + let loadScriptStub; + + before(function() { + loadScriptStub = sinon.stub(adloader, 'loadScript').callsFake((...args) => { + args[1](); + }); + }); + + after(function() { + loadScriptStub.restore(); + }); describe('inherited functions', function () { it('exists and is a function', function () { diff --git a/test/spec/modules/beachfrontBidAdapter_spec.js b/test/spec/modules/beachfrontBidAdapter_spec.js index 21e175a5b82..edaff2c88ce 100644 --- a/test/spec/modules/beachfrontBidAdapter_spec.js +++ b/test/spec/modules/beachfrontBidAdapter_spec.js @@ -1,9 +1,21 @@ import { expect } from 'chai'; import { spec, VIDEO_ENDPOINT, BANNER_ENDPOINT, OUTSTREAM_SRC, DEFAULT_MIMES } from 'modules/beachfrontBidAdapter'; import * as utils from 'src/utils'; +const adloader = require('src/adloader'); describe('BeachfrontAdapter', function () { let bidRequests; + let loadScriptStub; + + before(function() { + loadScriptStub = sinon.stub(adloader, 'loadScript').callsFake((...args) => { + args[1](); + }); + }); + + after(function() { + loadScriptStub.restore(); + }); beforeEach(function () { bidRequests = [ diff --git a/test/spec/modules/consentManagement_spec.js b/test/spec/modules/consentManagement_spec.js index 1303d9cd718..6af8c8a4478 100644 --- a/test/spec/modules/consentManagement_spec.js +++ b/test/spec/modules/consentManagement_spec.js @@ -678,8 +678,8 @@ describe('consentManagement', function () { // Run tests with JSON response and String response // from CMP window postMessage listener. - // testIFramedPage('with/JSON response', false); - // testIFramedPage('with/String response', true); + testIFramedPage('with/JSON response', false); + testIFramedPage('with/String response', true); function testIFramedPage(testName, messageFormatString) { it(`should return the consent string from a postmessage + addEventListener response - ${testName}`, (done) => { diff --git a/test/spec/modules/rockyouBidAdapter_spec.js b/test/spec/modules/rockyouBidAdapter_spec.js index 65d87566c26..81404189802 100644 --- a/test/spec/modules/rockyouBidAdapter_spec.js +++ b/test/spec/modules/rockyouBidAdapter_spec.js @@ -1,9 +1,21 @@ import { expect } from 'chai'; import { spec, internals } from 'modules/rockyouBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; +const adloader = require('src/adloader'); describe('RockYouAdapter', function () { const adapter = newBidder(spec); + let loadScriptStub; + + before(function() { + loadScriptStub = sinon.stub(adloader, 'loadScript').callsFake((...args) => { + args[1](); + }); + }); + + after(function() { + loadScriptStub.restore(); + }); describe('bid validator', function () { it('rejects a bid that is missing the placementId', function () { diff --git a/test/spec/modules/vubleBidAdapter_spec.js b/test/spec/modules/vubleBidAdapter_spec.js index 8996c1b4957..0a23965b22b 100644 --- a/test/spec/modules/vubleBidAdapter_spec.js +++ b/test/spec/modules/vubleBidAdapter_spec.js @@ -3,8 +3,21 @@ import {expect} from 'chai'; import {spec as adapter} from 'modules/vubleBidAdapter'; import * as utils from 'src/utils'; +const adloader = require('../../../src/adloader'); describe('VubleAdapter', function () { + let loadScriptStub; + + before(function() { + loadScriptStub = sinon.stub(adloader, 'loadScript').callsFake((...args) => { + args[1](); + }); + }); + + after(function() { + loadScriptStub.restore(); + }); + describe('Check methods existance', function () { it('exists and is a function', function () { expect(adapter.isBidRequestValid).to.exist.and.to.be.a('function'); diff --git a/test/spec/modules/xhbBidAdapter_spec.js b/test/spec/modules/xhbBidAdapter_spec.js index e48d3011ed2..9ef90492acc 100644 --- a/test/spec/modules/xhbBidAdapter_spec.js +++ b/test/spec/modules/xhbBidAdapter_spec.js @@ -4,9 +4,21 @@ import { newBidder } from 'src/adapters/bidderFactory'; import { deepClone } from 'src/utils'; const ENDPOINT = '//ib.adnxs.com/ut/v3/prebid'; +const adloader = require('../../../src/adloader'); describe('xhbAdapter', function () { const adapter = newBidder(spec); + let loadScriptStub; + + before(function() { + loadScriptStub = sinon.stub(adloader, 'loadScript').callsFake((...args) => { + args[1](); + }); + }); + + after(function() { + loadScriptStub.restore(); + }); describe('inherited functions', function () { it('exists and is a function', function () { diff --git a/test/spec/modules/zedoBidAdapter_spec.js b/test/spec/modules/zedoBidAdapter_spec.js index abb0a5c97fb..1bae0997749 100644 --- a/test/spec/modules/zedoBidAdapter_spec.js +++ b/test/spec/modules/zedoBidAdapter_spec.js @@ -1,7 +1,20 @@ import { expect } from 'chai'; import { spec } from 'modules/zedoBidAdapter'; +const adloader = require('src/adloader'); describe('The ZEDO bidding adapter', function () { + let loadScriptStub; + + before(function() { + loadScriptStub = sinon.stub(adloader, 'loadScript').callsFake((...args) => { + args[1](); + }); + }); + + after(function() { + loadScriptStub.restore(); + }); + describe('isBidRequestValid', function () { it('should return false when given an invalid bid', function () { const bid = { @@ -245,7 +258,6 @@ describe('The ZEDO bidding adapter', function () { expect(bids[0].vastXml).to.not.equal(''); expect(bids[0].ad).to.be.an('undefined'); expect(bids[0].renderer).not.to.be.an('undefined'); - bids[0].renderer.render(bids[0]); }); }); diff --git a/test/spec/unit/core/bidderFactory_spec.js b/test/spec/unit/core/bidderFactory_spec.js index 6cc4a0b172c..bc815a8afd2 100644 --- a/test/spec/unit/core/bidderFactory_spec.js +++ b/test/spec/unit/core/bidderFactory_spec.js @@ -7,6 +7,7 @@ import { userSync } from 'src/userSync' import * as utils from 'src/utils'; import { config } from 'src/config'; +const adloader = require('src/adloader'); const CODE = 'sampleBidder'; const MOCK_BIDS_REQUEST = { bids: [ @@ -34,6 +35,13 @@ describe('bidders created by newBidder', function () { let bidder; let addBidResponseStub; let doneStub; + let loadScriptStub; + + before(function() { + loadScriptStub = sinon.stub(adloader, 'loadScript').callsFake((...args) => { + args[1](); + }); + }); beforeEach(function () { spec = { @@ -48,6 +56,10 @@ describe('bidders created by newBidder', function () { doneStub = sinon.stub(); }); + after(function() { + loadScriptStub.restore(); + }); + describe('when the ajax response is irrelevant', function () { let ajaxStub;