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

on-bid-won #19

Merged
merged 2 commits into from
Dec 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
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