Skip to content

Commit

Permalink
add assertions for viewable, onLoad, onRefresh optional callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
bcomerford committed Oct 17, 2018
1 parent b2beb59 commit d93aa4a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"package.json"
],
"dependencies": {
"bulbs-public-ads-manager": "https://github.com/theonion/bulbs-public-ads-manager.git#9.10.0"
"bulbs-public-ads-manager": "https://github.com/theonion/bulbs-public-ads-manager.git#9.9.0"
}
}
11 changes: 5 additions & 6 deletions src/ad-units.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
function noop () { }

var AdUnits = {
headerSlotRenderEnded: noop,
headerSlotImpressionViewable: noop,
headerSlotOnLoad: noop
optionalCallback: function () {}
};

AdUnits.units = {
Expand All @@ -25,9 +23,10 @@ AdUnits.units = {
[[728, 0], [[1,1], [728, 90], [1280, 720]]],
[[0, 0], [[1,1], [320, 50], [300, 250], [1280, 720]]]
],
onSlotRenderEnded: AdUnits.headerSlotRenderEnded,
onImpressionViewable: AdUnits.headerSlotImpressionViewable,
onLoad: AdUnits.headerSlotOnLoad,
onSlotRenderEnded: AdUnits.optionalCallback,
onImpressionViewable: AdUnits.optionalCallback,
onLoad: AdUnits.optionalCallback,
onRefresh: AdUnits.optionalCallback,
'prebid': {
'bids': [
{
Expand Down
19 changes: 17 additions & 2 deletions src/manager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,12 @@ describe('AdManager', function() {

it('- emits a dfpImpressionViewable event', function() {
expect(eventSpy).to.have.been.called;
});

it('- should invoke optional onImpressionViewable callback if provided', function () {
TestHelper.stub(adManager.adUnits.units.header, 'onImpressionViewable');
adManager.onImpressionViewable(event);
expect(adManager.adUnits.units.header.onImpressionViewable.called).to.be.true;
});
});

Expand Down Expand Up @@ -562,8 +566,6 @@ describe('AdManager', function() {
eventSpy = sinon.spy();
adElement.addEventListener('dfpSlotOnload', eventSpy);
adManager.onSlotRenderEnded(event);
adManager.onImpressionViewable(event);
adManager.onSlotOnload(event);
});

afterEach(function() {
Expand All @@ -573,6 +575,12 @@ describe('AdManager', function() {
it('- emits a dfpSlotOnload event', function() {
expect(eventSpy).to.have.been.called;
});

it('- should invoke optional onLoad callback if provided', function () {
TestHelper.stub(adManager.adUnits.units.header, 'onLoad');
adManager.onSlotOnload(event);
expect(adManager.adUnits.units.header.onLoad.called).to.be.true;
});
});

describe('#generateId', function() {
Expand Down Expand Up @@ -1529,6 +1537,7 @@ describe('AdManager', function() {
adSlot1 = document.createElement('div');
adSlot1.id = 'dfp-ad-1';
adSlot1.className = 'dfp';
adSlot1.dataset.adUnit = 'header';
container1.appendChild(adSlot1);
baseContainer.appendChild(container1);
document.body.appendChild(baseContainer);
Expand Down Expand Up @@ -1597,6 +1606,12 @@ describe('AdManager', function() {
expect(adManager.refreshSlots.calledWith([stubSlot])).to.be.true;
});

it('- should invoke optional callback onRefresh if provided', function () {
TestHelper.stub(adManager.adUnits.units.header, 'onRefresh');
adManager.refreshSlot(adSlot);
expect(adManager.adUnits.units.header.onRefresh.called).to.be.true;
});

});

describe('#refreshSlots', function() {
Expand Down

0 comments on commit d93aa4a

Please sign in to comment.