Skip to content

Commit

Permalink
stub img creation as well to prevent call in justpremium
Browse files Browse the repository at this point in the history
  • Loading branch information
snapwich committed Oct 26, 2018
1 parent 57ae143 commit 60270e0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
16 changes: 11 additions & 5 deletions modules/justpremiumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ export const spec = {

}

export let pixel = {
fire(url) {
let img = document.createElement('img')
img.src = url
img.id = 'jp-pixel-track'
img.style.cssText = 'display:none !important;'
document.body.appendChild(img)
}
};

function track (data, payload, type) {
let pubUrl = ''

Expand All @@ -147,11 +157,7 @@ ru=${encodeURIComponent(pubUrl)}&tt=&siw=&sh=${payload.sh}&sw=${payload.sw}&wh=$
sd=&_c=&et=&aid=&said=&ei=&fc=&sp=&at=bidder&cid=&ist=&mg=&dl=&dlt=&ev=&vt=&zid=${payload.id}&dr=${duration}&di=&pr=&
cw=&ch=&nt=&st=&jp=${encodeURIComponent(JSON.stringify(jp))}&ty=${type}`

let img = document.createElement('img')
img.src = pixelUrl
img.id = 'jp-pixel-track'
img.style.cssText = 'display:none !important;'
document.body.appendChild(img)
pixel.fire(pixelUrl);
}

function findBid (params, bids) {
Expand Down
8 changes: 4 additions & 4 deletions test/spec/modules/justpremiumBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { expect } from 'chai'
import { spec } from 'modules/justpremiumBidAdapter'
import { spec, pixel } from 'modules/justpremiumBidAdapter'

describe('justpremium adapter', function () {
let sandbox;
let appendChildStub;
let pixelStub;

beforeEach(function() {
sandbox = sinon.sandbox.create();
appendChildStub = sandbox.stub(document.body, 'appendChild');
pixelStub = sandbox.stub(pixel, 'fire');
});

afterEach(function() {
Expand Down Expand Up @@ -167,7 +167,7 @@ describe('justpremium adapter', function () {
'timeout': 1
}]);

expect(appendChildStub.calledOnce).to.equal(true);
expect(pixelStub.calledOnce).to.equal(true);

done()
})
Expand Down
7 changes: 5 additions & 2 deletions test/spec/modules/uolBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ describe('UOL Bid Adapter', function () {

beforeEach(function() {
sandbox = sinon.sandbox.create();
getCurrentPositionStub = sandbox.stub(navigator.geolocation, 'getCurrentPosition');
queryStub = sandbox.stub(navigator.permissions, 'query');
});

afterEach(function() {
Expand Down Expand Up @@ -159,6 +157,11 @@ describe('UOL Bid Adapter', function () {
describe('buildRequest geolocation param', function () { // shall only be tested if browser engine supports geolocation and permissions API.
let geolocation = { lat: 4, long: 3, timestamp: 123121451 };

beforeEach(function() {
getCurrentPositionStub = sandbox.stub(navigator.geolocation, 'getCurrentPosition');
queryStub = sandbox.stub(navigator.permissions, 'query');
});

it('should not contain user coordinates if browser doesnt support permission query', function () {
localStorage.setItem('uolLocationTracker', JSON.stringify(geolocation));
navigator.permissions.query = undefined;
Expand Down

0 comments on commit 60270e0

Please sign in to comment.