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

add stub for adloader.loadScript in various adapter test files #3193

Merged
merged 2 commits into from
Oct 17, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
15 changes: 14 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,7 @@ 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]);
// 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