-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Media.net Adapter Improvements #2634
Changes from 1 commit
d746d01
06a82aa
4e7a59a
79560e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -501,12 +501,8 @@ describe('Media.net bid adapter', () => { | |
|
||
describe('buildRequests', () => { | ||
let sandbox; | ||
let mock; | ||
before(() => { | ||
sandbox = sinon.sandbox.create(); | ||
mock = sinon.mock(window); | ||
window.innerWidth = 1000; | ||
window.innerHeight = 1000; | ||
let documentStub = sandbox.stub(document, 'getElementById'); | ||
let boundingRect = { | ||
top: 50, | ||
|
@@ -520,10 +516,14 @@ describe('Media.net bid adapter', () => { | |
documentStub.withArgs('div-gpt-ad-1460505748561-0').returns({ | ||
getBoundingClientRect: () => boundingRect | ||
}); | ||
let windowSizeStub = sandbox.stub(spec, 'getWindowSize'); | ||
windowSizeStub.returns({ | ||
w: 1000, | ||
h: 1000 | ||
}); | ||
}); | ||
after(() => { | ||
sandbox.restore(); | ||
mock.restore(); | ||
}); | ||
it('should build valid payload on bid', () => { | ||
let requestObj = spec.buildRequests(VALID_BID_REQUEST, VALID_AUCTIONDATA); | ||
|
@@ -566,17 +566,16 @@ describe('Media.net bid adapter', () => { | |
}); | ||
|
||
describe('slot visibility', () => { | ||
let mock; | ||
let sandbox = sinon.sandbox.create(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should just put the sandbox creation in the outermost edit - just edited to say that they should be in a |
||
before(() => { | ||
mock = sinon.mock(window); | ||
window.innerWidth = 1000; | ||
window.innerHeight = 1000; | ||
}); | ||
after(() => { | ||
mock.restore(); | ||
let windowSizeStub = sandbox.stub(spec, 'getWindowSize'); | ||
windowSizeStub.returns({ | ||
w: 1000, | ||
h: 1000 | ||
}); | ||
}); | ||
after(() => sandbox.restore()); | ||
it('slot visibility should be 2 and ratio 0 when ad unit is BTF', () => { | ||
let sandbox = sinon.sandbox.create(); | ||
let documentStub = sandbox.stub(document, 'getElementById'); | ||
let boundingRect = { | ||
top: 1010, | ||
|
@@ -590,14 +589,14 @@ describe('Media.net bid adapter', () => { | |
documentStub.withArgs('div-gpt-ad-1460505748561-0').returns({ | ||
getBoundingClientRect: () => boundingRect | ||
}); | ||
|
||
let bidReq = spec.buildRequests(VALID_BID_REQUEST, VALID_AUCTIONDATA); | ||
let data = JSON.parse(bidReq.data); | ||
expect(data.imp[0].ext.visibility).to.equal(2); | ||
expect(data.imp[0].ext.viewability).to.equal(0); | ||
sandbox.restore(); | ||
documentStub.restore(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the |
||
}); | ||
it('slot visibility should be 2 and ratio < 0.5 when ad unit is partially inside viewport', () => { | ||
let sandbox = sinon.sandbox.create(); | ||
let documentStub = sandbox.stub(document, 'getElementById'); | ||
let boundingRect = { | ||
top: 990, | ||
|
@@ -615,10 +614,9 @@ describe('Media.net bid adapter', () => { | |
let data = JSON.parse(bidReq.data); | ||
expect(data.imp[0].ext.visibility).to.equal(2); | ||
expect(data.imp[0].ext.viewability).to.equal(100 / 75000); | ||
sandbox.restore(); | ||
documentStub.restore(); | ||
}); | ||
it('slot visibility should be 1 and ratio > 0.5 when ad unit mostly in viewport', () => { | ||
let sandbox = sinon.sandbox.create(); | ||
let documentStub = sandbox.stub(document, 'getElementById'); | ||
let boundingRect = { | ||
top: 800, | ||
|
@@ -636,7 +634,7 @@ describe('Media.net bid adapter', () => { | |
let data = JSON.parse(bidReq.data); | ||
expect(data.imp[0].ext.visibility).to.equal(1); | ||
expect(data.imp[0].ext.viewability).to.equal(40000 / 75000); | ||
sandbox.restore(); | ||
documentStub.restore(); | ||
}); | ||
it('co-ordinates should not be sent and slot visibility should be 0 when ad unit is not present', () => { | ||
let bidReq = spec.buildRequests(VALID_BID_REQUEST, VALID_AUCTIONDATA); | ||
|
@@ -679,7 +677,7 @@ describe('Media.net bid adapter', () => { | |
it('should not push response if no-bid', () => { | ||
let validBids = []; | ||
let bids = spec.interpretResponse(SERVER_RESPONSE_NOBID, []); | ||
expect(bids).to.deep.equal(validBids) | ||
expect(bids).to.deep.equal(validBids); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To get the distance from the top left corner of the document (as opposed to viewport) this code should be