Skip to content

Commit

Permalink
Merge pull request #67 from theonion/no-sizemapping
Browse files Browse the repository at this point in the history
  • Loading branch information
BriceShatzer authored Jun 20, 2018
2 parents f091eb1 + 41ef9e5 commit 897ba68
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
7 changes: 3 additions & 4 deletions src/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,9 @@ AdManager.prototype.configureAd = function (element) {
if (adUnitConfig.outOfPage) {
slot = this.googletag.defineOutOfPageSlot(adUnitPath, element.id);
} else {
slot = this.googletag.defineSlot(adUnitPath, [], element.id);
sizeMap = this.buildSizeMap(adUnitConfig.sizes);
slot.defineSizeMapping(sizeMap);
slot.activeSizes = this.adUnitSizes(adUnitConfig.sizes);
var activeSizes = this.adUnitSizes(adUnitConfig.sizes);
slot = this.googletag.defineSlot(adUnitPath, activeSizes, element.id);
slot.activeSizes = activeSizes;
}

if (!element.dataset) {
Expand Down
17 changes: 8 additions & 9 deletions src/manager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -924,11 +924,12 @@ describe('AdManager', function() {
});

describe('#configureAd', function() {
var adSlot1, container1;
var adSlot1, container1, sizes;

beforeEach(function() {
sizes = adManager.adUnits.units.header.sizes;
TestHelper.stub(adManager, 'getAdUnitCode').returns('/4246/fmg.onion');
TestHelper.stub(adManager, 'buildSizeMap').returns(adManager.adUnits.units.header.sizes);
TestHelper.stub(adManager, 'adUnitSizes').returns(sizes);
container1 = document.createElement('div');
adSlot1 = document.createElement('div');
adSlot1.className = 'dfp';
Expand Down Expand Up @@ -970,7 +971,6 @@ describe('AdManager', function() {
TestHelper.stub(adManager, 'generateId').returns('dfp-ad-1');
TestHelper.stub(window.googletag, 'pubads').returns('Stub pub ads');
slotStub = {
defineSizeMapping: sinon.spy(),
addService: sinon.spy(),
setTargeting: function () {}
};
Expand All @@ -985,11 +985,11 @@ describe('AdManager', function() {
});

it('- defines the slot on the google tag object', function() {
expect(window.googletag.defineSlot.calledWith('/4246/fmg.onion', [], 'dfp-ad-1')).to.be.true;
expect(window.googletag.defineSlot.calledWith('/4246/fmg.onion', sizes, 'dfp-ad-1')).to.be.true;
});

it('- defines the size mapping on the google tag object', function() {
expect(slotStub.defineSizeMapping.calledWith(adManager.adUnits.units.header.sizes)).to.be.true;
it('- defines activeSizes mapped to the google tag object', function() {
expect(slotStub.activeSizes).to.deep.equal(sizes);
});

it('- returns the configured slot and adds it to the slots object', function() {
Expand All @@ -1007,7 +1007,6 @@ describe('AdManager', function() {
TestHelper.stub(adManager, 'generateId').returns('dfp-ad-1');
TestHelper.stub(window.googletag, 'pubads').returns('Stub pub ads');
slotStub = {
defineSizeMapping: sinon.spy(),
addService: sinon.spy(),
setTargeting: function () {}
};
Expand All @@ -1020,7 +1019,7 @@ describe('AdManager', function() {
});

it('- defines the slot on the google tag object', function() {
expect(window.googletag.defineSlot.calledWith('/4246/fmg.onion/front', [], 'dfp-ad-1')).to.be.true;
expect(window.googletag.defineSlot.calledWith('/4246/fmg.onion/front', sizes, 'dfp-ad-1')).to.be.true;
});

it('- sets whether the ad should be eager loaded', function() {
Expand Down Expand Up @@ -1457,7 +1456,7 @@ describe('AdManager', function() {
var setupRefs = adSlotSetup();
adSlot = setupRefs.adSlot1;
});

it('- calls fetchIasTargeting when enabled', function() {
adManager = AdManagerWrapper.init({ iasEnabled: true });
TestHelper.stub(adManager, 'fetchIasTargeting');
Expand Down

0 comments on commit 897ba68

Please sign in to comment.