prebid.js 6.7.0 → 6.11.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/.eslintrc.js +8 -1
- package/integrationExamples/gpt/{haloRtdProvider_example.html → hadronRtdProvider_example.html} +9 -9
- package/integrationExamples/gpt/idImportLibrary_example.html +2 -2
- package/integrationExamples/gpt/userId_example.html +2 -2
- package/integrationExamples/gpt/weboramaRtdProvider_example.html +154 -115
- package/integrationExamples/gpt/x-domain/creative.html +63 -29
- package/modules/.submodules.json +3 -0
- package/modules/adagioBidAdapter.js +0 -8
- package/modules/adagioBidAdapter.md +1 -1
- package/modules/adkernelBidAdapter.js +2 -1
- package/modules/adnuntiusRtdProvider.js +96 -0
- package/modules/adnuntiusRtdProvider.md +41 -0
- package/modules/adotBidAdapter.js +516 -567
- package/modules/adotBidAdapter.md +6 -44
- package/modules/adpod.js +12 -14
- package/modules/adyoulikeBidAdapter.js +2 -0
- package/modules/appnexusBidAdapter.js +14 -2
- package/modules/asealBidAdapter.js +58 -0
- package/modules/asealBidAdapter.md +52 -0
- package/modules/brandmetricsRtdProvider.js +168 -0
- package/modules/brandmetricsRtdProvider.md +40 -0
- package/modules/conversantBidAdapter.js +7 -0
- package/modules/criteoBidAdapter.js +9 -0
- package/modules/currency.js +27 -5
- package/modules/displayioBidAdapter.js +157 -0
- package/modules/displayioBidAdapter.md +148 -0
- package/modules/dspxBidAdapter.js +69 -29
- package/modules/dspxBidAdapter.md +2 -1
- package/modules/e_volutionBidAdapter.js +158 -0
- package/modules/gridBidAdapter.js +15 -1
- package/modules/gumgumBidAdapter.js +52 -38
- package/modules/hadronIdSystem.js +96 -0
- package/modules/hadronIdSystem.md +35 -0
- package/modules/hadronRtdProvider.js +254 -0
- package/modules/hadronRtdProvider.md +126 -0
- package/modules/haloIdSystem.md +4 -35
- package/modules/haloRtdProvider.md +3 -126
- package/modules/imRtdProvider.js +10 -0
- package/modules/improvedigitalBidAdapter.js +5 -0
- package/modules/interactiveOffersBidAdapter.js +9 -6
- package/modules/iqzoneBidAdapter.js +10 -3
- package/modules/iqzoneBidAdapter.md +16 -0
- package/modules/ixBidAdapter.js +2 -6
- package/modules/kubientBidAdapter.js +50 -19
- package/modules/lunamediahbBidAdapter.js +32 -4
- package/modules/malltvBidAdapter.js +7 -3
- package/modules/malltvBidAdapter.md +64 -51
- package/modules/mass.js +3 -5
- package/modules/mediakeysBidAdapter.js +0 -5
- package/modules/medianetAnalyticsAdapter.js +1 -1
- package/modules/mediasquareBidAdapter.js +9 -1
- package/modules/nextMillenniumBidAdapter.js +1 -0
- package/modules/oguryBidAdapter.js +7 -14
- package/modules/prebidServerBidAdapter/index.js +61 -39
- package/modules/priceFloors.js +20 -12
- package/modules/pubmaticBidAdapter.js +1 -1
- package/modules/richaudienceBidAdapter.js +8 -3
- package/modules/riseBidAdapter.js +17 -6
- package/modules/rtbhouseBidAdapter.js +2 -0
- package/modules/rubiconAnalyticsAdapter.js +5 -0
- package/modules/rubiconBidAdapter.js +2 -2
- package/modules/sizeMappingV2.js +1 -8
- package/modules/sortableAnalyticsAdapter.js +5 -4
- package/modules/sovrnBidAdapter.js +93 -18
- package/modules/sovrnBidAdapter.md +80 -2
- package/modules/sspBCBidAdapter.js +53 -20
- package/modules/telariaBidAdapter.js +22 -29
- package/modules/trustpidSystem.js +197 -0
- package/modules/trustpidSystem.md +45 -0
- package/modules/undertoneBidAdapter.js +17 -1
- package/modules/userId/eids.js +16 -1
- package/modules/userId/eids.md +10 -2
- package/modules/userId/userId.md +17 -2
- package/modules/vibrantmediaBidAdapter.js +220 -0
- package/modules/vibrantmediaBidAdapter.md +92 -0
- package/modules/vidoomyBidAdapter.js +8 -0
- package/modules/vidoomyBidAdapter.md +4 -2
- package/modules/weboramaRtdProvider.js +264 -34
- package/modules/weboramaRtdProvider.md +110 -40
- package/modules/yahoosspBidAdapter.js +3 -1
- package/modules/yieldoneBidAdapter.js +6 -0
- package/package.json +2 -1
- package/src/adRendering.js +38 -0
- package/src/adapterManager.js +24 -19
- package/src/adapters/bidderFactory.js +14 -11
- package/src/adloader.js +2 -1
- package/src/auction.js +138 -115
- package/src/auctionIndex.js +85 -0
- package/src/auctionManager.js +3 -0
- package/src/bidderSettings.js +69 -0
- package/src/bidfactory.js +18 -6
- package/src/native.js +29 -21
- package/src/prebid.js +3 -19
- package/src/secureCreatives.js +128 -45
- package/src/targeting.js +11 -2
- package/src/utils.js +14 -17
- package/src/video.js +10 -11
- package/src/videoCache.js +10 -9
- package/test/fixtures/fixtures.js +2 -1
- package/test/helpers/indexStub.js +28 -0
- package/test/helpers/syncPromise.js +71 -0
- package/test/spec/auctionmanager_spec.js +268 -89
- package/test/spec/config_spec.js +24 -1
- package/test/spec/modules/adagioBidAdapter_spec.js +0 -10
- package/test/spec/modules/adnuntiusRtdProvider_spec.js +145 -0
- package/test/spec/modules/adotBidAdapter_spec.js +294 -3124
- package/test/spec/modules/adpod_spec.js +91 -156
- package/test/spec/modules/adyoulikeBidAdapter_spec.js +4 -0
- package/test/spec/modules/appnexusBidAdapter_spec.js +27 -0
- package/test/spec/modules/asealBidAdapter_spec.js +144 -0
- package/test/spec/modules/brandmetricsRtdProvider_spec.js +191 -0
- package/test/spec/modules/conversantBidAdapter_spec.js +54 -2
- package/test/spec/modules/criteoBidAdapter_spec.js +21 -0
- package/test/spec/modules/currency_spec.js +36 -15
- package/test/spec/modules/displayioBidAdapter_spec.js +239 -0
- package/test/spec/modules/dspxBidAdapter_spec.js +20 -15
- package/test/spec/modules/e_volutionBidAdapter_spec.js +242 -0
- package/test/spec/modules/eids_spec.js +2 -2
- package/test/spec/modules/gridBidAdapter_spec.js +18 -0
- package/test/spec/modules/gumgumBidAdapter_spec.js +49 -3
- package/test/spec/modules/hadronIdSystem_spec.js +57 -0
- package/test/spec/modules/hadronRtdProvider_spec.js +762 -0
- package/test/spec/modules/imRtdProvider_spec.js +30 -1
- package/test/spec/modules/improvedigitalBidAdapter_spec.js +19 -0
- package/test/spec/modules/iqzoneBidAdapter_spec.js +1 -0
- package/test/spec/modules/ixBidAdapter_spec.js +1 -1
- package/test/spec/modules/kubientBidAdapter_spec.js +182 -84
- package/test/spec/modules/lunamediahbBidAdapter_spec.js +27 -1
- package/test/spec/modules/mass_spec.js +2 -14
- package/test/spec/modules/mediakeysBidAdapter_spec.js +9 -5
- package/test/spec/modules/mediasquareBidAdapter_spec.js +25 -1
- package/test/spec/modules/oguryBidAdapter_spec.js +63 -5
- package/test/spec/modules/prebidServerBidAdapter_spec.js +43 -6
- package/test/spec/modules/priceFloors_spec.js +83 -24
- package/test/spec/modules/pubmaticBidAdapter_spec.js +40 -0
- package/test/spec/modules/riseBidAdapter_spec.js +30 -4
- package/test/spec/modules/rubiconAnalyticsAdapter_spec.js +31 -1
- package/test/spec/modules/rubiconBidAdapter_spec.js +1 -1
- package/test/spec/modules/sortableAnalyticsAdapter_spec.js +2 -3
- package/test/spec/modules/sovrnBidAdapter_spec.js +413 -333
- package/test/spec/modules/sspBCBidAdapter_spec.js +7 -7
- package/test/spec/modules/telariaBidAdapter_spec.js +1 -3
- package/test/spec/modules/trustpidSystem_spec.js +232 -0
- package/test/spec/modules/undertoneBidAdapter_spec.js +55 -2
- package/test/spec/modules/userId_spec.js +39 -39
- package/test/spec/modules/vibrantmediaBidAdapter_spec.js +1237 -0
- package/test/spec/modules/vidoomyBidAdapter_spec.js +7 -1
- package/test/spec/modules/weboramaRtdProvider_spec.js +536 -20
- package/test/spec/modules/yahoosspBidAdapter_spec.js +10 -0
- package/test/spec/modules/yieldoneBidAdapter_spec.js +33 -0
- package/test/spec/native_spec.js +62 -40
- package/test/spec/unit/core/adapterManager_spec.js +22 -0
- package/test/spec/unit/core/auctionIndex_spec.js +129 -0
- package/test/spec/unit/core/bidderFactory_spec.js +65 -12
- package/test/spec/unit/core/bidderSettings_spec.js +123 -0
- package/test/spec/unit/core/targeting_spec.js +93 -0
- package/test/spec/unit/pbjs_api_spec.js +80 -42
- package/test/spec/unit/secureCreatives_spec.js +143 -24
- package/test/spec/videoCache_spec.js +18 -19
- package/test/spec/video_spec.js +51 -61
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {bidderSettings, ScopedSettings} from '../../../../src/bidderSettings.js';
|
|
2
|
+
import {expect} from 'chai';
|
|
3
|
+
import * as prebidGlobal from '../../../../src/prebidGlobal';
|
|
4
|
+
import sinon from 'sinon';
|
|
5
|
+
|
|
6
|
+
describe('ScopedSettings', () => {
|
|
7
|
+
let data;
|
|
8
|
+
let settings;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
settings = new ScopedSettings(() => data, 'fallback');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe('get', () => {
|
|
15
|
+
it('should retrieve setting from scope', () => {
|
|
16
|
+
data = {
|
|
17
|
+
scope: {key: 'value'}
|
|
18
|
+
};
|
|
19
|
+
expect(settings.get('scope', 'key')).to.equal('value');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should fallback to fallback scope', () => {
|
|
23
|
+
data = {
|
|
24
|
+
fallback: {
|
|
25
|
+
key: 'value'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
expect(settings.get('scope', 'key')).to.equal('value');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should retrieve from default scope if scope is null', () => {
|
|
32
|
+
data = {
|
|
33
|
+
fallback: {
|
|
34
|
+
key: 'value'
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
expect(settings.get(null, 'key')).to.equal('value');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should not fall back if own setting has a falsy value', () => {
|
|
42
|
+
data = {
|
|
43
|
+
scope: {
|
|
44
|
+
key: false,
|
|
45
|
+
},
|
|
46
|
+
fallback: {
|
|
47
|
+
key: true
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
expect(settings.get('scope', 'key')).to.equal(false);
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('getOwn', () => {
|
|
55
|
+
it('should not fall back to default scope', () => {
|
|
56
|
+
data = {
|
|
57
|
+
fallback: {
|
|
58
|
+
key: 'value'
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
expect(settings.getOwn('missing', 'key')).to.be.undefined;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should use default if scope is null', () => {
|
|
65
|
+
data = {
|
|
66
|
+
fallback: {
|
|
67
|
+
key: 'value'
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
expect(settings.getOwn(null, 'key')).to.equal('value');
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe('getScopes', () => {
|
|
75
|
+
it('should return all top-level keys except the default scope', () => {
|
|
76
|
+
data = {
|
|
77
|
+
fallback: {},
|
|
78
|
+
scope1: {},
|
|
79
|
+
scope2: {},
|
|
80
|
+
};
|
|
81
|
+
expect(settings.getScopes()).to.have.members(['scope1', 'scope2']);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe('settingsFor', () => {
|
|
86
|
+
it('should merge with default scope', () => {
|
|
87
|
+
data = {
|
|
88
|
+
fallback: {
|
|
89
|
+
dkey: 'value'
|
|
90
|
+
},
|
|
91
|
+
scope: {
|
|
92
|
+
skey: 'value'
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
expect(settings.settingsFor('scope')).to.eql({
|
|
96
|
+
dkey: 'value',
|
|
97
|
+
skey: 'value'
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe('bidderSettings', () => {
|
|
104
|
+
let sandbox;
|
|
105
|
+
beforeEach(() => {
|
|
106
|
+
sandbox = sinon.sandbox.create();
|
|
107
|
+
sandbox.stub(prebidGlobal, 'getGlobal').returns({
|
|
108
|
+
bidderSettings: {
|
|
109
|
+
scope: {
|
|
110
|
+
key: 'value'
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
afterEach(() => {
|
|
117
|
+
sandbox.restore();
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('should fetch data from getGlobal().bidderSettings', () => {
|
|
121
|
+
expect(bidderSettings.get('scope', 'key')).to.equal('value');
|
|
122
|
+
})
|
|
123
|
+
});
|
|
@@ -228,6 +228,8 @@ describe('targeting tests', function () {
|
|
|
228
228
|
let sandbox;
|
|
229
229
|
let enableSendAllBids = false;
|
|
230
230
|
let useBidCache;
|
|
231
|
+
let bidCacheFilterFunction;
|
|
232
|
+
let undef;
|
|
231
233
|
|
|
232
234
|
beforeEach(function() {
|
|
233
235
|
sandbox = sinon.sandbox.create();
|
|
@@ -242,12 +244,16 @@ describe('targeting tests', function () {
|
|
|
242
244
|
if (key === 'useBidCache') {
|
|
243
245
|
return useBidCache;
|
|
244
246
|
}
|
|
247
|
+
if (key === 'bidCacheFilterFunction') {
|
|
248
|
+
return bidCacheFilterFunction;
|
|
249
|
+
}
|
|
245
250
|
return origGetConfig.apply(config, arguments);
|
|
246
251
|
});
|
|
247
252
|
});
|
|
248
253
|
|
|
249
254
|
afterEach(function () {
|
|
250
255
|
sandbox.restore();
|
|
256
|
+
bidCacheFilterFunction = undef;
|
|
251
257
|
});
|
|
252
258
|
|
|
253
259
|
describe('getAllTargeting', function () {
|
|
@@ -901,6 +907,93 @@ describe('targeting tests', function () {
|
|
|
901
907
|
expect(bids[0].adId).to.equal('adid-2');
|
|
902
908
|
});
|
|
903
909
|
|
|
910
|
+
it('should use bidCacheFilterFunction', function() {
|
|
911
|
+
auctionManagerStub.returns([
|
|
912
|
+
createBidReceived({bidder: 'appnexus', cpm: 7, auctionId: 1, responseTimestamp: 100, adUnitCode: 'code-0', adId: 'adid-1', mediaType: 'banner'}),
|
|
913
|
+
createBidReceived({bidder: 'appnexus', cpm: 5, auctionId: 2, responseTimestamp: 102, adUnitCode: 'code-0', adId: 'adid-2', mediaType: 'banner'}),
|
|
914
|
+
createBidReceived({bidder: 'appnexus', cpm: 6, auctionId: 1, responseTimestamp: 101, adUnitCode: 'code-1', adId: 'adid-3', mediaType: 'banner'}),
|
|
915
|
+
createBidReceived({bidder: 'appnexus', cpm: 8, auctionId: 2, responseTimestamp: 103, adUnitCode: 'code-1', adId: 'adid-4', mediaType: 'banner'}),
|
|
916
|
+
createBidReceived({bidder: 'appnexus', cpm: 27, auctionId: 1, responseTimestamp: 100, adUnitCode: 'code-2', adId: 'adid-5', mediaType: 'video'}),
|
|
917
|
+
createBidReceived({bidder: 'appnexus', cpm: 25, auctionId: 2, responseTimestamp: 102, adUnitCode: 'code-2', adId: 'adid-6', mediaType: 'video'}),
|
|
918
|
+
createBidReceived({bidder: 'appnexus', cpm: 26, auctionId: 1, responseTimestamp: 101, adUnitCode: 'code-3', adId: 'adid-7', mediaType: 'video'}),
|
|
919
|
+
createBidReceived({bidder: 'appnexus', cpm: 28, auctionId: 2, responseTimestamp: 103, adUnitCode: 'code-3', adId: 'adid-8', mediaType: 'video'}),
|
|
920
|
+
]);
|
|
921
|
+
|
|
922
|
+
let adUnitCodes = ['code-0', 'code-1', 'code-2', 'code-3'];
|
|
923
|
+
targetingInstance.setLatestAuctionForAdUnit('code-0', 2);
|
|
924
|
+
targetingInstance.setLatestAuctionForAdUnit('code-1', 2);
|
|
925
|
+
targetingInstance.setLatestAuctionForAdUnit('code-2', 2);
|
|
926
|
+
targetingInstance.setLatestAuctionForAdUnit('code-3', 2);
|
|
927
|
+
|
|
928
|
+
// Bid Caching On, No Filter Function
|
|
929
|
+
useBidCache = true;
|
|
930
|
+
bidCacheFilterFunction = undef;
|
|
931
|
+
let bids = targetingInstance.getWinningBids(adUnitCodes);
|
|
932
|
+
|
|
933
|
+
expect(bids.length).to.equal(4);
|
|
934
|
+
expect(bids[0].adId).to.equal('adid-1');
|
|
935
|
+
expect(bids[1].adId).to.equal('adid-4');
|
|
936
|
+
expect(bids[2].adId).to.equal('adid-5');
|
|
937
|
+
expect(bids[3].adId).to.equal('adid-8');
|
|
938
|
+
|
|
939
|
+
// Bid Caching Off, No Filter Function
|
|
940
|
+
useBidCache = false;
|
|
941
|
+
bidCacheFilterFunction = undef;
|
|
942
|
+
bids = targetingInstance.getWinningBids(adUnitCodes);
|
|
943
|
+
|
|
944
|
+
expect(bids.length).to.equal(4);
|
|
945
|
+
expect(bids[0].adId).to.equal('adid-2');
|
|
946
|
+
expect(bids[1].adId).to.equal('adid-4');
|
|
947
|
+
expect(bids[2].adId).to.equal('adid-6');
|
|
948
|
+
expect(bids[3].adId).to.equal('adid-8');
|
|
949
|
+
|
|
950
|
+
// Bid Caching On AGAIN, No Filter Function (should be same as first time)
|
|
951
|
+
useBidCache = true;
|
|
952
|
+
bidCacheFilterFunction = undef;
|
|
953
|
+
bids = targetingInstance.getWinningBids(adUnitCodes);
|
|
954
|
+
|
|
955
|
+
expect(bids.length).to.equal(4);
|
|
956
|
+
expect(bids[0].adId).to.equal('adid-1');
|
|
957
|
+
expect(bids[1].adId).to.equal('adid-4');
|
|
958
|
+
expect(bids[2].adId).to.equal('adid-5');
|
|
959
|
+
expect(bids[3].adId).to.equal('adid-8');
|
|
960
|
+
|
|
961
|
+
// Bid Caching On, with Filter Function to Exclude video
|
|
962
|
+
useBidCache = true;
|
|
963
|
+
let bcffCalled = 0;
|
|
964
|
+
bidCacheFilterFunction = bid => {
|
|
965
|
+
bcffCalled++;
|
|
966
|
+
return bid.mediaType !== 'video';
|
|
967
|
+
}
|
|
968
|
+
bids = targetingInstance.getWinningBids(adUnitCodes);
|
|
969
|
+
|
|
970
|
+
expect(bids.length).to.equal(4);
|
|
971
|
+
expect(bids[0].adId).to.equal('adid-1');
|
|
972
|
+
expect(bids[1].adId).to.equal('adid-4');
|
|
973
|
+
expect(bids[2].adId).to.equal('adid-6');
|
|
974
|
+
expect(bids[3].adId).to.equal('adid-8');
|
|
975
|
+
// filter function should have been called for each cached bid (4 times)
|
|
976
|
+
expect(bcffCalled).to.equal(4);
|
|
977
|
+
|
|
978
|
+
// Bid Caching Off, with Filter Function to Exclude video
|
|
979
|
+
// - should not use cached bids or call the filter function
|
|
980
|
+
useBidCache = false;
|
|
981
|
+
bcffCalled = 0;
|
|
982
|
+
bidCacheFilterFunction = bid => {
|
|
983
|
+
bcffCalled++;
|
|
984
|
+
return bid.mediaType !== 'video';
|
|
985
|
+
}
|
|
986
|
+
bids = targetingInstance.getWinningBids(adUnitCodes);
|
|
987
|
+
|
|
988
|
+
expect(bids.length).to.equal(4);
|
|
989
|
+
expect(bids[0].adId).to.equal('adid-2');
|
|
990
|
+
expect(bids[1].adId).to.equal('adid-4');
|
|
991
|
+
expect(bids[2].adId).to.equal('adid-6');
|
|
992
|
+
expect(bids[3].adId).to.equal('adid-8');
|
|
993
|
+
// filter function should not have been called
|
|
994
|
+
expect(bcffCalled).to.equal(0);
|
|
995
|
+
});
|
|
996
|
+
|
|
904
997
|
it('should not use rendered bid to get winning bid', function () {
|
|
905
998
|
let bidsReceived = [
|
|
906
999
|
createBidReceived({bidder: 'appnexus', cpm: 8, auctionId: 1, responseTimestamp: 100, adUnitCode: 'code-0', adId: 'adid-1', status: 'rendered'}),
|
|
@@ -16,6 +16,9 @@ import * as auctionModule from 'src/auction.js';
|
|
|
16
16
|
import { registerBidder } from 'src/adapters/bidderFactory.js';
|
|
17
17
|
import { _sendAdToCreative } from 'src/secureCreatives.js';
|
|
18
18
|
import find from 'core-js-pure/features/array/find.js';
|
|
19
|
+
import {synchronizePromise} from '../../helpers/syncPromise.js';
|
|
20
|
+
import 'src/prebid.js';
|
|
21
|
+
import {hook} from '../../../src/hook.js';
|
|
19
22
|
|
|
20
23
|
var assert = require('chai').assert;
|
|
21
24
|
var expect = require('chai').expect;
|
|
@@ -190,13 +193,21 @@ window.apntag = {
|
|
|
190
193
|
}
|
|
191
194
|
|
|
192
195
|
describe('Unit: Prebid Module', function () {
|
|
193
|
-
let bidExpiryStub;
|
|
196
|
+
let bidExpiryStub, promiseSandbox;
|
|
197
|
+
|
|
198
|
+
before(() => {
|
|
199
|
+
hook.ready();
|
|
200
|
+
});
|
|
201
|
+
|
|
194
202
|
beforeEach(function () {
|
|
203
|
+
promiseSandbox = sinon.createSandbox();
|
|
204
|
+
synchronizePromise(promiseSandbox);
|
|
195
205
|
bidExpiryStub = sinon.stub(filters, 'isBidNotExpired').callsFake(() => true);
|
|
196
206
|
configObj.setConfig({ useBidCache: true });
|
|
197
207
|
});
|
|
198
208
|
|
|
199
209
|
afterEach(function() {
|
|
210
|
+
promiseSandbox.restore();
|
|
200
211
|
$$PREBID_GLOBAL$$.adUnits = [];
|
|
201
212
|
bidExpiryStub.restore();
|
|
202
213
|
configObj.setConfig({ useBidCache: false });
|
|
@@ -422,6 +433,7 @@ describe('Unit: Prebid Module', function () {
|
|
|
422
433
|
let bid;
|
|
423
434
|
let auction;
|
|
424
435
|
let ajaxStub;
|
|
436
|
+
let indexStub;
|
|
425
437
|
let cbTimeout = 3000;
|
|
426
438
|
let targeting;
|
|
427
439
|
|
|
@@ -487,7 +499,8 @@ describe('Unit: Prebid Module', function () {
|
|
|
487
499
|
],
|
|
488
500
|
'bidId': '4d0a6829338a07',
|
|
489
501
|
'bidderRequestId': '331f3cf3f1d9c8',
|
|
490
|
-
'auctionId': '20882439e3238c'
|
|
502
|
+
'auctionId': '20882439e3238c',
|
|
503
|
+
'transactionId': 'trdiv-gpt-ad-1460505748561-0',
|
|
491
504
|
}
|
|
492
505
|
],
|
|
493
506
|
'auctionStart': 1505250713622,
|
|
@@ -505,6 +518,7 @@ describe('Unit: Prebid Module', function () {
|
|
|
505
518
|
let auctionManagerInstance = newAuctionManager();
|
|
506
519
|
targeting = newTargeting(auctionManagerInstance);
|
|
507
520
|
let adUnits = [{
|
|
521
|
+
transactionId: 'trdiv-gpt-ad-1460505748561-0',
|
|
508
522
|
code: 'div-gpt-ad-1460505748561-0',
|
|
509
523
|
sizes: [[300, 250], [300, 600]],
|
|
510
524
|
bids: [{
|
|
@@ -516,6 +530,8 @@ describe('Unit: Prebid Module', function () {
|
|
|
516
530
|
}];
|
|
517
531
|
let adUnitCodes = ['div-gpt-ad-1460505748561-0'];
|
|
518
532
|
auction = auctionManagerInstance.createAuction({adUnits, adUnitCodes});
|
|
533
|
+
indexStub = sinon.stub(auctionManager, 'index');
|
|
534
|
+
indexStub.get(() => auctionManagerInstance.index);
|
|
519
535
|
ajaxStub = sinon.stub(ajaxLib, 'ajaxBuilder').callsFake(function() {
|
|
520
536
|
return function(url, callback) {
|
|
521
537
|
const fakeResponse = sinon.stub();
|
|
@@ -527,6 +543,7 @@ describe('Unit: Prebid Module', function () {
|
|
|
527
543
|
|
|
528
544
|
afterEach(function () {
|
|
529
545
|
ajaxStub.restore();
|
|
546
|
+
indexStub.restore();
|
|
530
547
|
});
|
|
531
548
|
|
|
532
549
|
it('should get correct ' + CONSTANTS.TARGETING_KEYS.PRICE_BUCKET + ' when using bid.cpm is between 0 to 5', function() {
|
|
@@ -566,6 +583,7 @@ describe('Unit: Prebid Module', function () {
|
|
|
566
583
|
let cbTimeout = 3000;
|
|
567
584
|
let auctionManagerInstance;
|
|
568
585
|
let targeting;
|
|
586
|
+
let indexStub;
|
|
569
587
|
|
|
570
588
|
const bannerResponse = {
|
|
571
589
|
'version': '0.0.1',
|
|
@@ -644,6 +662,7 @@ describe('Unit: Prebid Module', function () {
|
|
|
644
662
|
}
|
|
645
663
|
|
|
646
664
|
const adUnit = {
|
|
665
|
+
transactionId: `tr${code}`,
|
|
647
666
|
code: code,
|
|
648
667
|
sizes: [[300, 250], [300, 600]],
|
|
649
668
|
bids: [{
|
|
@@ -656,22 +675,22 @@ describe('Unit: Prebid Module', function () {
|
|
|
656
675
|
|
|
657
676
|
let _mediaTypes = {};
|
|
658
677
|
if (mediaTypes.indexOf('banner') !== -1) {
|
|
659
|
-
_mediaTypes
|
|
678
|
+
Object.assign(_mediaTypes, {
|
|
660
679
|
'banner': {}
|
|
661
|
-
};
|
|
680
|
+
});
|
|
662
681
|
}
|
|
663
682
|
if (mediaTypes.indexOf('video') !== -1) {
|
|
664
|
-
_mediaTypes
|
|
683
|
+
Object.assign(_mediaTypes, {
|
|
665
684
|
'video': {
|
|
666
685
|
context: 'instream',
|
|
667
686
|
playerSize: [300, 250]
|
|
668
687
|
}
|
|
669
|
-
};
|
|
688
|
+
});
|
|
670
689
|
}
|
|
671
690
|
if (mediaTypes.indexOf('native') !== -1) {
|
|
672
|
-
_mediaTypes
|
|
691
|
+
Object.assign(_mediaTypes, {
|
|
673
692
|
'native': {}
|
|
674
|
-
};
|
|
693
|
+
});
|
|
675
694
|
}
|
|
676
695
|
|
|
677
696
|
if (Object.keys(_mediaTypes).length > 0) {
|
|
@@ -733,35 +752,41 @@ describe('Unit: Prebid Module', function () {
|
|
|
733
752
|
|
|
734
753
|
before(function () {
|
|
735
754
|
currentPriceBucket = configObj.getConfig('priceGranularity');
|
|
736
|
-
sinon.stub(adapterManager, 'makeBidRequests').callsFake(() =>
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
'
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
755
|
+
sinon.stub(adapterManager, 'makeBidRequests').callsFake(() => {
|
|
756
|
+
const br = {
|
|
757
|
+
'bidderCode': 'appnexus',
|
|
758
|
+
'auctionId': '20882439e3238c',
|
|
759
|
+
'bidderRequestId': '331f3cf3f1d9c8',
|
|
760
|
+
'bids': [
|
|
761
|
+
{
|
|
762
|
+
'bidder': 'appnexus',
|
|
763
|
+
'params': {
|
|
764
|
+
'placementId': '10433394'
|
|
765
|
+
},
|
|
766
|
+
'adUnitCode': 'div-gpt-ad-1460505748561-0',
|
|
767
|
+
'transactionId': 'trdiv-gpt-ad-1460505748561-0',
|
|
768
|
+
'sizes': [
|
|
769
|
+
[
|
|
770
|
+
300,
|
|
771
|
+
250
|
|
772
|
+
],
|
|
773
|
+
[
|
|
774
|
+
300,
|
|
775
|
+
600
|
|
776
|
+
]
|
|
751
777
|
],
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
],
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
}]));
|
|
778
|
+
'bidId': '4d0a6829338a07',
|
|
779
|
+
'bidderRequestId': '331f3cf3f1d9c8',
|
|
780
|
+
'auctionId': '20882439e3238c'
|
|
781
|
+
}
|
|
782
|
+
],
|
|
783
|
+
'auctionStart': 1505250713622,
|
|
784
|
+
'timeout': 3000
|
|
785
|
+
};
|
|
786
|
+
const au = auction.getAdUnits().find((au) => au.transactionId === br.bids[0].transactionId);
|
|
787
|
+
br.bids[0].mediaTypes = Object.assign({}, au.mediaTypes);
|
|
788
|
+
return [br];
|
|
789
|
+
});
|
|
765
790
|
});
|
|
766
791
|
|
|
767
792
|
after(function () {
|
|
@@ -769,8 +794,14 @@ describe('Unit: Prebid Module', function () {
|
|
|
769
794
|
adapterManager.makeBidRequests.restore();
|
|
770
795
|
})
|
|
771
796
|
|
|
797
|
+
beforeEach(() => {
|
|
798
|
+
indexStub = sinon.stub(auctionManager, 'index');
|
|
799
|
+
indexStub.get(() => auctionManagerInstance.index);
|
|
800
|
+
});
|
|
801
|
+
|
|
772
802
|
afterEach(function () {
|
|
773
803
|
ajaxStub.restore();
|
|
804
|
+
indexStub.restore();
|
|
774
805
|
});
|
|
775
806
|
|
|
776
807
|
it('should get correct ' + CONSTANTS.TARGETING_KEYS.PRICE_BUCKET + ' with cpm between 0 - 5', function() {
|
|
@@ -1002,12 +1033,7 @@ describe('Unit: Prebid Module', function () {
|
|
|
1002
1033
|
adUnitCode: config.adUnitCodes[0],
|
|
1003
1034
|
};
|
|
1004
1035
|
|
|
1005
|
-
|
|
1006
|
-
source: { postMessage: sinon.stub() },
|
|
1007
|
-
origin: 'origin.sf.com'
|
|
1008
|
-
};
|
|
1009
|
-
|
|
1010
|
-
_sendAdToCreative(mockAdObject, event);
|
|
1036
|
+
_sendAdToCreative(mockAdObject, sinon.stub());
|
|
1011
1037
|
|
|
1012
1038
|
expect(slots[0].spyGetSlotElementId.called).to.equal(false);
|
|
1013
1039
|
expect(slots[1].spyGetSlotElementId.called).to.equal(true);
|
|
@@ -1854,11 +1880,23 @@ describe('Unit: Prebid Module', function () {
|
|
|
1854
1880
|
pos: 2
|
|
1855
1881
|
}
|
|
1856
1882
|
}
|
|
1883
|
+
},
|
|
1884
|
+
{
|
|
1885
|
+
code: 'test6',
|
|
1886
|
+
bids: [],
|
|
1887
|
+
sizes: [300, 250],
|
|
1888
|
+
mediaTypes: {
|
|
1889
|
+
banner: {
|
|
1890
|
+
sizes: [300, 250],
|
|
1891
|
+
pos: 0
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1857
1894
|
}];
|
|
1858
1895
|
$$PREBID_GLOBAL$$.requestBids({
|
|
1859
1896
|
adUnits: adUnit
|
|
1860
1897
|
});
|
|
1861
1898
|
expect(auctionArgs.adUnits[0].mediaTypes.banner.pos).to.equal(2);
|
|
1899
|
+
expect(auctionArgs.adUnits[1].mediaTypes.banner.pos).to.equal(0);
|
|
1862
1900
|
});
|
|
1863
1901
|
});
|
|
1864
1902
|
|