@aller/blink
Version:
A library for tracking user behaviour.
113 lines • 4.72 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var consts_1 = require("../consts");
var prepare_ad_event_1 = __importDefault(require("../prepare-ad-event"));
var config_1 = require("../../config/config");
describe('Setup Ad Event Body', function () {
it('should format a typical event', function () {
var _a;
var id = 'ad-banner';
var page = {
id: 'default-page',
state: {
general: {
site: 'www.dagbladet.no',
pageView: '32be2425-907a-4f46-be45-cea8b00f5d7c',
userId: '40c2f93f-52bb-47a8-b7c2-e92b8f49df2c',
referrer: 'www.sol.no',
version: config_1.VERSION,
},
inscreen: {
'db.no/123': [
{ type: 'start', time: new Date(2018, 0, 0, 0) },
{ type: 'stop', time: new Date(2018, 0, 0, 1) },
],
'ad-banner': [
{ type: 'start', time: new Date(2018, 0, 0, 0, 0) },
{ type: 'stop', time: new Date(2018, 0, 0, 0, 4) },
],
},
inscreen0: {
'ad-banner': [
{ type: 'start', time: new Date(2018, 0, 0, 0, 1) },
{ type: 'stop', time: new Date(2018, 0, 0, 0, 4) },
],
},
screen: { events: [] },
ads: {
'ad-banner': (_a = {
id: 'ad-banner'
},
_a[consts_1.DFP_RENDERED] = 1,
_a[consts_1.DFP_LOADED] = 1,
_a[consts_1.DFP_INSCREEN] = 1,
_a[consts_1.SCROLL_OFFSET_TOP] = 1500,
_a[consts_1.SCROLL_OFFSET_HEIGHT] = 300,
_a[consts_1.DFP_ADVERTISER_ID] = 900,
_a[consts_1.DFP_ADUNIT_PATH] = '/8578/dagbladet.no/forside',
_a[consts_1.DFP_CAMPAIGN_ID] = 500,
_a[consts_1.DFP_CREATIVE_ID] = 300,
_a[consts_1.DFP_LINE_ITEM_ID] = 1900,
_a[consts_1.DFP_NAME] = 'skyscraper-right',
_a[consts_1.SCROLL_POS_AD_LOAD] = 2490,
_a[consts_1.SCROLL_POS_INSCREEN_DFP] = 1,
_a[consts_1.SCROLL_POS_SLOT_RENDER_ENDED] = 30,
_a[consts_1.SCROLL_POS_SLOT_ONLOAD] = 40,
_a[consts_1.DFP_SIZE] = [200],
_a[consts_1.DFP_SOURCE_AGNOSTIC_CREATIVE_ID] = 901,
_a[consts_1.DFP_SOURCE_AGNOSTIC_LINE_ITEM_ID] = 401,
_a[consts_1.DFP_BIDDER] = 'appnexus',
_a),
},
},
};
var expectedAdBody = {
// Typical data for all events
id: 'ad-banner',
adId: 'ad-banner',
pageView: '32be2425-907a-4f46-be45-cea8b00f5d7c',
type: 'ads',
userId: '40c2f93f-52bb-47a8-b7c2-e92b8f49df2c',
version: config_1.VERSION,
site: 'www.dagbladet.no',
referrer: 'www.sol.no',
// Ad specific data
inscreenTime: 240000,
inscreenTime0: 180000,
scroll: {
pos: {
adLoad: 2490,
inscreenDFP: 1,
slotRenderEnded: 30,
slotOnload: 40,
},
offsetTop: 1500,
offsetHeight: 300,
scrollHeight: 300,
},
dfp: {
inscreen: 1,
name: 'skyscraper-right',
advertiserId: 900,
campaignId: 500,
creativeId: 300,
adUnitPath: '/8578/dagbladet.no/forside',
rendered: 1,
loaded: 1,
lineItemId: 1900,
size: [200],
sourceAgnosticCreativeId: 901,
sourceAgnosticLineItemId: 401,
bidder: 'appnexus',
},
};
var utils = {
getScrollHeight: function () { return 300; },
};
expect(prepare_ad_event_1.default({ id: id, page: page, utils: utils })).toEqual(expectedAdBody);
});
});
//# sourceMappingURL=prepare-ad-event.test.js.map
;