Skip to content

Commit

Permalink
backport changes (#7819)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHuie authored Dec 7, 2021
1 parent ac9da94 commit 548a439
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
16 changes: 8 additions & 8 deletions test/spec/modules/eplanningBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,26 +328,25 @@ describe('E-Planning Adapter', function () {
describe('buildRequests', function () {
let bidRequests = [validBid];
let sandbox;
let getWindowSelfStub;
let innerWidth;
beforeEach(() => {
sandbox = sinon.sandbox.create();
getWindowSelfStub = sandbox.stub(utils, 'getWindowSelf');
getWindowSelfStub.returns(createWindow(800));
});

afterEach(() => {
sandbox.restore();
});

const createWindow = () => {
const createWindow = (innerWidth) => {
const win = {};
win.self = win;
win.innerWidth = 1025;
win.innerWidth = innerWidth;
return win;
};

function setupSingleWindow(sandBox) {
const win = createWindow();
sandBox.stub(utils, 'getWindowSelf').returns(win);
}

it('should create the url correctly', function () {
const url = spec.buildRequests(bidRequests, bidderRequest).url;
expect(url).to.equal('https://pbjs.e-planning.net/pbjs/1/' + CI + '/1/localhost/ROS');
Expand Down Expand Up @@ -516,7 +515,8 @@ describe('E-Planning Adapter', function () {

it('should return the e parameter with a value according to the sizes in order corresponding to the desktop priority list of the ad units', function () {
let bidRequestsPrioritySizes = [validBidExistingSizesInPriorityListForDesktop];
setupSingleWindow(sandbox);
// overwrite default innerWdith for tests with a larger one we consider "Desktop" or NOT Mobile
getWindowSelfStub.returns(createWindow(1025));
const e = spec.buildRequests(bidRequestsPrioritySizes, bidderRequest).data.e;
expect(e).to.equal('300x250_0:300x250,300x600,970x250');
});
Expand Down
7 changes: 5 additions & 2 deletions test/spec/unit/core/adapterManager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1697,14 +1697,17 @@ describe('adapterManager tests', function () {
});

describe('sizeMapping', function () {
let sandbox;
beforeEach(function () {
sandbox = sinon.sandbox.create();
allS2SBidders.length = 0;
clientTestAdapters.length = 0;
sinon.stub(window, 'matchMedia').callsFake(() => ({matches: true}));
// always have matchMedia return true for us
sandbox.stub(utils.getWindowTop(), 'matchMedia').callsFake(() => ({matches: true}));
});

afterEach(function () {
matchMedia.restore();
sandbox.restore();
config.resetConfig();
setSizeConfig([]);
});
Expand Down

0 comments on commit 548a439

Please sign in to comment.