Skip to content

Commit

Permalink
add stub for adloader.loadScript in various adapter test files (prebi…
Browse files Browse the repository at this point in the history
…d#3193)

* add stub for adloader in various adapter test files

* remove unneeded commented line of code
  • Loading branch information
jsnellbaker authored and Pedro López Jiménez committed Mar 18, 2019
1 parent b23aebc commit a3bd17f
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 3 deletions.
12 changes: 12 additions & 0 deletions test/spec/modules/appnexusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
12 changes: 12 additions & 0 deletions test/spec/modules/beachfrontBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
4 changes: 2 additions & 2 deletions test/spec/modules/consentManagement_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
12 changes: 12 additions & 0 deletions test/spec/modules/rockyouBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down
13 changes: 13 additions & 0 deletions test/spec/modules/vubleBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
12 changes: 12 additions & 0 deletions test/spec/modules/xhbBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
14 changes: 13 additions & 1 deletion test/spec/modules/zedoBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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]);
});
});

Expand Down
12 changes: 12 additions & 0 deletions test/spec/unit/core/bidderFactory_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -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 = {
Expand All @@ -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;

Expand Down

0 comments on commit a3bd17f

Please sign in to comment.