Skip to content

Commit

Permalink
Merge pull request #19 from taboola/on-bid-won-taboola
Browse files Browse the repository at this point in the history
on-bid-won
  • Loading branch information
ahmadlob authored Dec 26, 2022
2 parents fb09945 + 73ead27 commit 72658c3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
8 changes: 7 additions & 1 deletion modules/taboolaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER} from '../src/mediaTypes.js';
import {config} from '../src/config.js';
import {getWindowSelf} from '../src/utils.js'
import {getWindowSelf, replaceAuctionPrice} from '../src/utils.js'
import {getStorageManager} from '../src/storageManager.js';
import { ajax } from '../src/ajax.js';

const BIDDER_CODE = 'taboola';
const GVLID = 42;
Expand Down Expand Up @@ -152,6 +153,11 @@ export const spec = {

return bidResponses.map((bidResponse) => getBid(bids, currency, bidResponse)).filter(Boolean);
},
onBidWon: (bid) => {
if (bid.nurl) {
ajax(replaceAuctionPrice(bid.nurl, bid.originalCpm));
}
},
getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) {
const syncs = []
const queryParams = [];
Expand Down
26 changes: 26 additions & 0 deletions test/spec/modules/taboolaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {expect} from 'chai';
import {spec, internal, END_POINT_URL, userData} from 'modules/taboolaBidAdapter.js';
import {config} from '../../../src/config'
import * as utils from '../../../src/utils'
import {server} from '../../mocks/xhr'

describe('Taboola Adapter', function () {
let hasLocalStorage, cookiesAreEnabled, getDataFromLocalStorage, localStorageIsEnabled, getCookie, commonBidRequest;
Expand Down Expand Up @@ -91,6 +92,31 @@ describe('Taboola Adapter', function () {
})
})

describe('onBidWon', function () {
it('onBidWon exist as a function', () => {
expect(spec.onBidWon).to.exist.and.to.be.a('function');
});

it('should resolve price macro in nurl', function () {
const nurl = 'http://win.example.com/${AUCTION_PRICE}';
const bid = {
requestId: 1,
cpm: 2,
originalCpm: 3.4,
creativeId: 1,
ttl: 60,
netRevenue: true,
mediaType: 'banner',
ad: '...',
width: 300,
height: 250,
nurl: nurl
}
spec.onBidWon(bid);
expect(server.requests[0].url).to.equals('http://win.example.com/3.4')
});
});

describe('buildRequests', function () {
const defaultBidRequest = {
...createBidRequest(),
Expand Down

0 comments on commit 72658c3

Please sign in to comment.