Skip to content

Commit

Permalink
test debug
Browse files Browse the repository at this point in the history
  • Loading branch information
ym-abaranov committed Jan 28, 2022
1 parent d36b6eb commit 46d41b3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
17 changes: 6 additions & 11 deletions modules/yieldmoSyntheticInventoryModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ function collectData(placementId, consentDataObj) {
const connection = window.navigator.connection || {};
const description = Array.prototype.slice.call(document.getElementsByTagName('meta'))
.filter((meta) => meta.getAttribute('name') === 'description')[0];
const pageDimensions = {
density: window.top.devicePixelRatio || 0,
height: window.top.screen.height || window.top.screen.availHeight || window.top.outerHeight || window.top.innerHeight || 481,
width: window.top.screen.width || window.top.screen.availWidth || window.top.outerWidth || window.top.innerWidth || 321,
};

return {
bust: timeStamp,
Expand All @@ -89,15 +84,15 @@ function collectData(placementId, consentDataObj) {
p: placementId,
description: description ? description.content.substring(0, 1000) : '',
title: document.title,
scrd: pageDimensions.density,
h: pageDimensions.height,
w: pageDimensions.width,
scrd: window.top.devicePixelRatio || 0,
h: window.top.screen.height || window.top.screen.availHeight || window.top.outerHeight || window.top.innerHeight || 481,
w: window.top.screen.width || window.top.screen.availWidth || window.top.outerWidth || window.top.innerWidth || 321,
pft: timeStamp,
ct: timeStamp,
connect: connection.effectiveType,
bwe: connection.downlink ? connection.downlink + 'Mb/sec' : '',
connect: typeof connection.effectiveType !== 'undefined' ? connection.effectiveType : undefined,
bwe: typeof connection.downlink !== 'undefined' ? connection.downlink + 'Mb/sec' : undefined,
rtt: typeof connection.rtt !== 'undefined' ? String(connection.rtt) : undefined,
sd: connection.saveData,
sd: typeof connection.saveData !== 'undefined' ? String(connection.saveData) : undefined,
us_privacy: (consentDataObj.usp && consentDataObj.usp.usPrivacy) || '',
cmp: (consentDataObj.cmp && consentDataObj.cmp.tcString) || ''
};
Expand Down
33 changes: 17 additions & 16 deletions test/spec/modules/yieldmoSyntheticInventoryModule_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,13 @@ describe('Yieldmo Synthetic Inventory Module', function() {
const title = 'Test title value';
const ajaxStub = setAjaxStub((url, callbackObj) => {});
const documentStubTitle = sandbox.stub(document, 'title').value(title);
const pageDimensions = {
scrd: String(window.top.devicePixelRatio || 0),
h: String(window.top.screen.height || window.screen.top.availHeight || window.top.outerHeight || window.top.innerHeight || 481),
w: String(window.top.screen.width || window.screen.top.availWidth || window.top.outerWidth || window.top.innerWidth || 321),
};
const connection = window.navigator.connection || {};
const connectToCompare = {
connect: String(connection.effectiveType),
bwe: String(connection.downlink ? connection.downlink + 'Mb/sec' : ''),
rtt: typeof connection.rtt !== 'undefined' ? String(connection.rtt) : undefined,
sd: String(connection.saveData),
}

init(mockedYmConfig);
const queryParams = JSON.parse(JSON.stringify(getQuearyParamsFromUrl(ajaxStub.getCall(0).args[0])));
const queryParams = getQuearyParamsFromUrl(ajaxStub.getCall(0).args[0]);
const timeStamp = queryParams.bust;

expect(queryParams).to.eql({
const paramsToCompare = {
title,
_s: '1',
dnt: 'false',
Expand All @@ -134,9 +123,21 @@ describe('Yieldmo Synthetic Inventory Module', function() {
bust: timeStamp,
pft: timeStamp,
ct: timeStamp,
...connectToCompare,
...pageDimensions,
});
connect: typeof connection.effectiveType !== 'undefined' ? connection.effectiveType : undefined,
bwe: typeof connection.downlink !== 'undefined' ? connection.downlink + 'Mb/sec' : undefined,
rtt: typeof connection.rtt !== 'undefined' ? String(connection.rtt) : undefined,
sd: typeof connection.saveData !== 'undefined' ? String(connection.saveData) : undefined,
scrd: String(window.top.devicePixelRatio || 0),
h: String(window.top.screen.height || window.screen.top.availHeight || window.top.outerHeight || window.top.innerHeight || 481),
w: String(window.top.screen.width || window.screen.top.availWidth || window.top.outerWidth || window.top.innerWidth || 321),
};

/* eslint-disable no-console */
console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!', ajaxStub.getCall(0).args[0]);
console.log('#############################', getQuearyParamsFromUrl(ajaxStub.getCall(0).args[0]));
console.log('_____________________________', Object.entries(queryParams), Object.entries(paramsToCompare))

expect(queryParams).to.eql(paramsToCompare);
});

it('should send ad request to ad server', () => {
Expand Down

0 comments on commit 46d41b3

Please sign in to comment.