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

Added customSlotMatching test for setTargetingForGPTAsync #4709

Merged
Merged
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
27 changes: 27 additions & 0 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,33 @@ describe('Unit: Prebid Module', function () {
assert.deepEqual(slots[1].spySetTargeting.args, targeting, 'google tag targeting options not matching');
});

it('should set googletag targeting keys to specific slot with customSlotMatching', function () {
// same ad unit code but two differnt divs
// we make sure we can set targeting for a specific one with customSlotMatching

$$PREBID_GLOBAL$$.setConfig({ enableSendAllBids: false });

var slots = [
new Slot('div-id-one', config.adUnitCodes[0]),
new Slot('div-id-two', config.adUnitCodes[0]),
new Slot(config.adUnitElementIDs[2], config.adUnitCodes[2])
];

slots[0].spySetTargeting.resetHistory();
slots[1].spySetTargeting.resetHistory();
window.googletag.pubads().setSlots(slots);

$$PREBID_GLOBAL$$.setTargetingForGPTAsync([config.adUnitCodes[0]], (slot) => {
return (adUnitCode) => {
return slots[0].getSlotElementId() === slot.getSlotElementId();
};
});

var expected = getTargetingKeys();
expect(slots[0].spySetTargeting.args).to.deep.contain.members(expected);
expect(slots[1].spySetTargeting.args).to.not.deep.contain.members(expected);
});

it('should set targeting when passed a string ad unit code with enableSendAllBids', function () {
var slots = createSlotArray();
window.googletag.pubads().setSlots(slots);
Expand Down