prebid.js 7.22.0 → 7.24.0
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/admaticBidAdapter.js +1 -0
- package/dist/adrelevantisBidAdapter.js +1 -1
- package/dist/adtrgtmeBidAdapter.js +1 -1
- package/dist/adxcgBidAdapter.js +1 -1
- package/dist/adyoulikeBidAdapter.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/audiencerunBidAdapter.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/bluebillywigBidAdapter.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/connectIdSystem.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/growthCodeIdSystem.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/impactifyBidAdapter.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/jixieBidAdapter.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/kueezRtbBidAdapter.js +1 -0
- 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/mediakeysBidAdapter.js +1 -1
- package/dist/mediasquareBidAdapter.js +1 -1
- package/dist/mgidBidAdapter.js +1 -1
- package/dist/mgidRtdProvider.js +1 -0
- package/dist/minutemediaBidAdapter.js +1 -1
- package/dist/multibid.js +1 -1
- package/dist/not-for-prod/prebid.js +153 -141
- 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/permutiveRtdProvider.js +1 -1
- 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/gpt/mgidRtdProvider_example.html +143 -0
- 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 +7 -1
- package/modules/aaxBlockmeterRtdProvider.js +59 -0
- package/modules/aaxBlockmeterRtdProvider.md +48 -0
- package/modules/admaticBidAdapter.js +147 -0
- package/modules/admaticBidAdapter.md +48 -0
- package/modules/amxBidAdapter.js +1 -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/connectIdSystem.js +36 -23
- package/modules/connectIdSystem.md +3 -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/growthCodeIdSystem.js +9 -5
- package/modules/gumgumBidAdapter.js +4 -0
- package/modules/improvedigitalBidAdapter.js +191 -470
- package/modules/ixBidAdapter.js +54 -71
- package/modules/jwplayerVideoProvider.js +929 -0
- package/modules/jwplayerVideoProvider.md +25 -0
- package/modules/kargoBidAdapter.js +1 -1
- package/modules/kueezRtbBidAdapter.js +278 -0
- package/modules/kueezRtbBidAdapter.md +35 -0
- package/modules/magniteAnalyticsAdapter.js +6 -1
- package/modules/mgidRtdProvider.js +190 -0
- package/modules/mgidRtdProvider.md +51 -0
- 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/permutiveRtdProvider.js +2 -1
- package/modules/permutiveRtdProvider.md +36 -1
- package/modules/prebidServerBidAdapter/index.js +19 -716
- package/modules/prebidServerBidAdapter/ortbConverter.js +274 -0
- package/modules/priceFloors.js +73 -1
- package/modules/pubmaticBidAdapter.js +21 -29
- 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/tripleliftBidAdapter.js +1 -1
- package/modules/userId/eids.js +3 -10
- 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 +12 -8
- package/src/adRendering.js +1 -1
- package/src/adapterManager.js +56 -7
- package/src/adloader.js +3 -1
- package/src/auction.js +6 -1
- 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 +15 -0
- package/test/spec/modules/aaxBlockmeter_spec.js +58 -0
- package/test/spec/modules/admaticBidAdapter_spec.js +46 -0
- package/test/spec/modules/chtnwBidAdapter_spec.js +105 -0
- package/test/spec/modules/concertBidAdapter_spec.js +56 -0
- package/test/spec/modules/connectIdSystem_spec.js +175 -5
- 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/eids_spec.js +10 -7
- package/test/spec/modules/ftrackIdSystem_spec.js +34 -22
- package/test/spec/modules/gumgumBidAdapter_spec.js +15 -0
- package/test/spec/modules/improvedigitalBidAdapter_spec.js +231 -211
- package/test/spec/modules/ixBidAdapter_spec.js +412 -350
- package/test/spec/modules/kueezRtbBidAdapter_spec.js +396 -0
- package/test/spec/modules/magniteAnalyticsAdapter_spec.js +26 -0
- package/test/spec/modules/mgidRtdProvider_spec.js +366 -0
- package/test/spec/modules/openxOrtbBidAdapter_spec.js +77 -49
- package/test/spec/modules/oxxionRtdProvider_spec.js +142 -0
- package/test/spec/modules/permutiveRtdProvider_spec.js +64 -5
- package/test/spec/modules/prebidServerBidAdapter_spec.js +139 -137
- package/test/spec/modules/realTimeDataModule_spec.js +65 -0
- package/test/spec/modules/tripleliftBidAdapter_spec.js +14 -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,846 @@
|
|
|
1
|
+
import {
|
|
2
|
+
JWPlayerProvider,
|
|
3
|
+
adStateFactory,
|
|
4
|
+
timeStateFactory,
|
|
5
|
+
callbackStorageFactory,
|
|
6
|
+
utils
|
|
7
|
+
} from 'modules/jwplayerVideoProvider';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
PROTOCOLS, API_FRAMEWORKS, VIDEO_MIME_TYPE, PLAYBACK_METHODS, PLACEMENT, VPAID_MIME_TYPE
|
|
11
|
+
} from 'libraries/video/constants/ortb.js';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
SETUP_COMPLETE, SETUP_FAILED, PLAY, AD_IMPRESSION, videoEvents
|
|
15
|
+
} from 'libraries/video/constants/events.js';
|
|
16
|
+
|
|
17
|
+
import { PLAYBACK_MODE } from 'libraries/video/constants/enums.js';
|
|
18
|
+
|
|
19
|
+
function getPlayerMock() {
|
|
20
|
+
return makePlayerFactoryMock({
|
|
21
|
+
getState: function () {},
|
|
22
|
+
setup: function () {},
|
|
23
|
+
getViewable: function () {},
|
|
24
|
+
getPercentViewable: function () {},
|
|
25
|
+
getMute: function () {},
|
|
26
|
+
getVolume: function () {},
|
|
27
|
+
getConfig: function () {},
|
|
28
|
+
getHeight: function () {},
|
|
29
|
+
getWidth: function () {},
|
|
30
|
+
getFullscreen: function () {},
|
|
31
|
+
getPlaylistItem: function () {},
|
|
32
|
+
playAd: function () {},
|
|
33
|
+
on: function () {},
|
|
34
|
+
off: function () {},
|
|
35
|
+
remove: function () {},
|
|
36
|
+
getAudioTracks: function () {},
|
|
37
|
+
getCurrentAudioTrack: function () {},
|
|
38
|
+
getPlugin: function () {},
|
|
39
|
+
getFloating: function () {}
|
|
40
|
+
})();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function makePlayerFactoryMock(playerMock_) {
|
|
44
|
+
const playerFactory = function () {
|
|
45
|
+
return playerMock_;
|
|
46
|
+
}
|
|
47
|
+
playerFactory.version = '8.21.0';
|
|
48
|
+
return playerFactory;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getUtilsMock() {
|
|
52
|
+
return {
|
|
53
|
+
getJwConfig: function () {},
|
|
54
|
+
getSupportedMediaTypes: function () {},
|
|
55
|
+
getStartDelay: function () {},
|
|
56
|
+
getPlacement: function () {},
|
|
57
|
+
getPlaybackMethod: function () {},
|
|
58
|
+
isOmidSupported: function () {},
|
|
59
|
+
getSkipParams: function () {},
|
|
60
|
+
getJwEvent: event => event,
|
|
61
|
+
getIsoLanguageCode: function () {},
|
|
62
|
+
getSegments: function () {},
|
|
63
|
+
getContentDatum: function () {}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const sharedUtils = { videoEvents };
|
|
68
|
+
|
|
69
|
+
describe('JWPlayerProvider', function () {
|
|
70
|
+
describe('init', function () {
|
|
71
|
+
let config;
|
|
72
|
+
let adState;
|
|
73
|
+
let timeState;
|
|
74
|
+
let callbackStorage;
|
|
75
|
+
let utilsMock;
|
|
76
|
+
|
|
77
|
+
beforeEach(() => {
|
|
78
|
+
config = {};
|
|
79
|
+
adState = adStateFactory();
|
|
80
|
+
timeState = timeStateFactory();
|
|
81
|
+
callbackStorage = callbackStorageFactory();
|
|
82
|
+
utilsMock = getUtilsMock();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should trigger failure when jwplayer is missing', function () {
|
|
86
|
+
const provider = JWPlayerProvider(config, null, adState, timeState, callbackStorage, utilsMock, sharedUtils);
|
|
87
|
+
const setupFailed = sinon.spy();
|
|
88
|
+
provider.onEvent(SETUP_FAILED, setupFailed, {});
|
|
89
|
+
provider.init();
|
|
90
|
+
expect(setupFailed.calledOnce).to.be.true;
|
|
91
|
+
const payload = setupFailed.args[0][1];
|
|
92
|
+
expect(payload.errorCode).to.be.equal(-1);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should trigger failure when jwplayer version is under min supported version', function () {
|
|
96
|
+
let jwplayerMock = () => {};
|
|
97
|
+
jwplayerMock.version = '8.20.0';
|
|
98
|
+
const provider = JWPlayerProvider(config, jwplayerMock, adState, timeState, callbackStorage, utilsMock, sharedUtils);
|
|
99
|
+
const setupFailed = sinon.spy();
|
|
100
|
+
provider.onEvent(SETUP_FAILED, setupFailed, {});
|
|
101
|
+
provider.init();
|
|
102
|
+
expect(setupFailed.calledOnce).to.be.true;
|
|
103
|
+
const payload = setupFailed.args[0][1];
|
|
104
|
+
expect(payload.errorCode).to.be.equal(-2);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should instantiate the player when uninstantied', function () {
|
|
108
|
+
const player = getPlayerMock();
|
|
109
|
+
config.playerConfig = {};
|
|
110
|
+
const setupSpy = player.setup = sinon.spy();
|
|
111
|
+
const provider = JWPlayerProvider(config, makePlayerFactoryMock(player), adState, timeState, callbackStorage, utilsMock, sharedUtils);
|
|
112
|
+
provider.init();
|
|
113
|
+
expect(setupSpy.calledOnce).to.be.true;
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('should trigger setup complete when player is already instantied', function () {
|
|
117
|
+
const player = getPlayerMock();
|
|
118
|
+
player.getState = () => 'idle';
|
|
119
|
+
const provider = JWPlayerProvider(config, makePlayerFactoryMock(player), adState, timeState, callbackStorage, utilsMock, sharedUtils);
|
|
120
|
+
const setupComplete = sinon.spy();
|
|
121
|
+
provider.onEvent(SETUP_COMPLETE, setupComplete, {});
|
|
122
|
+
provider.init();
|
|
123
|
+
expect(setupComplete.calledOnce).to.be.true;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('should not reinstantiate player', function () {
|
|
127
|
+
const player = getPlayerMock();
|
|
128
|
+
player.getState = () => 'idle';
|
|
129
|
+
const setupSpy = player.setup = sinon.spy();
|
|
130
|
+
const provider = JWPlayerProvider(config, makePlayerFactoryMock(player), adState, timeState, callbackStorage, utilsMock, sharedUtils);
|
|
131
|
+
provider.init();
|
|
132
|
+
expect(setupSpy.called).to.be.false;
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe('getId', function () {
|
|
137
|
+
it('should return configured div id', function () {
|
|
138
|
+
const provider = JWPlayerProvider({ divId: 'test_id' }, undefined, undefined, undefined, undefined, undefined, sharedUtils);
|
|
139
|
+
expect(provider.getId()).to.be.equal('test_id');
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe('getOrtbVideo', function () {
|
|
144
|
+
it('should populate oRTB Video params', function () {
|
|
145
|
+
const test_media_type = VIDEO_MIME_TYPE.MP4;
|
|
146
|
+
const test_height = 100;
|
|
147
|
+
const test_width = 200;
|
|
148
|
+
const test_start_delay = 5;
|
|
149
|
+
const test_placement = PLACEMENT.ARTICLE;
|
|
150
|
+
const test_battr = 'battr';
|
|
151
|
+
const test_playback_method = PLAYBACK_METHODS.CLICK_TO_PLAY;
|
|
152
|
+
const test_skip = 0;
|
|
153
|
+
|
|
154
|
+
const config = {};
|
|
155
|
+
const player = getPlayerMock();
|
|
156
|
+
const utils = getUtilsMock();
|
|
157
|
+
|
|
158
|
+
player.getConfig = () => ({
|
|
159
|
+
advertising: {
|
|
160
|
+
battr: test_battr
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
player.getHeight = () => test_height;
|
|
164
|
+
player.getWidth = () => test_width;
|
|
165
|
+
player.getFullscreen = () => true; //
|
|
166
|
+
|
|
167
|
+
utils.getSupportedMediaTypes = () => [test_media_type];
|
|
168
|
+
utils.getStartDelay = () => test_start_delay;
|
|
169
|
+
utils.getPlacement = () => test_placement;
|
|
170
|
+
utils.getPlaybackMethod = () => test_playback_method;
|
|
171
|
+
utils.isOmidSupported = () => true; //
|
|
172
|
+
utils.getSkipParams = () => ({ skip: test_skip });
|
|
173
|
+
|
|
174
|
+
const provider = JWPlayerProvider(config, makePlayerFactoryMock(player), adStateFactory(), {}, {}, utils, sharedUtils);
|
|
175
|
+
provider.init();
|
|
176
|
+
let video = provider.getOrtbVideo();
|
|
177
|
+
|
|
178
|
+
expect(video.mimes).to.include(VIDEO_MIME_TYPE.MP4);
|
|
179
|
+
expect(video.protocols).to.include.members([
|
|
180
|
+
PROTOCOLS.VAST_2_0,
|
|
181
|
+
PROTOCOLS.VAST_3_0,
|
|
182
|
+
PROTOCOLS.VAST_4_0,
|
|
183
|
+
PROTOCOLS.VAST_2_0_WRAPPER,
|
|
184
|
+
PROTOCOLS.VAST_3_0_WRAPPER,
|
|
185
|
+
PROTOCOLS.VAST_4_0_WRAPPER
|
|
186
|
+
]);
|
|
187
|
+
expect(video.h).to.equal(test_height);
|
|
188
|
+
expect(video.w).to.equal(test_width);
|
|
189
|
+
expect(video.startdelay).to.equal(test_start_delay);
|
|
190
|
+
expect(video.placement).to.equal(test_placement);
|
|
191
|
+
expect(video.battr).to.equal(test_battr);
|
|
192
|
+
expect(video.maxextended).to.equal(-1);
|
|
193
|
+
expect(video.boxingallowed).to.equal(1);
|
|
194
|
+
expect(video.playbackmethod).to.include(test_playback_method);
|
|
195
|
+
expect(video.playbackend).to.equal(1);
|
|
196
|
+
expect(video.api).to.have.length(2);
|
|
197
|
+
expect(video.api).to.include.members([API_FRAMEWORKS.VPAID_2_0, API_FRAMEWORKS.OMID_1_0]); //
|
|
198
|
+
expect(video.skip).to.equal(test_skip);
|
|
199
|
+
expect(video.pos).to.equal(7); //
|
|
200
|
+
|
|
201
|
+
player.getFullscreen = () => false;
|
|
202
|
+
utils.isOmidSupported = () => false;
|
|
203
|
+
|
|
204
|
+
video = provider.getOrtbVideo();
|
|
205
|
+
expect(video).to.not.have.property('pos');
|
|
206
|
+
expect(video.api).to.have.length(1);
|
|
207
|
+
expect(video.api).to.include(API_FRAMEWORKS.VPAID_2_0);
|
|
208
|
+
expect(video.api).to.not.include(API_FRAMEWORKS.OMID_1_0);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
describe('getOrtbContent', function () {
|
|
213
|
+
it('should populate oRTB Content params', function () {
|
|
214
|
+
const test_item = {
|
|
215
|
+
mediaid: 'id',
|
|
216
|
+
file: 'file',
|
|
217
|
+
title: 'title',
|
|
218
|
+
iabCategories: 'iabCategories',
|
|
219
|
+
tags: 'keywords',
|
|
220
|
+
};
|
|
221
|
+
const test_duration = 30;
|
|
222
|
+
let test_playback_mode = PLAYBACK_MODE.VOD;//
|
|
223
|
+
|
|
224
|
+
const player = getPlayerMock();
|
|
225
|
+
player.getPlaylistItem = () => test_item;
|
|
226
|
+
const utils = getUtilsMock();
|
|
227
|
+
|
|
228
|
+
const timeState = {
|
|
229
|
+
getState: () => ({
|
|
230
|
+
duration: test_duration,
|
|
231
|
+
playbackMode: test_playback_mode
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const provider = JWPlayerProvider({}, makePlayerFactoryMock(player), adStateFactory(), timeState, {}, utils, sharedUtils);
|
|
236
|
+
provider.init();
|
|
237
|
+
|
|
238
|
+
let content = provider.getOrtbContent();
|
|
239
|
+
expect(content.id).to.be.equal('jw_' + test_item.mediaid);
|
|
240
|
+
expect(content.url).to.be.equal(test_item.file);
|
|
241
|
+
expect(content.title).to.be.equal(test_item.title);
|
|
242
|
+
expect(content.cat).to.be.equal(test_item.iabCategories);
|
|
243
|
+
expect(content.keywords).to.be.equal(test_item.tags);
|
|
244
|
+
expect(content.len).to.be.equal(test_duration);
|
|
245
|
+
expect(content.livestream).to.be.equal(0);//
|
|
246
|
+
|
|
247
|
+
test_playback_mode = PLAYBACK_MODE.LIVE;
|
|
248
|
+
|
|
249
|
+
content = provider.getOrtbContent();
|
|
250
|
+
expect(content.livestream).to.be.equal(1);
|
|
251
|
+
|
|
252
|
+
test_playback_mode = PLAYBACK_MODE.DVR;
|
|
253
|
+
|
|
254
|
+
content = provider.getOrtbContent();
|
|
255
|
+
expect(content.livestream).to.be.equal(1);
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
describe('setAdTagUrl', function () {
|
|
260
|
+
it('should call playAd', function () {
|
|
261
|
+
const player = getPlayerMock();
|
|
262
|
+
const playAdSpy = player.playAd = sinon.spy();
|
|
263
|
+
const provider = JWPlayerProvider({}, makePlayerFactoryMock(player), {}, {}, {}, {}, sharedUtils);
|
|
264
|
+
provider.init();
|
|
265
|
+
provider.setAdTagUrl('tag');
|
|
266
|
+
expect(playAdSpy.called).to.be.true;
|
|
267
|
+
const argument = playAdSpy.args[0][0];
|
|
268
|
+
expect(argument).to.be.equal('tag');
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
describe('events', function () {
|
|
273
|
+
it('should register event listener on player', function () {
|
|
274
|
+
const player = getPlayerMock();
|
|
275
|
+
const onSpy = player.on = sinon.spy();
|
|
276
|
+
const provider = JWPlayerProvider({}, makePlayerFactoryMock(player), adStateFactory(), timeStateFactory(), callbackStorageFactory(), getUtilsMock(), sharedUtils);
|
|
277
|
+
provider.init();
|
|
278
|
+
const callback = () => {};
|
|
279
|
+
provider.onEvent(PLAY, callback, {});
|
|
280
|
+
expect(onSpy.calledOnce).to.be.true;
|
|
281
|
+
const eventName = onSpy.args[0][0];
|
|
282
|
+
expect(eventName).to.be.equal('play');
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it('should remove event listener on player', function () {
|
|
286
|
+
const player = getPlayerMock();
|
|
287
|
+
const offSpy = player.off = sinon.spy();
|
|
288
|
+
const provider = JWPlayerProvider({}, makePlayerFactoryMock(player), adStateFactory(), timeStateFactory(), callbackStorageFactory(), utils, sharedUtils);
|
|
289
|
+
provider.init();
|
|
290
|
+
const callback = () => {};
|
|
291
|
+
provider.onEvent(AD_IMPRESSION, callback, {});
|
|
292
|
+
provider.offEvent(AD_IMPRESSION, callback);
|
|
293
|
+
expect(offSpy.calledOnce).to.be.true;
|
|
294
|
+
const eventName = offSpy.args[0][0];
|
|
295
|
+
expect(eventName).to.be.equal('adViewableImpression');
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
describe('destroy', function () {
|
|
300
|
+
it('should remove and null the player', function () {
|
|
301
|
+
const player = getPlayerMock();
|
|
302
|
+
const removeSpy = player.remove = sinon.spy();
|
|
303
|
+
player.remove = removeSpy;
|
|
304
|
+
const provider = JWPlayerProvider({}, makePlayerFactoryMock(player), adStateFactory(), timeStateFactory(), callbackStorageFactory(), getUtilsMock(), sharedUtils);
|
|
305
|
+
provider.init();
|
|
306
|
+
provider.destroy();
|
|
307
|
+
provider.destroy();
|
|
308
|
+
expect(removeSpy.calledOnce).to.be.true;
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
describe('adStateFactory', function () {
|
|
314
|
+
let adState = adStateFactory();
|
|
315
|
+
|
|
316
|
+
beforeEach(() => {
|
|
317
|
+
adState.clearState();
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
it('should update state for ad events', function () {
|
|
321
|
+
const tag = 'tag';
|
|
322
|
+
const adPosition = 'adPosition';
|
|
323
|
+
const timeLoading = 'timeLoading';
|
|
324
|
+
const id = 'id';
|
|
325
|
+
const description = 'description';
|
|
326
|
+
const adsystem = 'adsystem';
|
|
327
|
+
const adtitle = 'adtitle';
|
|
328
|
+
const advertiserId = 'advertiserId';
|
|
329
|
+
const advertiser = 'advertiser';
|
|
330
|
+
const dealId = 'dealId';
|
|
331
|
+
const linear = 'linear';
|
|
332
|
+
const vastversion = 'vastversion';
|
|
333
|
+
const mediaFile = 'mediaFile';
|
|
334
|
+
const adId = 'adId';
|
|
335
|
+
const universalAdId = 'universalAdId';
|
|
336
|
+
const creativeAdId = 'creativeAdId';
|
|
337
|
+
const creativetype = 'creativetype';
|
|
338
|
+
const clickThroughUrl = 'clickThroughUrl';
|
|
339
|
+
const witem = 'witem';
|
|
340
|
+
const wcount = 'wcount';
|
|
341
|
+
const podcount = 'podcount';
|
|
342
|
+
const sequence = 'sequence';
|
|
343
|
+
|
|
344
|
+
adState.updateForEvent({
|
|
345
|
+
tag,
|
|
346
|
+
adPosition,
|
|
347
|
+
timeLoading,
|
|
348
|
+
id,
|
|
349
|
+
description,
|
|
350
|
+
adsystem,
|
|
351
|
+
adtitle,
|
|
352
|
+
advertiserId,
|
|
353
|
+
advertiser,
|
|
354
|
+
dealId,
|
|
355
|
+
linear,
|
|
356
|
+
vastversion,
|
|
357
|
+
mediaFile,
|
|
358
|
+
adId,
|
|
359
|
+
universalAdId,
|
|
360
|
+
creativeAdId,
|
|
361
|
+
creativetype,
|
|
362
|
+
clickThroughUrl,
|
|
363
|
+
witem,
|
|
364
|
+
wcount,
|
|
365
|
+
podcount,
|
|
366
|
+
sequence
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
const state = adState.getState();
|
|
370
|
+
expect(state.adTagUrl).to.equal(tag);
|
|
371
|
+
expect(state.offset).to.equal(adPosition);
|
|
372
|
+
expect(state.loadTime).to.equal(timeLoading);
|
|
373
|
+
expect(state.vastAdId).to.equal(id);
|
|
374
|
+
expect(state.adDescription).to.equal(description);
|
|
375
|
+
expect(state.adServer).to.equal(adsystem);
|
|
376
|
+
expect(state.adTitle).to.equal(adtitle);
|
|
377
|
+
expect(state.advertiserId).to.equal(advertiserId);
|
|
378
|
+
expect(state.dealId).to.equal(dealId);
|
|
379
|
+
expect(state.linear).to.equal(linear);
|
|
380
|
+
expect(state.vastVersion).to.equal(vastversion);
|
|
381
|
+
expect(state.creativeUrl).to.equal(mediaFile);
|
|
382
|
+
expect(state.adId).to.equal(adId);
|
|
383
|
+
expect(state.universalAdId).to.equal(universalAdId);
|
|
384
|
+
expect(state.creativeId).to.equal(creativeAdId);
|
|
385
|
+
expect(state.creativeType).to.equal(creativetype);
|
|
386
|
+
expect(state.redirectUrl).to.equal(clickThroughUrl);
|
|
387
|
+
expect(state).to.have.property('adPlacementType');
|
|
388
|
+
expect(state.adPlacementType).to.be.undefined;
|
|
389
|
+
expect(state.waterfallIndex).to.equal(witem);
|
|
390
|
+
expect(state.waterfallCount).to.equal(wcount);
|
|
391
|
+
expect(state.adPodCount).to.equal(podcount);
|
|
392
|
+
expect(state.adPodIndex).to.equal(sequence);
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
it('should convert placement to oRTB value', function () {
|
|
396
|
+
adState.updateForEvent({
|
|
397
|
+
placement: 'instream'
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
let state = adState.getState();
|
|
401
|
+
expect(state.adPlacementType).to.be.equal(PLACEMENT.INSTREAM);
|
|
402
|
+
|
|
403
|
+
adState.updateForEvent({
|
|
404
|
+
placement: 'banner'
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
state = adState.getState();
|
|
408
|
+
expect(state.adPlacementType).to.be.equal(PLACEMENT.BANNER);
|
|
409
|
+
|
|
410
|
+
adState.updateForEvent({
|
|
411
|
+
placement: 'article'
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
state = adState.getState();
|
|
415
|
+
expect(state.adPlacementType).to.be.equal(PLACEMENT.ARTICLE);
|
|
416
|
+
|
|
417
|
+
adState.updateForEvent({
|
|
418
|
+
placement: 'feed'
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
state = adState.getState();
|
|
422
|
+
expect(state.adPlacementType).to.be.equal(PLACEMENT.FEED);
|
|
423
|
+
|
|
424
|
+
adState.updateForEvent({
|
|
425
|
+
placement: 'interstitial'
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
state = adState.getState();
|
|
429
|
+
expect(state.adPlacementType).to.be.equal(PLACEMENT.INTERSTITIAL);
|
|
430
|
+
|
|
431
|
+
adState.updateForEvent({
|
|
432
|
+
placement: 'slider'
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
state = adState.getState();
|
|
436
|
+
expect(state.adPlacementType).to.be.equal(PLACEMENT.SLIDER);
|
|
437
|
+
|
|
438
|
+
adState.updateForEvent({
|
|
439
|
+
placement: 'floating'
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
state = adState.getState();
|
|
443
|
+
expect(state.adPlacementType).to.be.equal(PLACEMENT.FLOATING);
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
describe('timeStateFactory', function () {
|
|
448
|
+
let timeState = timeStateFactory();
|
|
449
|
+
|
|
450
|
+
beforeEach(() => {
|
|
451
|
+
timeState.clearState();
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
it('should update state for VOD time event', function() {
|
|
455
|
+
const position = 5;
|
|
456
|
+
const test_duration = 30;
|
|
457
|
+
|
|
458
|
+
timeState.updateForEvent({
|
|
459
|
+
position,
|
|
460
|
+
duration: test_duration
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
const { time, duration, playbackMode } = timeState.getState();
|
|
464
|
+
expect(time).to.be.equal(position);
|
|
465
|
+
expect(duration).to.be.equal(test_duration);
|
|
466
|
+
expect(playbackMode).to.be.equal(PLAYBACK_MODE.VOD);
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
it('should update state for LIVE time events', function() {
|
|
470
|
+
const position = 0;
|
|
471
|
+
const test_duration = 0;
|
|
472
|
+
|
|
473
|
+
timeState.updateForEvent({
|
|
474
|
+
position,
|
|
475
|
+
duration: test_duration
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
const { time, duration, playbackMode } = timeState.getState();
|
|
479
|
+
expect(time).to.be.equal(position);
|
|
480
|
+
expect(duration).to.be.equal(test_duration);
|
|
481
|
+
expect(playbackMode).to.be.equal(PLAYBACK_MODE.LIVE);
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
it('should update state for DVR time events', function() {
|
|
485
|
+
const position = -5;
|
|
486
|
+
const test_duration = -30;
|
|
487
|
+
|
|
488
|
+
timeState.updateForEvent({
|
|
489
|
+
position,
|
|
490
|
+
duration: test_duration
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
const { time, duration, playbackMode } = timeState.getState();
|
|
494
|
+
expect(time).to.be.equal(position);
|
|
495
|
+
expect(duration).to.be.equal(test_duration);
|
|
496
|
+
expect(playbackMode).to.be.equal(PLAYBACK_MODE.DVR);
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
describe('callbackStorageFactory', function () {
|
|
501
|
+
let callbackStorage = callbackStorageFactory();
|
|
502
|
+
|
|
503
|
+
beforeEach(() => {
|
|
504
|
+
callbackStorage.clearStorage();
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
it('should store callbacks', function () {
|
|
508
|
+
const callback1 = () => 'callback1';
|
|
509
|
+
const eventHandler1 = () => 'eventHandler1';
|
|
510
|
+
callbackStorage.storeCallback('event', eventHandler1, callback1);
|
|
511
|
+
|
|
512
|
+
const callback2 = () => 'callback2';
|
|
513
|
+
const eventHandler2 = () => 'eventHandler2';
|
|
514
|
+
callbackStorage.storeCallback('event', eventHandler2, callback2);
|
|
515
|
+
|
|
516
|
+
const callback3 = () => 'callback3';
|
|
517
|
+
|
|
518
|
+
expect(callbackStorage.getCallback('event', callback1)).to.be.equal(eventHandler1);
|
|
519
|
+
expect(callbackStorage.getCallback('event', callback2)).to.be.equal(eventHandler2);
|
|
520
|
+
expect(callbackStorage.getCallback('event', callback3)).to.be.undefined;
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
it('should remove callbacks after retrieval', function () {
|
|
524
|
+
const callback1 = () => 'callback1';
|
|
525
|
+
const eventHandler1 = () => 'eventHandler1';
|
|
526
|
+
callbackStorage.storeCallback('event', eventHandler1, callback1);
|
|
527
|
+
|
|
528
|
+
expect(callbackStorage.getCallback('event', callback1)).to.be.equal(eventHandler1);
|
|
529
|
+
expect(callbackStorage.getCallback('event', callback1)).to.be.undefined;
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
it('should clear callbacks', function () {
|
|
533
|
+
const callback1 = () => 'callback1';
|
|
534
|
+
const eventHandler1 = () => 'eventHandler1';
|
|
535
|
+
callbackStorage.storeCallback('event', eventHandler1, callback1);
|
|
536
|
+
|
|
537
|
+
callbackStorage.clearStorage();
|
|
538
|
+
expect(callbackStorage.getCallback('event', callback1)).to.be.undefined;
|
|
539
|
+
});
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
describe('utils', function () {
|
|
543
|
+
describe('getJwConfig', function () {
|
|
544
|
+
const getJwConfig = utils.getJwConfig;
|
|
545
|
+
it('should return undefined when no config is provided', function () {
|
|
546
|
+
let jwConfig = getJwConfig();
|
|
547
|
+
expect(jwConfig).to.be.undefined;
|
|
548
|
+
|
|
549
|
+
jwConfig = getJwConfig(null);
|
|
550
|
+
expect(jwConfig).to.be.undefined;
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
it('should set vendor config params to top level', function () {
|
|
554
|
+
let jwConfig = getJwConfig({
|
|
555
|
+
params: {
|
|
556
|
+
vendorConfig: {
|
|
557
|
+
'test': 'a',
|
|
558
|
+
'test_2': 'b'
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
expect(jwConfig.test).to.be.equal('a');
|
|
563
|
+
expect(jwConfig.test_2).to.be.equal('b');
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
it('should convert video module params', function () {
|
|
567
|
+
let jwConfig = getJwConfig({
|
|
568
|
+
mute: true,
|
|
569
|
+
autoStart: true,
|
|
570
|
+
licenseKey: 'key'
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
expect(jwConfig.mute).to.be.true;
|
|
574
|
+
expect(jwConfig.autostart).to.be.true;
|
|
575
|
+
expect(jwConfig.key).to.be.equal('key');
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
it('should apply video module params only when absent from vendor config', function () {
|
|
579
|
+
let jwConfig = getJwConfig({
|
|
580
|
+
mute: true,
|
|
581
|
+
autoStart: true,
|
|
582
|
+
licenseKey: 'key',
|
|
583
|
+
params: {
|
|
584
|
+
vendorConfig: {
|
|
585
|
+
mute: false,
|
|
586
|
+
autostart: false,
|
|
587
|
+
key: 'other_key'
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
expect(jwConfig.mute).to.be.false;
|
|
593
|
+
expect(jwConfig.autostart).to.be.false;
|
|
594
|
+
expect(jwConfig.key).to.be.equal('other_key');
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
it('should not convert undefined properties', function () {
|
|
598
|
+
let jwConfig = getJwConfig({
|
|
599
|
+
params: {
|
|
600
|
+
vendorConfig: {
|
|
601
|
+
test: 'a'
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
expect(jwConfig).to.not.have.property('mute');
|
|
607
|
+
expect(jwConfig).to.not.have.property('autostart');
|
|
608
|
+
expect(jwConfig).to.not.have.property('key');
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
it('should exclude fallback ad block when setupAds is explicitly disabled', function () {
|
|
612
|
+
let jwConfig = getJwConfig({
|
|
613
|
+
setupAds: false,
|
|
614
|
+
params: {
|
|
615
|
+
|
|
616
|
+
vendorConfig: {}
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
expect(jwConfig).to.not.have.property('advertising');
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
it('should set advertising block when setupAds is allowed', function () {
|
|
624
|
+
let jwConfig = getJwConfig({
|
|
625
|
+
params: {
|
|
626
|
+
vendorConfig: {
|
|
627
|
+
advertising: {
|
|
628
|
+
tag: 'test_tag'
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
expect(jwConfig).to.have.property('advertising');
|
|
635
|
+
expect(jwConfig.advertising).to.have.property('tag', 'test_tag');
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
it('should fallback to vast plugin', function () {
|
|
639
|
+
let jwConfig = getJwConfig({});
|
|
640
|
+
|
|
641
|
+
expect(jwConfig).to.have.property('advertising');
|
|
642
|
+
expect(jwConfig.advertising).to.have.property('client', 'vast');
|
|
643
|
+
});
|
|
644
|
+
});
|
|
645
|
+
describe('getSkipParams', function () {
|
|
646
|
+
const getSkipParams = utils.getSkipParams;
|
|
647
|
+
|
|
648
|
+
it('should return an empty object when skip is not configured', function () {
|
|
649
|
+
let skipParams = getSkipParams({});
|
|
650
|
+
expect(skipParams).to.be.empty;
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
it('should set skip to false when explicitly configured', function () {
|
|
654
|
+
let skipParams = getSkipParams({
|
|
655
|
+
skipoffset: -1
|
|
656
|
+
});
|
|
657
|
+
expect(skipParams.skip).to.be.equal(0);
|
|
658
|
+
expect(skipParams.skipmin).to.be.undefined;
|
|
659
|
+
expect(skipParams.skipafter).to.be.undefined;
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
it('should be skippable when skip offset is set', function () {
|
|
663
|
+
const skipOffset = 3;
|
|
664
|
+
let skipParams = getSkipParams({
|
|
665
|
+
skipoffset: skipOffset
|
|
666
|
+
});
|
|
667
|
+
expect(skipParams.skip).to.be.equal(1);
|
|
668
|
+
expect(skipParams.skipmin).to.be.equal(skipOffset + 2);
|
|
669
|
+
expect(skipParams.skipafter).to.be.equal(skipOffset);
|
|
670
|
+
});
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
describe('getSupportedMediaTypes', function () {
|
|
674
|
+
const getSupportedMediaTypes = utils.getSupportedMediaTypes;
|
|
675
|
+
|
|
676
|
+
it('should always support VPAID', function () {
|
|
677
|
+
let supportedMediaTypes = getSupportedMediaTypes([]);
|
|
678
|
+
expect(supportedMediaTypes).to.include(VPAID_MIME_TYPE);
|
|
679
|
+
|
|
680
|
+
supportedMediaTypes = getSupportedMediaTypes([VIDEO_MIME_TYPE.MP4]);
|
|
681
|
+
expect(supportedMediaTypes).to.include(VPAID_MIME_TYPE);
|
|
682
|
+
});
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
describe('getPlacement', function () {
|
|
686
|
+
const getPlacement = utils.getPlacement;
|
|
687
|
+
|
|
688
|
+
it('should be INSTREAM when not configured for outstream', function () {
|
|
689
|
+
let adConfig = {};
|
|
690
|
+
let placement = getPlacement(adConfig);
|
|
691
|
+
expect(placement).to.be.equal(PLACEMENT.INSTREAM);
|
|
692
|
+
|
|
693
|
+
adConfig = { outstream: false };
|
|
694
|
+
placement = getPlacement(adConfig);
|
|
695
|
+
expect(placement).to.be.equal(PLACEMENT.INSTREAM);
|
|
696
|
+
});
|
|
697
|
+
|
|
698
|
+
it('should be FLOATING when player is floating', function () {
|
|
699
|
+
const player = getPlayerMock();
|
|
700
|
+
player.getFloating = () => true;
|
|
701
|
+
const placement = getPlacement({outstream: true}, player);
|
|
702
|
+
expect(placement).to.be.equal(PLACEMENT.FLOATING);
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
it('should be the value defined in the ad config', function () {
|
|
706
|
+
const player = getPlayerMock();
|
|
707
|
+
player.getFloating = () => false;
|
|
708
|
+
|
|
709
|
+
let placement = getPlacement({placement: 'banner', outstream: true}, player);
|
|
710
|
+
expect(placement).to.be.equal(PLACEMENT.BANNER);
|
|
711
|
+
|
|
712
|
+
placement = getPlacement({placement: 'article', outstream: true}, player);
|
|
713
|
+
expect(placement).to.be.equal(PLACEMENT.ARTICLE);
|
|
714
|
+
|
|
715
|
+
placement = getPlacement({placement: 'feed', outstream: true}, player);
|
|
716
|
+
expect(placement).to.be.equal(PLACEMENT.FEED);
|
|
717
|
+
|
|
718
|
+
placement = getPlacement({placement: 'interstitial', outstream: true}, player);
|
|
719
|
+
expect(placement).to.be.equal(PLACEMENT.INTERSTITIAL);
|
|
720
|
+
|
|
721
|
+
placement = getPlacement({placement: 'slider', outstream: true}, player);
|
|
722
|
+
expect(placement).to.be.equal(PLACEMENT.SLIDER);
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
it('should be undefined when undetermined', function () {
|
|
726
|
+
const placement = getPlacement({ outstream: true }, getPlayerMock());
|
|
727
|
+
expect(placement).to.be.undefined;
|
|
728
|
+
});
|
|
729
|
+
});
|
|
730
|
+
|
|
731
|
+
describe('getPlaybackMethod', function() {
|
|
732
|
+
const getPlaybackMethod = utils.getPlaybackMethod;
|
|
733
|
+
|
|
734
|
+
it('should return autoplay with sound', function() {
|
|
735
|
+
const playbackMethod = getPlaybackMethod({
|
|
736
|
+
autoplay: true,
|
|
737
|
+
mute: false
|
|
738
|
+
});
|
|
739
|
+
expect(playbackMethod).to.equal(PLAYBACK_METHODS.AUTOPLAY);
|
|
740
|
+
});
|
|
741
|
+
|
|
742
|
+
it('should return autoplay muted', function() {
|
|
743
|
+
const playbackMethod = getPlaybackMethod({
|
|
744
|
+
autoplay: true,
|
|
745
|
+
mute: true
|
|
746
|
+
});
|
|
747
|
+
expect(playbackMethod).to.equal(PLAYBACK_METHODS.AUTOPLAY_MUTED);
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
it('should treat autoplayAdsMuted as mute', function () {
|
|
751
|
+
const playbackMethod = getPlaybackMethod({
|
|
752
|
+
autoplay: true,
|
|
753
|
+
autoplayAdsMuted: true
|
|
754
|
+
});
|
|
755
|
+
expect(playbackMethod).to.equal(PLAYBACK_METHODS.AUTOPLAY_MUTED);
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
it('should return click to play', function() {
|
|
759
|
+
let playbackMethod = getPlaybackMethod({ autoplay: false });
|
|
760
|
+
expect(playbackMethod).to.equal(PLAYBACK_METHODS.CLICK_TO_PLAY);
|
|
761
|
+
|
|
762
|
+
playbackMethod = getPlaybackMethod({
|
|
763
|
+
autoplay: false,
|
|
764
|
+
autoplayAdsMuted: true
|
|
765
|
+
});
|
|
766
|
+
expect(playbackMethod).to.equal(PLAYBACK_METHODS.CLICK_TO_PLAY);
|
|
767
|
+
|
|
768
|
+
playbackMethod = getPlaybackMethod({
|
|
769
|
+
autoplay: false,
|
|
770
|
+
mute: true
|
|
771
|
+
});
|
|
772
|
+
expect(playbackMethod).to.equal(PLAYBACK_METHODS.CLICK_TO_PLAY);
|
|
773
|
+
});
|
|
774
|
+
});
|
|
775
|
+
|
|
776
|
+
describe('isOmidSupported', function () {
|
|
777
|
+
const isOmidSupported = utils.isOmidSupported;
|
|
778
|
+
const initialOmidSessionClient = window.OmidSessionClient;
|
|
779
|
+
afterEach(() => {
|
|
780
|
+
window.OmidSessionClient = initialOmidSessionClient;
|
|
781
|
+
});
|
|
782
|
+
|
|
783
|
+
it('should be true when Omid is loaded and client is VAST', function () {
|
|
784
|
+
window.OmidSessionClient = {};
|
|
785
|
+
expect(isOmidSupported('vast')).to.be.true;
|
|
786
|
+
});
|
|
787
|
+
|
|
788
|
+
it('should be false when Omid is not present', function () {
|
|
789
|
+
expect(isOmidSupported('vast')).to.be.false;
|
|
790
|
+
});
|
|
791
|
+
|
|
792
|
+
it('should be false when client is not Vast', function () {
|
|
793
|
+
window.OmidSessionClient = {};
|
|
794
|
+
expect(isOmidSupported('googima')).to.be.false;
|
|
795
|
+
expect(isOmidSupported('freewheel')).to.be.false;
|
|
796
|
+
expect(isOmidSupported('googimadai')).to.be.false;
|
|
797
|
+
expect(isOmidSupported('')).to.be.false;
|
|
798
|
+
expect(isOmidSupported(null)).to.be.false;
|
|
799
|
+
expect(isOmidSupported()).to.be.false;
|
|
800
|
+
});
|
|
801
|
+
});
|
|
802
|
+
|
|
803
|
+
describe('getIsoLanguageCode', function () {
|
|
804
|
+
const sampleAudioTracks = [{language: 'ht'}, {language: 'fr'}, {language: 'es'}, {language: 'pt'}];
|
|
805
|
+
|
|
806
|
+
it('should return undefined when audio tracks are unavailable', function () {
|
|
807
|
+
const player = getPlayerMock();
|
|
808
|
+
let languageCode = utils.getIsoLanguageCode(player);
|
|
809
|
+
expect(languageCode).to.be.undefined;
|
|
810
|
+
player.getAudioTracks = () => [];
|
|
811
|
+
languageCode = utils.getIsoLanguageCode(player);
|
|
812
|
+
expect(languageCode).to.be.undefined;
|
|
813
|
+
});
|
|
814
|
+
|
|
815
|
+
it('should return the first audio track language code if the getCurrentAudioTrack returns undefined', function () {
|
|
816
|
+
const player = getPlayerMock();
|
|
817
|
+
player.getAudioTracks = () => sampleAudioTracks;
|
|
818
|
+
let languageCode = utils.getIsoLanguageCode(player);
|
|
819
|
+
expect(languageCode).to.be.equal('ht');
|
|
820
|
+
});
|
|
821
|
+
|
|
822
|
+
it('should return the first audio track language code if the getCurrentAudioTrack returns null', function () {
|
|
823
|
+
const player = getPlayerMock();
|
|
824
|
+
player.getAudioTracks = () => sampleAudioTracks;
|
|
825
|
+
player.getCurrentAudioTrack = () => null;
|
|
826
|
+
let languageCode = utils.getIsoLanguageCode(player);
|
|
827
|
+
expect(languageCode).to.be.equal('ht');
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
it('should return the first audio track language code if the getCurrentAudioTrack returns -1', function () {
|
|
831
|
+
const player = getPlayerMock();
|
|
832
|
+
player.getAudioTracks = () => sampleAudioTracks;
|
|
833
|
+
player.getCurrentAudioTrack = () => -1;
|
|
834
|
+
const languageCode = utils.getIsoLanguageCode(player);
|
|
835
|
+
expect(languageCode).to.be.equal('ht');
|
|
836
|
+
});
|
|
837
|
+
|
|
838
|
+
it('should return the right audio track language code', function () {
|
|
839
|
+
const player = getPlayerMock();
|
|
840
|
+
player.getAudioTracks = () => sampleAudioTracks;
|
|
841
|
+
player.getCurrentAudioTrack = () => 2;
|
|
842
|
+
const languageCode = utils.getIsoLanguageCode(player);
|
|
843
|
+
expect(languageCode).to.be.equal('es');
|
|
844
|
+
});
|
|
845
|
+
});
|
|
846
|
+
});
|