prebid.js 7.22.0 → 7.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/33acrossBidAdapter.js +1 -1
- package/dist/aaxBlockmeterRtdProvider.js +1 -0
- package/dist/adagioBidAdapter.js +1 -1
- package/dist/adbookpspBidAdapter.js +1 -1
- package/dist/adgenerationBidAdapter.js +1 -1
- package/dist/adrelevantisBidAdapter.js +1 -1
- package/dist/adtrgtmeBidAdapter.js +1 -1
- package/dist/adxcgBidAdapter.js +1 -1
- package/dist/ajaBidAdapter.js +1 -1
- package/dist/amxBidAdapter.js +1 -1
- package/dist/amxIdSystem.js +1 -1
- package/dist/analyticsAdapter.js +1 -1
- package/dist/appierAnalyticsAdapter.js +1 -1
- package/dist/appnexusBidAdapter.js +1 -1
- package/dist/asoBidAdapter.js +1 -1
- package/dist/axonixBidAdapter.js +1 -1
- package/dist/bidViewability.js +1 -1
- package/dist/bidViewabilityIO.js +1 -1
- package/dist/bidglassBidAdapter.js +1 -1
- package/dist/big-richmediaBidAdapter.js +1 -1
- package/dist/bridgewellBidAdapter.js +1 -1
- package/dist/brightMountainMediaBidAdapter.js +1 -1
- package/dist/browsiRtdProvider.js +1 -1
- package/dist/carodaBidAdapter.js +1 -1
- package/dist/chtnwBidAdapter.js +1 -0
- package/dist/cleanioRtdProvider.js +1 -1
- package/dist/concertBidAdapter.js +1 -1
- package/dist/connectadBidAdapter.js +1 -1
- package/dist/consentManagement.js +1 -1
- package/dist/consentManagementUsp.js +1 -1
- package/dist/consumableBidAdapter.js +1 -1
- package/dist/conversantBidAdapter.js +1 -1
- package/dist/craftBidAdapter.js +1 -1
- package/dist/criteoBidAdapter.js +1 -1
- package/dist/currency.js +1 -1
- package/dist/dependencies.json +19 -0
- package/dist/dfpAdServerVideo.js +1 -1
- package/dist/dgkeywordRtdProvider.js +1 -1
- package/dist/dspxBidAdapter.js +1 -1
- package/dist/eplanningBidAdapter.js +1 -1
- package/dist/finativeBidAdapter.js +1 -1
- package/dist/gdprEnforcement.js +1 -1
- package/dist/glimpseBidAdapter.js +1 -1
- package/dist/gmosspBidAdapter.js +1 -1
- package/dist/goldbachBidAdapter.js +1 -1
- package/dist/googleAnalyticsAdapter.js +1 -1
- package/dist/gridBidAdapter.js +1 -1
- package/dist/gridNMBidAdapter.js +1 -1
- package/dist/gumgumBidAdapter.js +1 -1
- package/dist/h12mediaBidAdapter.js +1 -1
- package/dist/id5AnalyticsAdapter.js +1 -1
- package/dist/id5IdSystem.js +1 -1
- package/dist/improvedigitalBidAdapter.js +1 -1
- package/dist/inmarBidAdapter.js +1 -1
- package/dist/insticatorBidAdapter.js +1 -1
- package/dist/instreamTracking.js +1 -1
- package/dist/ixBidAdapter.js +1 -1
- package/dist/justpremiumBidAdapter.js +1 -1
- package/dist/jwplayerVideoProvider.js +1 -0
- package/dist/kargoBidAdapter.js +1 -1
- package/dist/konduitAnalyticsAdapter.js +1 -1
- package/dist/kueezBidAdapter.js +1 -1
- package/dist/lassoBidAdapter.js +1 -1
- package/dist/lifestreetBidAdapter.js +1 -1
- package/dist/liveyieldAnalyticsAdapter.js +1 -1
- package/dist/logicadBidAdapter.js +1 -1
- package/dist/loglyliftBidAdapter.js +1 -1
- package/dist/magniteAnalyticsAdapter.js +1 -1
- package/dist/malltvAnalyticsAdapter.js +1 -1
- package/dist/marsmediaBidAdapter.js +1 -1
- package/dist/mediafuseBidAdapter.js +1 -1
- package/dist/mediasquareBidAdapter.js +1 -1
- package/dist/mgidBidAdapter.js +1 -1
- package/dist/minutemediaBidAdapter.js +1 -1
- package/dist/multibid.js +1 -1
- package/dist/not-for-prod/prebid.js +141 -132
- package/dist/oguryBidAdapter.js +1 -1
- package/dist/onetagBidAdapter.js +1 -1
- package/dist/ooloAnalyticsAdapter.js +1 -1
- package/dist/openxOrtbBidAdapter.js +1 -1
- package/dist/ortbConverter.js +1 -0
- package/dist/outbrainBidAdapter.js +1 -1
- package/dist/oxxionRtdProvider.js +1 -0
- package/dist/parrableIdSystem.js +1 -1
- package/dist/pbsExtensions.js +1 -0
- package/dist/pixfutureBidAdapter.js +1 -1
- package/dist/prebid-core.js +1 -1
- package/dist/prebidServerBidAdapter.js +1 -1
- package/dist/priceFloors.js +1 -1
- package/dist/pubCommonId.js +1 -1
- package/dist/publinkIdSystem.js +1 -1
- package/dist/pubmaticBidAdapter.js +1 -1
- package/dist/pubwiseAnalyticsAdapter.js +1 -1
- package/dist/pxyzBidAdapter.js +1 -1
- package/dist/quantcastBidAdapter.js +1 -1
- package/dist/readpeakBidAdapter.js +1 -1
- package/dist/relaidoBidAdapter.js +1 -1
- package/dist/rhythmoneBidAdapter.js +1 -1
- package/dist/riseBidAdapter.js +1 -1
- package/dist/rtdModule.js +1 -1
- package/dist/rubiconAnalyticsAdapter.js +1 -1
- package/dist/rubiconBidAdapter.js +1 -1
- package/dist/schain.js +1 -1
- package/dist/seedingAllianceBidAdapter.js +1 -1
- package/dist/seedtagBidAdapter.js +1 -1
- package/dist/sharethroughAnalyticsAdapter.js +1 -1
- package/dist/sharethroughBidAdapter.js +1 -1
- package/dist/shinezBidAdapter.js +1 -1
- package/dist/smaatoBidAdapter.js +1 -1
- package/dist/smartadserverBidAdapter.js +1 -1
- package/dist/smartxBidAdapter.js +1 -1
- package/dist/smilewantedBidAdapter.js +1 -1
- package/dist/sonobiBidAdapter.js +1 -1
- package/dist/sovrnAnalyticsAdapter.js +1 -1
- package/dist/sovrnBidAdapter.js +1 -1
- package/dist/spotxBidAdapter.js +1 -1
- package/dist/sspBCBidAdapter.js +1 -1
- package/dist/sublimeBidAdapter.js +1 -1
- package/dist/synacormediaBidAdapter.js +1 -1
- package/dist/targetVideoBidAdapter.js +1 -1
- package/dist/teadsBidAdapter.js +1 -1
- package/dist/teadsIdSystem.js +1 -1
- package/dist/trionBidAdapter.js +1 -1
- package/dist/tripleliftBidAdapter.js +1 -1
- package/dist/ttdBidAdapter.js +1 -1
- package/dist/ucfunnelAnalyticsAdapter.js +1 -1
- package/dist/underdogmediaBidAdapter.js +1 -1
- package/dist/undertoneBidAdapter.js +1 -1
- package/dist/userId.js +1 -1
- package/dist/vidazooBidAdapter.js +1 -1
- package/dist/video.js +1 -0
- package/dist/videoModule.js +1 -0
- package/dist/videobyteBidAdapter.js +1 -1
- package/dist/videojsVideoProvider.js +1 -0
- package/dist/visxBidAdapter.js +1 -1
- package/dist/vuukleBidAdapter.js +1 -1
- package/dist/widespaceBidAdapter.js +1 -1
- package/dist/winrBidAdapter.js +1 -1
- package/dist/yahoosspBidAdapter.js +1 -1
- package/dist/yieldmoBidAdapter.js +1 -1
- package/dist/yieldoneAnalyticsAdapter.js +1 -1
- package/integrationExamples/videoModule/jwplayer/bidMarkedAsUsed.html +98 -0
- package/integrationExamples/videoModule/jwplayer/bidRequestScheduling.html +89 -0
- package/integrationExamples/videoModule/jwplayer/eventListeners.html +244 -0
- package/integrationExamples/videoModule/jwplayer/gamAdServerMediation.html +122 -0
- package/integrationExamples/videoModule/jwplayer/mediaMetadata.html +80 -0
- package/integrationExamples/videoModule/jwplayer/playlist.html +122 -0
- package/integrationExamples/videoModule/videojs/bidMarkedAsUsed.html +126 -0
- package/integrationExamples/videoModule/videojs/bidRequestScheduling.html +132 -0
- package/integrationExamples/videoModule/videojs/eventListeners.html +238 -0
- package/integrationExamples/videoModule/videojs/gamAdServerMediation.html +138 -0
- package/integrationExamples/videoModule/videojs/mediaMetadata.html +103 -0
- package/integrationExamples/videoModule/videojs/playlist.html +151 -0
- package/libraries/ortbConverter/README.md +378 -0
- package/libraries/ortbConverter/converter.js +135 -0
- package/libraries/ortbConverter/lib/composer.js +43 -0
- package/libraries/ortbConverter/lib/mergeProcessors.js +9 -0
- package/libraries/ortbConverter/lib/sizes.js +14 -0
- package/libraries/ortbConverter/processors/banner.js +40 -0
- package/libraries/ortbConverter/processors/default.js +167 -0
- package/libraries/ortbConverter/processors/mediaType.js +21 -0
- package/libraries/ortbConverter/processors/native.js +37 -0
- package/libraries/ortbConverter/processors/video.js +66 -0
- package/libraries/pbsExtensions/pbsExtensions.js +12 -0
- package/libraries/pbsExtensions/processors/aliases.js +17 -0
- package/libraries/pbsExtensions/processors/mediaType.js +23 -0
- package/libraries/pbsExtensions/processors/params.js +22 -0
- package/libraries/pbsExtensions/processors/pbs.js +99 -0
- package/libraries/pbsExtensions/processors/requestExtPrebid.js +30 -0
- package/libraries/pbsExtensions/processors/video.js +23 -0
- package/libraries/video/constants/enums.js +5 -0
- package/libraries/video/constants/events.js +97 -0
- package/libraries/video/constants/ortb.js +169 -0
- package/libraries/video/constants/vendorCodes.js +6 -0
- package/libraries/video/shared/eventHandler.js +18 -0
- package/libraries/video/shared/parentModule.js +82 -0
- package/libraries/video/shared/state.js +47 -0
- package/libraries/video/shared/vastXmlBuilder.js +77 -0
- package/libraries/video/shared/vastXmlEditor.js +115 -0
- package/modules/.submodules.json +6 -1
- package/modules/aaxBlockmeterRtdProvider.js +59 -0
- package/modules/aaxBlockmeterRtdProvider.md +48 -0
- package/modules/appnexusBidAdapter.js +38 -1
- package/modules/chtnwBidAdapter.js +110 -0
- package/modules/chtnwBidAdapter.md +31 -0
- package/modules/concertBidAdapter.js +44 -2
- package/modules/consentManagement.js +22 -1
- package/modules/consentManagementUsp.js +29 -7
- package/modules/criteoBidAdapter.js +25 -5
- package/modules/currency.js +9 -0
- package/modules/dgkeywordRtdProvider.js +3 -3
- package/modules/gridNMBidAdapter.js +10 -14
- package/modules/improvedigitalBidAdapter.js +191 -470
- package/modules/ixBidAdapter.js +24 -64
- package/modules/jwplayerVideoProvider.js +929 -0
- package/modules/jwplayerVideoProvider.md +25 -0
- package/modules/kargoBidAdapter.js +1 -1
- package/modules/multibid/index.js +12 -0
- package/modules/openxOrtbBidAdapter.js +120 -275
- package/modules/oxxionRtdProvider.js +119 -0
- package/modules/oxxionRtdProvider.md +48 -0
- package/modules/prebidServerBidAdapter/index.js +19 -716
- package/modules/prebidServerBidAdapter/ortbConverter.js +274 -0
- package/modules/priceFloors.js +73 -1
- package/modules/rtdModule/index.js +22 -1
- package/modules/schain.js +24 -1
- package/modules/spotxBidAdapter.js +16 -15
- package/modules/synacormediaBidAdapter.js +1 -1
- package/modules/teadsIdSystem.js +5 -0
- package/modules/userId/index.js +64 -6
- package/modules/videoModule/addingSubmodule.md +521 -0
- package/modules/videoModule/coreVideo.js +234 -0
- package/modules/videoModule/gamAdServerSubmodule.js +27 -0
- package/modules/videoModule/index.js +244 -0
- package/modules/videoModule/videoImpressionVerifier.js +206 -0
- package/modules/videojsVideoProvider.js +854 -0
- package/modules/videojsVideoProvider.md +17 -0
- package/package.json +5 -1
- package/src/adapterManager.js +56 -7
- package/src/adloader.js +2 -1
- package/src/auction.js +5 -0
- package/src/events.js +5 -1
- package/src/pbjsORTB.js +35 -0
- package/src/prebid.js +137 -112
- package/src/targeting.js +10 -2
- package/src/utils/currency.js +16 -0
- package/src/utils.js +21 -0
- package/test/spec/auctionmanager_spec.js +6 -0
- package/test/spec/modules/aaxBlockmeter_spec.js +58 -0
- package/test/spec/modules/chtnwBidAdapter_spec.js +105 -0
- package/test/spec/modules/concertBidAdapter_spec.js +56 -0
- package/test/spec/modules/consentManagementUsp_spec.js +64 -18
- package/test/spec/modules/criteoBidAdapter_spec.js +28 -0
- package/test/spec/modules/dgkeywordRtdProvider_spec.js +3 -3
- package/test/spec/modules/improvedigitalBidAdapter_spec.js +231 -211
- package/test/spec/modules/ixBidAdapter_spec.js +230 -371
- package/test/spec/modules/openxOrtbBidAdapter_spec.js +77 -49
- package/test/spec/modules/oxxionRtdProvider_spec.js +142 -0
- package/test/spec/modules/prebidServerBidAdapter_spec.js +139 -137
- package/test/spec/modules/realTimeDataModule_spec.js +65 -0
- package/test/spec/modules/userId_spec.js +67 -1
- package/test/spec/modules/videoModule/coreVideo_spec.js +98 -0
- package/test/spec/modules/videoModule/pbVideo_spec.js +362 -0
- package/test/spec/modules/videoModule/shared/parentModule_spec.js +73 -0
- package/test/spec/modules/videoModule/shared/state_spec.js +26 -0
- package/test/spec/modules/videoModule/shared/vastXmlBuilder_spec.js +103 -0
- package/test/spec/modules/videoModule/shared/vastXmlEditor_spec.js +209 -0
- package/test/spec/modules/videoModule/submodules/jwplayerVideoProvider_spec.js +846 -0
- package/test/spec/modules/videoModule/submodules/videojsVideoProvider_spec.js +391 -0
- package/test/spec/modules/videoModule/videoImpressionVerifier_spec.js +112 -0
- package/test/spec/ortbConverter/banner_spec.js +203 -0
- package/test/spec/ortbConverter/composer_spec.js +69 -0
- package/test/spec/ortbConverter/converter_spec.js +283 -0
- package/test/spec/ortbConverter/currency_spec.js +40 -0
- package/test/spec/ortbConverter/default_processors_spec.js +61 -0
- package/test/spec/ortbConverter/gdpr_spec.js +38 -0
- package/test/spec/ortbConverter/mediaTypes_spec.js +67 -0
- package/test/spec/ortbConverter/mergeProcessors_spec.js +59 -0
- package/test/spec/ortbConverter/multibid_spec.js +35 -0
- package/test/spec/ortbConverter/native_spec.js +95 -0
- package/test/spec/ortbConverter/pbjsORTB_spec.js +67 -0
- package/test/spec/ortbConverter/pbsExtensions/aliases_spec.js +57 -0
- package/test/spec/ortbConverter/pbsExtensions/params_spec.js +96 -0
- package/test/spec/ortbConverter/pbsExtensions/video_spec.js +52 -0
- package/test/spec/ortbConverter/priceFloors_spec.js +143 -0
- package/test/spec/ortbConverter/schain_spec.js +33 -0
- package/test/spec/ortbConverter/userId_spec.js +21 -0
- package/test/spec/ortbConverter/usp_spec.js +15 -0
- package/test/spec/ortbConverter/video_spec.js +189 -0
- package/test/spec/unit/core/adapterManager_spec.js +102 -0
- package/test/spec/unit/core/targeting_spec.js +34 -0
- package/test/spec/unit/pbjs_api_spec.js +124 -45
- package/test/spec/utils_spec.js +45 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { VideoCore } from 'modules/videoModule/coreVideo.js';
|
|
3
|
+
|
|
4
|
+
describe('Video Core', function () {
|
|
5
|
+
const mockSubmodule = {
|
|
6
|
+
getOrtbVideo: sinon.spy(),
|
|
7
|
+
getOrtbContent: sinon.spy(),
|
|
8
|
+
setAdTagUrl: sinon.spy(),
|
|
9
|
+
onEvent: sinon.spy(),
|
|
10
|
+
offEvent: sinon.spy(),
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const otherSubmodule = {
|
|
14
|
+
getOrtbVideo: () => {},
|
|
15
|
+
getOrtbContent: () => {},
|
|
16
|
+
setAdTagUrl: () => {},
|
|
17
|
+
onEvent: () => {},
|
|
18
|
+
offEvent: () => {},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const testId = 'test_id';
|
|
22
|
+
const testVendorCode = 0;
|
|
23
|
+
const otherId = 'other_id';
|
|
24
|
+
const otherVendorCode = 1;
|
|
25
|
+
|
|
26
|
+
const parentModuleMock = {
|
|
27
|
+
registerSubmodule: sinon.spy(),
|
|
28
|
+
getSubmodule: sinon.spy(id => {
|
|
29
|
+
if (id === testId) {
|
|
30
|
+
return mockSubmodule;
|
|
31
|
+
} else if (id === otherId) {
|
|
32
|
+
return otherSubmodule;
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const videoCore = VideoCore(parentModuleMock);
|
|
38
|
+
|
|
39
|
+
videoCore.registerProvider({
|
|
40
|
+
vendorCode: testVendorCode,
|
|
41
|
+
divId: testId
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
videoCore.registerProvider({
|
|
45
|
+
vendorCode: otherVendorCode,
|
|
46
|
+
divId: otherId
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('registerProvider', function () {
|
|
50
|
+
it('should delegate the registration to the Parent Module', function () {
|
|
51
|
+
expect(parentModuleMock.registerSubmodule.calledTwice).to.be.true;
|
|
52
|
+
expect(parentModuleMock.registerSubmodule.args[0][0]).to.be.equal(testId);
|
|
53
|
+
expect(parentModuleMock.registerSubmodule.args[1][0]).to.be.equal(otherId);
|
|
54
|
+
expect(parentModuleMock.registerSubmodule.args[0][1]).to.be.equal(testVendorCode);
|
|
55
|
+
expect(parentModuleMock.registerSubmodule.args[1][1]).to.be.equal(otherVendorCode);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('getOrtbVideo', function () {
|
|
60
|
+
it('delegates to the submodule of the right divId', function () {
|
|
61
|
+
videoCore.getOrtbVideo(testId);
|
|
62
|
+
videoCore.getOrtbVideo(otherId);
|
|
63
|
+
expect(mockSubmodule.getOrtbVideo.calledOnce).to.be.true;
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('getOrtbContent', function () {
|
|
68
|
+
it('delegates to the submodule of the right divId', function () {
|
|
69
|
+
videoCore.getOrtbContent(testId);
|
|
70
|
+
videoCore.getOrtbContent(otherId);
|
|
71
|
+
expect(mockSubmodule.getOrtbContent.calledOnce).to.be.true;
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('setAdTagUrl', function () {
|
|
76
|
+
it('delegates to the submodule of the right divId', function () {
|
|
77
|
+
videoCore.setAdTagUrl('', testId);
|
|
78
|
+
videoCore.setAdTagUrl('', otherId);
|
|
79
|
+
expect(mockSubmodule.setAdTagUrl.calledOnce).to.be.true;
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe('onEvents', function () {
|
|
84
|
+
it('delegates to the submodule of the right divId', function () {
|
|
85
|
+
videoCore.onEvents(['event'], () => {}, testId);
|
|
86
|
+
videoCore.onEvents(['event'], () => {}, otherId);
|
|
87
|
+
expect(mockSubmodule.onEvent.calledOnce).to.be.true;
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('offEvents', function () {
|
|
92
|
+
it('delegates to the submodule of the right divId', function () {
|
|
93
|
+
videoCore.offEvents(['event'], () => {}, testId);
|
|
94
|
+
videoCore.offEvents(['event'], () => {}, otherId);
|
|
95
|
+
expect(mockSubmodule.offEvent.calledOnce).to.be.true;
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { PbVideo } from 'modules/videoModule';
|
|
3
|
+
import CONSTANTS from 'src/constants.json';
|
|
4
|
+
|
|
5
|
+
let ortbVideoMock;
|
|
6
|
+
let ortbContentMock;
|
|
7
|
+
let videoCoreMock;
|
|
8
|
+
let getConfigMock;
|
|
9
|
+
let requestBidsMock;
|
|
10
|
+
let pbGlobalMock;
|
|
11
|
+
let pbEventsMock;
|
|
12
|
+
let videoEventsMock;
|
|
13
|
+
let gamSubmoduleMock;
|
|
14
|
+
let gamSubmoduleFactoryMock;
|
|
15
|
+
let videoImpressionVerifierFactoryMock;
|
|
16
|
+
let videoImpressionVerifierMock;
|
|
17
|
+
|
|
18
|
+
function resetTestVars() {
|
|
19
|
+
ortbVideoMock = {};
|
|
20
|
+
ortbContentMock = {};
|
|
21
|
+
videoCoreMock = {
|
|
22
|
+
registerProvider: sinon.spy(),
|
|
23
|
+
onEvents: sinon.spy(),
|
|
24
|
+
getOrtbVideo: () => ortbVideoMock,
|
|
25
|
+
getOrtbContent: () => ortbContentMock,
|
|
26
|
+
setAdTagUrl: sinon.spy()
|
|
27
|
+
};
|
|
28
|
+
getConfigMock = () => {};
|
|
29
|
+
requestBidsMock = {
|
|
30
|
+
before: sinon.spy()
|
|
31
|
+
};
|
|
32
|
+
pbGlobalMock = {
|
|
33
|
+
requestBids: requestBidsMock,
|
|
34
|
+
getHighestCpmBids: sinon.spy(),
|
|
35
|
+
getBidResponsesForAdUnitCode: sinon.spy(),
|
|
36
|
+
setConfig: sinon.spy(),
|
|
37
|
+
getConfig: () => ({}),
|
|
38
|
+
markWinningBidAsUsed: sinon.spy()
|
|
39
|
+
};
|
|
40
|
+
pbEventsMock = {
|
|
41
|
+
emit: sinon.spy(),
|
|
42
|
+
on: sinon.spy()
|
|
43
|
+
};
|
|
44
|
+
videoEventsMock = [];
|
|
45
|
+
gamSubmoduleMock = {
|
|
46
|
+
getAdTagUrl: sinon.spy()
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
gamSubmoduleFactoryMock = sinon.spy(() => gamSubmoduleMock);
|
|
50
|
+
|
|
51
|
+
videoImpressionVerifierMock = {
|
|
52
|
+
trackBid: sinon.spy(),
|
|
53
|
+
getBidIdentifiers: sinon.spy()
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
videoImpressionVerifierFactoryMock = () => videoImpressionVerifierMock;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let pbVideoFactory = (videoCore, getConfig, pbGlobal, pbEvents, videoEvents, gamSubmoduleFactory, videoImpressionVerifierFactory) => {
|
|
60
|
+
const pbVideo = PbVideo(
|
|
61
|
+
videoCore || videoCoreMock,
|
|
62
|
+
getConfig || getConfigMock,
|
|
63
|
+
pbGlobal || pbGlobalMock,
|
|
64
|
+
pbEvents || pbEventsMock,
|
|
65
|
+
videoEvents || videoEventsMock,
|
|
66
|
+
gamSubmoduleFactory || gamSubmoduleFactoryMock,
|
|
67
|
+
videoImpressionVerifierFactory || videoImpressionVerifierFactoryMock
|
|
68
|
+
);
|
|
69
|
+
pbVideo.init();
|
|
70
|
+
return pbVideo;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
describe('Prebid Video', function () {
|
|
74
|
+
beforeEach(() => resetTestVars());
|
|
75
|
+
|
|
76
|
+
describe('Setting video to config', function () {
|
|
77
|
+
let providers = [{ divId: 'div1' }, { divId: 'div2' }];
|
|
78
|
+
let getConfigCallback;
|
|
79
|
+
let getConfig = (propertyName, callback) => {
|
|
80
|
+
if (propertyName === 'video') {
|
|
81
|
+
getConfigCallback = callback;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
beforeEach(() => {
|
|
86
|
+
pbVideoFactory(null, getConfig);
|
|
87
|
+
getConfigCallback({ video: { providers } });
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('Should register providers', function () {
|
|
91
|
+
expect(videoCoreMock.registerProvider.calledTwice).to.be.true;
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('Should register events', function () {
|
|
95
|
+
expect(videoCoreMock.onEvents.calledTwice).to.be.true;
|
|
96
|
+
const onEventsSpy = videoCoreMock.onEvents;
|
|
97
|
+
expect(onEventsSpy.getCall(0).args[2]).to.be.equal('div1');
|
|
98
|
+
expect(onEventsSpy.getCall(1).args[2]).to.be.equal('div2');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe('Event triggering', function () {
|
|
102
|
+
it('Should emit events off of Prebid\'s Events', function () {
|
|
103
|
+
let eventHandler;
|
|
104
|
+
const videoCore = Object.assign({}, videoCoreMock, {
|
|
105
|
+
onEvents: (events, eventHandler_) => eventHandler = eventHandler_
|
|
106
|
+
});
|
|
107
|
+
pbVideoFactory(videoCore, getConfig);
|
|
108
|
+
getConfigCallback({ video: { providers } });
|
|
109
|
+
const expectedType = 'test_event';
|
|
110
|
+
const expectedPayload = {'test': 'data'};
|
|
111
|
+
eventHandler(expectedType, expectedPayload);
|
|
112
|
+
expect(pbEventsMock.emit.calledOnce).to.be.true;
|
|
113
|
+
expect(pbEventsMock.emit.getCall(0).args[0]).to.be.equal('video' + expectedType.replace(/^./, expectedType[0].toUpperCase()));
|
|
114
|
+
expect(pbEventsMock.emit.getCall(0).args[1]).to.be.equal(expectedPayload);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('Ad Server configuration', function() {
|
|
119
|
+
const test_vendor_code = 5;
|
|
120
|
+
const test_params = { test: 'params' };
|
|
121
|
+
providers[0].adServer = { vendorCode: test_vendor_code, params: test_params };
|
|
122
|
+
|
|
123
|
+
it('should instantiate the GAM Submodule', function () {
|
|
124
|
+
expect(gamSubmoduleFactoryMock.calledOnce).to.be.true;
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
describe('Ad unit Enrichment', function () {
|
|
130
|
+
it('registers before:bidRequest hook', function () {
|
|
131
|
+
pbVideoFactory();
|
|
132
|
+
expect(requestBidsMock.before.calledOnce).to.be.true;
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('requests oRtb params and writes them to ad unit and config', function() {
|
|
136
|
+
const getOrtbVideoSpy = videoCoreMock.getOrtbVideo = sinon.spy(() => ({
|
|
137
|
+
test: 'videoTestValue'
|
|
138
|
+
}));
|
|
139
|
+
const getOrtbContentSpy = videoCoreMock.getOrtbContent = sinon.spy(() => ({
|
|
140
|
+
test: 'contentTestValue'
|
|
141
|
+
}));
|
|
142
|
+
|
|
143
|
+
let beforeBidRequestCallback;
|
|
144
|
+
const requestBids = {
|
|
145
|
+
before: callback_ => beforeBidRequestCallback = callback_
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
pbVideoFactory(null, null, Object.assign({}, pbGlobalMock, { requestBids }));
|
|
149
|
+
expect(beforeBidRequestCallback).to.not.be.undefined;
|
|
150
|
+
const nextFn = sinon.spy();
|
|
151
|
+
const adUnits = [{
|
|
152
|
+
code: 'ad1',
|
|
153
|
+
mediaTypes: {
|
|
154
|
+
video: {}
|
|
155
|
+
},
|
|
156
|
+
video: { divId: 'divId' }
|
|
157
|
+
}];
|
|
158
|
+
beforeBidRequestCallback(nextFn, { adUnits });
|
|
159
|
+
expect(getOrtbVideoSpy.calledOnce).to.be.true;
|
|
160
|
+
expect(getOrtbContentSpy.calledOnce).to.be.true;
|
|
161
|
+
const adUnit = adUnits[0];
|
|
162
|
+
expect(adUnit.mediaTypes.video).to.have.property('test', 'videoTestValue');
|
|
163
|
+
expect(nextFn.calledOnce).to.be.true;
|
|
164
|
+
expect(nextFn.getCall(0).args[0].ortb2).to.be.deep.equal({ site: { content: { test: 'contentTestValue' } } });
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
describe('Ad tag injection', function () {
|
|
169
|
+
let auctionEndCallback;
|
|
170
|
+
let providers = [{ divId: 'div1', adServer: {} }, { divId: 'div2' }];
|
|
171
|
+
let getConfig = (propertyName, callbackFn) => {
|
|
172
|
+
if (propertyName === 'video') {
|
|
173
|
+
if (callbackFn) {
|
|
174
|
+
callbackFn({ video: { providers } });
|
|
175
|
+
} else {
|
|
176
|
+
return { providers };
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const pbEvents = {
|
|
182
|
+
emit: () => {},
|
|
183
|
+
on: (event, callback) => {
|
|
184
|
+
if (event === CONSTANTS.EVENTS.AUCTION_END) {
|
|
185
|
+
auctionEndCallback = callback
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
off: () => {}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const expectedVendorCode = 5;
|
|
192
|
+
const expectedAdTag = 'test_tag';
|
|
193
|
+
const expectedAdUnitCode = 'expectedAdUnitcode';
|
|
194
|
+
const expectedDivId = 'expectedDivId';
|
|
195
|
+
const expectedAdUnit = {
|
|
196
|
+
code: expectedAdUnitCode,
|
|
197
|
+
video: {
|
|
198
|
+
divId: expectedDivId,
|
|
199
|
+
adServer: {
|
|
200
|
+
vendorCode: expectedVendorCode,
|
|
201
|
+
baseAdTagUrl: expectedAdTag
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
const auctionResults = { adUnits: [ expectedAdUnit, {} ] };
|
|
206
|
+
|
|
207
|
+
beforeEach(() => {
|
|
208
|
+
gamSubmoduleMock.getAdTagUrl.resetHistory();
|
|
209
|
+
videoCoreMock.setAdTagUrl.resetHistory();
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
let beforeBidRequestCallback;
|
|
213
|
+
const requestBids = {
|
|
214
|
+
before: callback_ => beforeBidRequestCallback = callback_
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
it('should request ad tag url from adServer when configured to use adServer', function () {
|
|
218
|
+
const expectedVastUrl = 'expectedVastUrl';
|
|
219
|
+
const expectedVastXml = 'expectedVastXml';
|
|
220
|
+
const pbGlobal = Object.assign({}, pbGlobalMock, {
|
|
221
|
+
requestBids,
|
|
222
|
+
getHighestCpmBids: () => [{
|
|
223
|
+
vastUrl: expectedVastUrl,
|
|
224
|
+
vastXml: expectedVastXml
|
|
225
|
+
}, {}, {}, {}]
|
|
226
|
+
});
|
|
227
|
+
pbVideoFactory(null, getConfig, pbGlobal, pbEvents);
|
|
228
|
+
|
|
229
|
+
beforeBidRequestCallback(() => {}, {});
|
|
230
|
+
auctionEndCallback(auctionResults);
|
|
231
|
+
expect(gamSubmoduleMock.getAdTagUrl.calledOnce).to.be.true;
|
|
232
|
+
expect(gamSubmoduleMock.getAdTagUrl.getCall(0).args[0]).is.equal(expectedAdUnit);
|
|
233
|
+
expect(gamSubmoduleMock.getAdTagUrl.getCall(0).args[1]).is.equal(expectedAdTag);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it('should load ad tag when ad server returns ad tag', function () {
|
|
237
|
+
const expectedAdTag = 'resulting ad tag';
|
|
238
|
+
const gamSubmoduleFactory = () => ({
|
|
239
|
+
getAdTagUrl: () => expectedAdTag
|
|
240
|
+
});
|
|
241
|
+
const expectedVastUrl = 'expectedVastUrl';
|
|
242
|
+
const expectedVastXml = 'expectedVastXml';
|
|
243
|
+
const pbGlobal = Object.assign({}, pbGlobalMock, {
|
|
244
|
+
requestBids,
|
|
245
|
+
getHighestCpmBids: () => [{
|
|
246
|
+
vastUrl: expectedVastUrl,
|
|
247
|
+
vastXml: expectedVastXml
|
|
248
|
+
}, {}, {}, {}]
|
|
249
|
+
});
|
|
250
|
+
pbVideoFactory(null, getConfig, pbGlobal, pbEvents, null, gamSubmoduleFactory);
|
|
251
|
+
beforeBidRequestCallback(() => {}, {});
|
|
252
|
+
auctionEndCallback(auctionResults);
|
|
253
|
+
expect(videoCoreMock.setAdTagUrl.calledOnce).to.be.true;
|
|
254
|
+
expect(videoCoreMock.setAdTagUrl.args[0][0]).to.be.equal(expectedAdTag);
|
|
255
|
+
expect(videoCoreMock.setAdTagUrl.args[0][1]).to.be.equal(expectedDivId);
|
|
256
|
+
expect(videoCoreMock.setAdTagUrl.args[0][2]).to.have.property('adUnitCode', expectedAdUnitCode);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it('should load ad tag from highest bid when ad server is not configured', function () {
|
|
260
|
+
const expectedVastUrl = 'expectedVastUrl';
|
|
261
|
+
const expectedVastXml = 'expectedVastXml';
|
|
262
|
+
const pbGlobal = Object.assign({}, pbGlobalMock, {
|
|
263
|
+
requestBids,
|
|
264
|
+
getHighestCpmBids: () => [{
|
|
265
|
+
vastUrl: expectedVastUrl,
|
|
266
|
+
vastXml: expectedVastXml
|
|
267
|
+
}, {}, {}, {}]
|
|
268
|
+
});
|
|
269
|
+
const expectedAdUnit = {
|
|
270
|
+
code: expectedAdUnitCode,
|
|
271
|
+
video: { divId: expectedDivId }
|
|
272
|
+
};
|
|
273
|
+
const auctionResults = { adUnits: [ expectedAdUnit, {} ] };
|
|
274
|
+
|
|
275
|
+
pbVideoFactory(null, () => ({ providers: [] }), pbGlobal, pbEvents);
|
|
276
|
+
beforeBidRequestCallback(() => {}, {});
|
|
277
|
+
auctionEndCallback(auctionResults);
|
|
278
|
+
expect(videoCoreMock.setAdTagUrl.calledOnce).to.be.true;
|
|
279
|
+
expect(videoCoreMock.setAdTagUrl.args[0][0]).to.be.equal(expectedVastUrl);
|
|
280
|
+
expect(videoCoreMock.setAdTagUrl.args[0][1]).to.be.equal(expectedDivId);
|
|
281
|
+
expect(videoCoreMock.setAdTagUrl.args[0][2]).to.have.property('adUnitCode', expectedAdUnitCode);
|
|
282
|
+
expect(videoCoreMock.setAdTagUrl.args[0][2]).to.have.property('adXml', expectedVastXml);
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
describe('Ad tracking', function () {
|
|
287
|
+
const expectedAdEventPayload = { adEventPayloadMarker: 'marker' };
|
|
288
|
+
const expectedBid = { bidMarker: 'marker' };
|
|
289
|
+
let bidAdjustmentCb;
|
|
290
|
+
let adImpressionCb;
|
|
291
|
+
let adErrorCb;
|
|
292
|
+
|
|
293
|
+
const pbEvents = {
|
|
294
|
+
on: (event, callback) => {
|
|
295
|
+
if (event === CONSTANTS.EVENTS.BID_ADJUSTMENT) {
|
|
296
|
+
bidAdjustmentCb = callback;
|
|
297
|
+
} else if (event === 'videoAdImpression') {
|
|
298
|
+
adImpressionCb = callback;
|
|
299
|
+
} else if (event === 'videoAdError') {
|
|
300
|
+
adErrorCb = callback;
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
emit: sinon.spy()
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
it('should ask Impression Verifier to track bid on Bid Adjustment', function () {
|
|
307
|
+
pbVideoFactory(null, null, null, pbEvents);
|
|
308
|
+
bidAdjustmentCb();
|
|
309
|
+
expect(videoImpressionVerifierMock.trackBid.calledOnce).to.be.true;
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('should trigger video bid impression when the bid matched', function () {
|
|
313
|
+
pbEvents.emit.resetHistory();
|
|
314
|
+
const pbGlobal = Object.assign({}, pbGlobalMock, { getBidResponsesForAdUnitCode: () => ({ bids: [expectedBid] }) });
|
|
315
|
+
const videoImpressionVerifier = Object.assign({}, videoImpressionVerifierMock, { getBidIdentifiers: () => ({}) });
|
|
316
|
+
pbVideoFactory(null, null, pbGlobal, pbEvents, null, null, () => videoImpressionVerifier);
|
|
317
|
+
adImpressionCb(expectedAdEventPayload);
|
|
318
|
+
|
|
319
|
+
expect(pbEvents.emit.calledOnce).to.be.true;
|
|
320
|
+
expect(pbEvents.emit.getCall(0).args[0]).to.be.equal('videoBidImpression');
|
|
321
|
+
const payload = pbEvents.emit.getCall(0).args[1];
|
|
322
|
+
expect(payload.bid).to.be.equal(expectedBid);
|
|
323
|
+
expect(payload.adEvent).to.be.equal(expectedAdEventPayload);
|
|
324
|
+
expect(pbGlobal.markWinningBidAsUsed.calledOnce).to.be.true;
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('should trigger video bid error when the bid matched', function () {
|
|
328
|
+
pbEvents.emit.resetHistory();
|
|
329
|
+
const pbGlobal = Object.assign({}, pbGlobalMock, { getBidResponsesForAdUnitCode: () => ({ bids: [expectedBid] }) });
|
|
330
|
+
const videoImpressionVerifier = Object.assign({}, videoImpressionVerifierMock, { getBidIdentifiers: () => ({}) });
|
|
331
|
+
pbVideoFactory(null, null, pbGlobal, pbEvents, null, null, () => videoImpressionVerifier);
|
|
332
|
+
adErrorCb(expectedAdEventPayload);
|
|
333
|
+
|
|
334
|
+
expect(pbEvents.emit.calledOnce).to.be.true;
|
|
335
|
+
expect(pbEvents.emit.getCall(0).args[0]).to.be.equal('videoBidError');
|
|
336
|
+
const payload = pbEvents.emit.getCall(0).args[1];
|
|
337
|
+
expect(payload.bid).to.be.equal(expectedBid);
|
|
338
|
+
expect(payload.adEvent).to.be.equal(expectedAdEventPayload);
|
|
339
|
+
expect(pbGlobal.markWinningBidAsUsed.calledOnce).to.be.true;
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
it('should not trigger a bid impression when the bid did not match', function () {
|
|
343
|
+
pbEvents.emit.resetHistory();
|
|
344
|
+
const pbGlobal = Object.assign({}, pbGlobalMock, { getBidResponsesForAdUnitCode: () => ({ bids: [expectedBid] }) });
|
|
345
|
+
const videoImpressionVerifier = Object.assign({}, videoImpressionVerifierMock, { getBidIdentifiers: () => ({ auctionId: 'id' }) });
|
|
346
|
+
pbVideoFactory(null, null, pbGlobal, pbEvents, null, null, () => videoImpressionVerifier);
|
|
347
|
+
adImpressionCb(expectedAdEventPayload);
|
|
348
|
+
|
|
349
|
+
expect(pbEvents.emit.called).to.be.false;
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
it('should not trigger a bid error when the bid did not match', function () {
|
|
353
|
+
pbEvents.emit.resetHistory();
|
|
354
|
+
const pbGlobal = Object.assign({}, pbGlobalMock, { getBidResponsesForAdUnitCode: () => ({ bids: [expectedBid] }) });
|
|
355
|
+
const videoImpressionVerifier = Object.assign({}, videoImpressionVerifierMock, { getBidIdentifiers: () => ({ auctionId: 'id' }) });
|
|
356
|
+
pbVideoFactory(null, null, pbGlobal, pbEvents, null, null, () => videoImpressionVerifier);
|
|
357
|
+
adErrorCb(expectedAdEventPayload);
|
|
358
|
+
|
|
359
|
+
expect(pbEvents.emit.called).to.be.false;
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { SubmoduleBuilder, ParentModule } from 'libraries/video/shared/parentModule.js';
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
|
|
4
|
+
describe('Parent Module', function() {
|
|
5
|
+
const idForMock = 0;
|
|
6
|
+
const vendorCodeForMock = 'a';
|
|
7
|
+
const unrecognizedId = 999;
|
|
8
|
+
const unrecognizedVendorCode = 'zzz';
|
|
9
|
+
const mockSubmodule = { test: 'test' };
|
|
10
|
+
const mockSubmoduleBuilder = {
|
|
11
|
+
build: vendorCode => {
|
|
12
|
+
if (vendorCode === vendorCodeForMock) {
|
|
13
|
+
return mockSubmodule;
|
|
14
|
+
} else {
|
|
15
|
+
throw new Error('flawed');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const parentModule = ParentModule(mockSubmoduleBuilder);
|
|
20
|
+
|
|
21
|
+
describe('Register Submodule', function () {
|
|
22
|
+
it('should throw when the builder fails to build', function () {
|
|
23
|
+
expect(() => parentModule.registerSubmodule(unrecognizedId, unrecognizedVendorCode)).to.throw('flawed');
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('Get Submodule', function () {
|
|
28
|
+
it('should return registered submodules', function () {
|
|
29
|
+
parentModule.registerSubmodule(idForMock, vendorCodeForMock);
|
|
30
|
+
const submodule = parentModule.getSubmodule(idForMock);
|
|
31
|
+
expect(submodule).to.be.equal(mockSubmodule);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should return undefined when submodule is not registered', function () {
|
|
35
|
+
const submodule = parentModule.getSubmodule(unrecognizedId);
|
|
36
|
+
expect(submodule).to.be.undefined;
|
|
37
|
+
});
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('Submodule Builder', function () {
|
|
42
|
+
const vendorCode1 = 1;
|
|
43
|
+
const vendorCode2 = 2;
|
|
44
|
+
const submodule1 = {};
|
|
45
|
+
const initSpy = sinon.spy();
|
|
46
|
+
const submodule2 = { init: initSpy };
|
|
47
|
+
const submoduleFactory1 = () => submodule1;
|
|
48
|
+
const submoduleFactory2 = () => submodule2;
|
|
49
|
+
const submoduleFactory1Spy = sinon.spy(submoduleFactory1);
|
|
50
|
+
|
|
51
|
+
const vendorDirectory = {};
|
|
52
|
+
vendorDirectory[vendorCode1] = submoduleFactory1Spy;
|
|
53
|
+
vendorDirectory[vendorCode2] = submoduleFactory2;
|
|
54
|
+
|
|
55
|
+
const submoduleBuilder = SubmoduleBuilder(vendorDirectory);
|
|
56
|
+
|
|
57
|
+
it('should call submodule factory when vendor code is supported', function () {
|
|
58
|
+
const submodule = submoduleBuilder.build(vendorCode1);
|
|
59
|
+
expect(submoduleFactory1Spy.calledOnce).to.be.true;
|
|
60
|
+
expect(submodule).to.be.equal(submodule1);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should instantiate the submodule, when supported', function () {
|
|
64
|
+
const submodule = submoduleBuilder.build(vendorCode2);
|
|
65
|
+
expect(initSpy.calledOnce).to.be.true;
|
|
66
|
+
expect(submodule).to.be.equal(submodule2);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should throw when vendor code is not recognized', function () {
|
|
70
|
+
const unrecognizedVendorCode = 999;
|
|
71
|
+
expect(() => submoduleBuilder.build(unrecognizedVendorCode)).to.throw('Unrecognized submodule vendor code: ' + unrecognizedVendorCode);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import stateFactory from 'libraries/video/shared/state.js';
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
|
|
4
|
+
describe('State', function () {
|
|
5
|
+
let state = stateFactory();
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
state.clearState();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('should update state', function () {
|
|
11
|
+
state.updateState({ 'test': 'a' });
|
|
12
|
+
expect(state.getState()).to.have.property('test', 'a');
|
|
13
|
+
state.updateState({ 'test': 'b' });
|
|
14
|
+
expect(state.getState()).to.have.property('test', 'b');
|
|
15
|
+
state.updateState({ 'test_2': 'c' });
|
|
16
|
+
expect(state.getState()).to.have.property('test', 'b');
|
|
17
|
+
expect(state.getState()).to.have.property('test_2', 'c');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should clear state', function () {
|
|
21
|
+
state.updateState({ 'test': 'a' });
|
|
22
|
+
state.clearState();
|
|
23
|
+
expect(state.getState()).to.not.have.property('test', 'a');
|
|
24
|
+
expect(state.getState()).to.be.empty;
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { buildVastWrapper, getVastNode, getAdNode, getWrapperNode, getAdSystemNode,
|
|
2
|
+
getAdTagUriNode, getErrorNode, getImpressionNode } from 'libraries/video/shared/vastXmlBuilder.js';
|
|
3
|
+
import { expect } from 'chai';
|
|
4
|
+
|
|
5
|
+
describe('buildVastWrapper', function () {
|
|
6
|
+
it('should include impression and error nodes when requested', function () {
|
|
7
|
+
const vastXml = buildVastWrapper(
|
|
8
|
+
'adId123',
|
|
9
|
+
'http://wwww.testUrl.com/redirectUrl.xml',
|
|
10
|
+
'http://wwww.testUrl.com/impression.jpg',
|
|
11
|
+
'impressionId123',
|
|
12
|
+
'http://wwww.testUrl.com/error.jpg'
|
|
13
|
+
);
|
|
14
|
+
expect(vastXml).to.be.equal(`<VAST version="4.2"><Ad id="adId123"><Wrapper><AdSystem version="${$$PREBID_GLOBAL$$.version}">Prebid org</AdSystem><VASTAdTagURI><![CDATA[http://wwww.testUrl.com/redirectUrl.xml]]></VASTAdTagURI><Impression id="impressionId123"><![CDATA[http://wwww.testUrl.com/impression.jpg]]></Impression><Error><![CDATA[http://wwww.testUrl.com/error.jpg]]></Error></Wrapper></Ad></VAST>`);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should omit error nodes when excluded', function () {
|
|
18
|
+
const vastXml = buildVastWrapper(
|
|
19
|
+
'adId123',
|
|
20
|
+
'http://wwww.testUrl.com/redirectUrl.xml',
|
|
21
|
+
'http://wwww.testUrl.com/impression.jpg',
|
|
22
|
+
'impressionId123',
|
|
23
|
+
);
|
|
24
|
+
expect(vastXml).to.be.equal(`<VAST version="4.2"><Ad id="adId123"><Wrapper><AdSystem version="${$$PREBID_GLOBAL$$.version}">Prebid org</AdSystem><VASTAdTagURI><![CDATA[http://wwww.testUrl.com/redirectUrl.xml]]></VASTAdTagURI><Impression id="impressionId123"><![CDATA[http://wwww.testUrl.com/impression.jpg]]></Impression></Wrapper></Ad></VAST>`);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should omit impression nodes when excluded', function () {
|
|
28
|
+
const vastXml = buildVastWrapper(
|
|
29
|
+
'adId123',
|
|
30
|
+
'http://wwww.testUrl.com/redirectUrl.xml',
|
|
31
|
+
);
|
|
32
|
+
expect(vastXml).to.be.equal(`<VAST version="4.2"><Ad id="adId123"><Wrapper><AdSystem version="${$$PREBID_GLOBAL$$.version}">Prebid org</AdSystem><VASTAdTagURI><![CDATA[http://wwww.testUrl.com/redirectUrl.xml]]></VASTAdTagURI></Wrapper></Ad></VAST>`);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('getVastNode', function () {
|
|
37
|
+
it('should return well formed Vast node', function () {
|
|
38
|
+
const vastNode = getVastNode('body', '4.0');
|
|
39
|
+
expect(vastNode).to.be.equal('<VAST version=\"4.0\">body</VAST>');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should omit version when missing', function() {
|
|
43
|
+
const vastNode = getVastNode('body');
|
|
44
|
+
expect(vastNode).to.be.equal('<VAST>body</VAST>');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('getAdNode', function () {
|
|
49
|
+
it('should return well formed Ad node', function () {
|
|
50
|
+
const adNode = getAdNode('body', 'adId123');
|
|
51
|
+
expect(adNode).to.be.equal('<Ad id=\"adId123\">body</Ad>');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should omit id when missing', function() {
|
|
55
|
+
const adNode = getAdNode('body');
|
|
56
|
+
expect(adNode).to.be.equal('<Ad>body</Ad>');
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('getWrapperNode', function () {
|
|
61
|
+
it('should return well formed Wrapper node', function () {
|
|
62
|
+
const wrapperNode = getWrapperNode('body');
|
|
63
|
+
expect(wrapperNode).to.be.equal('<Wrapper>body</Wrapper>');
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('getAdSystemNode', function () {
|
|
68
|
+
it('should return well formed AdSystem node', function () {
|
|
69
|
+
const adSystemNode = getAdSystemNode('testSysName', '5.0');
|
|
70
|
+
expect(adSystemNode).to.be.equal('<AdSystem version=\"5.0\">testSysName</AdSystem>');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should omit version when missing', function() {
|
|
74
|
+
const adSystemNode = getAdSystemNode('testSysName');
|
|
75
|
+
expect(adSystemNode).to.be.equal('<AdSystem>testSysName</AdSystem>');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('getAdTagUriNode', function () {
|
|
80
|
+
it('should return well formed ad tag URI node', function () {
|
|
81
|
+
const adTagNode = getAdTagUriNode('http://wwww.testUrl.com/ad.xml');
|
|
82
|
+
expect(adTagNode).to.be.equal('<VASTAdTagURI><![CDATA[http://wwww.testUrl.com/ad.xml]]></VASTAdTagURI>');
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe('getImpressionNode', function () {
|
|
87
|
+
it('should return well formed Impression node', function () {
|
|
88
|
+
const impressionNode = getImpressionNode('http://wwww.testUrl.com/adImpression.jpg', 'impresionId123');
|
|
89
|
+
expect(impressionNode).to.be.equal('<Impression id=\"impresionId123\"><![CDATA[http://wwww.testUrl.com/adImpression.jpg]]></Impression>');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('should omit id when missing', function() {
|
|
93
|
+
const impressionNode = getImpressionNode('http://wwww.testUrl.com/adImpression.jpg');
|
|
94
|
+
expect(impressionNode).to.be.equal('<Impression><![CDATA[http://wwww.testUrl.com/adImpression.jpg]]></Impression>');
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('getErrorNode', function () {
|
|
99
|
+
it('should return well formed Error node', function () {
|
|
100
|
+
const errorNode = getErrorNode('http://wwww.testUrl.com/adError.jpg');
|
|
101
|
+
expect(errorNode).to.be.equal('<Error><![CDATA[http://wwww.testUrl.com/adError.jpg]]></Error>');
|
|
102
|
+
});
|
|
103
|
+
});
|