Skip to content
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

Eplanning & Adapter Manager: backport test changes to 5.20.x-legacy #7819

Merged
merged 1 commit into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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