Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Isolate unit tests by stubbing external lib (prebid#1308)
  • Loading branch information
Swiiip authored and Yann-Pravo committed Jul 6, 2017
1 parent 4c92f9c commit 6a7c95e
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/spec/adapters/criteo_spec.js
Expand Up @@ -2,10 +2,55 @@

import Adapter from '../../../src/adapters/criteo';
import bidManager from '../../../src/bidmanager';
import {ajax} from '../../../src/ajax'
import {expect} from 'chai';

var CONSTANTS = require('../../../src/constants');

/* ------------ Publishertag stub begin ------------ */
before(() => {
window.Criteo = {
PubTag: {
DirectBidding: {
DirectBiddingSlot: function DirectBiddingSlot(placementCode, zoneid, nativeCallback, transactionId, sizes) {
return {
impId: placementCode
};
},

DirectBiddingUrlBuilder: function DirectBiddingUrlBuilder(isAudit) { return {} },

DirectBiddingEvent: function DirectBiddingEvent(profileId, urlBuilder, slots, success, error, timeout) {
return {
slots: slots,
eval: function () {
var callbacks = {
error: error,
success: success
}
ajax('//bidder.criteo.com/cdb', callbacks)
}
}
}
}
}
};

window.criteo_pubtag = window.criteo_pubtag || {
push: function (event) {
event.eval();
}
}

window.Criteo.events = window.Criteo.events || [];
window.Criteo.events.push = function (elem) {
if (typeof elem === 'function') {
elem();
}
};
});
/* ------------ Publishertag stub end ------------ */

describe('criteo adapter test', () => {
let adapter;
let stubAddBidResponse;
Expand Down

0 comments on commit 6a7c95e

Please sign in to comment.