Skip to content

Commit 897ba68

Browse files
authored
Merge pull request #67 from theonion/no-sizemapping
2 parents f091eb1 + 41ef9e5 commit 897ba68

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/manager.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,9 @@ AdManager.prototype.configureAd = function (element) {
517517
if (adUnitConfig.outOfPage) {
518518
slot = this.googletag.defineOutOfPageSlot(adUnitPath, element.id);
519519
} else {
520-
slot = this.googletag.defineSlot(adUnitPath, [], element.id);
521-
sizeMap = this.buildSizeMap(adUnitConfig.sizes);
522-
slot.defineSizeMapping(sizeMap);
523-
slot.activeSizes = this.adUnitSizes(adUnitConfig.sizes);
520+
var activeSizes = this.adUnitSizes(adUnitConfig.sizes);
521+
slot = this.googletag.defineSlot(adUnitPath, activeSizes, element.id);
522+
slot.activeSizes = activeSizes;
524523
}
525524

526525
if (!element.dataset) {

src/manager.spec.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -924,11 +924,12 @@ describe('AdManager', function() {
924924
});
925925

926926
describe('#configureAd', function() {
927-
var adSlot1, container1;
927+
var adSlot1, container1, sizes;
928928

929929
beforeEach(function() {
930+
sizes = adManager.adUnits.units.header.sizes;
930931
TestHelper.stub(adManager, 'getAdUnitCode').returns('/4246/fmg.onion');
931-
TestHelper.stub(adManager, 'buildSizeMap').returns(adManager.adUnits.units.header.sizes);
932+
TestHelper.stub(adManager, 'adUnitSizes').returns(sizes);
932933
container1 = document.createElement('div');
933934
adSlot1 = document.createElement('div');
934935
adSlot1.className = 'dfp';
@@ -970,7 +971,6 @@ describe('AdManager', function() {
970971
TestHelper.stub(adManager, 'generateId').returns('dfp-ad-1');
971972
TestHelper.stub(window.googletag, 'pubads').returns('Stub pub ads');
972973
slotStub = {
973-
defineSizeMapping: sinon.spy(),
974974
addService: sinon.spy(),
975975
setTargeting: function () {}
976976
};
@@ -985,11 +985,11 @@ describe('AdManager', function() {
985985
});
986986

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

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

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

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

10261025
it('- sets whether the ad should be eager loaded', function() {
@@ -1457,7 +1456,7 @@ describe('AdManager', function() {
14571456
var setupRefs = adSlotSetup();
14581457
adSlot = setupRefs.adSlot1;
14591458
});
1460-
1459+
14611460
it('- calls fetchIasTargeting when enabled', function() {
14621461
adManager = AdManagerWrapper.init({ iasEnabled: true });
14631462
TestHelper.stub(adManager, 'fetchIasTargeting');

0 commit comments

Comments
 (0)