1
1
import { expect } from 'chai' ;
2
2
import sinon from 'sinon' ;
3
- import { spec } from 'modules/concertBidAdapter.js' ;
4
- import { getStorageManager } from '../../../ src/storageManager .js'
3
+ import { spec , storage } from 'modules/concertBidAdapter.js' ;
4
+ import { hook } from 'src/hook .js' ;
5
5
6
6
describe ( 'ConcertAdapter' , function ( ) {
7
7
let bidRequests ;
@@ -10,9 +10,8 @@ describe('ConcertAdapter', function () {
10
10
let element ;
11
11
let sandbox ;
12
12
13
- afterEach ( function ( ) {
14
- $$PREBID_GLOBAL$$ . bidderSettings = { } ;
15
- sandbox . restore ( ) ;
13
+ before ( function ( ) {
14
+ hook . ready ( ) ;
16
15
} ) ;
17
16
18
17
beforeEach ( function ( ) {
@@ -39,6 +38,7 @@ describe('ConcertAdapter', function () {
39
38
storageAllowed : true
40
39
}
41
40
} ;
41
+
42
42
bidRequests = [
43
43
{
44
44
bidder : 'concert' ,
@@ -83,6 +83,11 @@ describe('ConcertAdapter', function () {
83
83
sandbox . stub ( document , 'getElementById' ) . withArgs ( 'desktop_leaderboard_variable' ) . returns ( element )
84
84
} ) ;
85
85
86
+ afterEach ( function ( ) {
87
+ $$PREBID_GLOBAL$$ . bidderSettings = { } ;
88
+ sandbox . restore ( ) ;
89
+ } ) ;
90
+
86
91
describe ( 'spec.isBidRequestValid' , function ( ) {
87
92
it ( 'should return when it recieved all the required params' , function ( ) {
88
93
const bid = bidRequests [ 0 ] ;
@@ -118,7 +123,6 @@ describe('ConcertAdapter', function () {
118
123
} ) ;
119
124
120
125
it ( 'should not generate uid if the user has opted out' , function ( ) {
121
- const storage = getStorageManager ( ) ;
122
126
storage . setDataInLocalStorage ( 'c_nap' , 'true' ) ;
123
127
const request = spec . buildRequests ( bidRequests , bidRequest ) ;
124
128
const payload = JSON . parse ( request . data ) ;
@@ -127,17 +131,29 @@ describe('ConcertAdapter', function () {
127
131
} ) ;
128
132
129
133
it ( 'should generate uid if the user has not opted out' , function ( ) {
130
- const storage = getStorageManager ( ) ;
131
134
storage . removeDataFromLocalStorage ( 'c_nap' ) ;
132
135
const request = spec . buildRequests ( bidRequests , bidRequest ) ;
133
136
const payload = JSON . parse ( request . data ) ;
134
137
135
138
expect ( payload . meta . uid ) . to . not . equal ( false ) ;
136
139
} ) ;
137
140
138
- it ( 'should grab uid from local storage if it exists' , function ( ) {
139
- const storage = getStorageManager ( ) ;
140
- storage . setDataInLocalStorage ( 'c_uid' , 'foo' ) ;
141
+ it ( 'should use sharedid if it exists' , function ( ) {
142
+ storage . removeDataFromLocalStorage ( 'c_nap' ) ;
143
+ const request = spec . buildRequests ( bidRequests , {
144
+ ...bidRequest ,
145
+ userId : {
146
+ _sharedid : {
147
+ id : '123abc'
148
+ }
149
+ }
150
+ } ) ;
151
+ const payload = JSON . parse ( request . data ) ;
152
+ expect ( payload . meta . uid ) . to . equal ( '123abc' ) ;
153
+ } )
154
+
155
+ it ( 'should grab uid from local storage if it exists and sharedid does not' , function ( ) {
156
+ storage . setDataInLocalStorage ( 'vmconcert_uid' , 'foo' ) ;
141
157
storage . removeDataFromLocalStorage ( 'c_nap' ) ;
142
158
const request = spec . buildRequests ( bidRequests , bidRequest ) ;
143
159
const payload = JSON . parse ( request . data ) ;
@@ -211,7 +227,6 @@ describe('ConcertAdapter', function () {
211
227
const opts = {
212
228
iframeEnabled : true
213
229
} ;
214
- const storage = getStorageManager ( ) ;
215
230
storage . setDataInLocalStorage ( 'c_nap' , 'true' ) ;
216
231
217
232
const sync = spec . getUserSyncs ( opts , [ ] , bidRequest . gdprConsent , bidRequest . uspConsent ) ;
@@ -222,7 +237,6 @@ describe('ConcertAdapter', function () {
222
237
const opts = {
223
238
iframeEnabled : true
224
239
} ;
225
- const storage = getStorageManager ( ) ;
226
240
storage . removeDataFromLocalStorage ( 'c_nap' ) ;
227
241
228
242
bidRequest . gdprConsent = {
@@ -237,7 +251,6 @@ describe('ConcertAdapter', function () {
237
251
const opts = {
238
252
iframeEnabled : true
239
253
} ;
240
- const storage = getStorageManager ( ) ;
241
254
storage . removeDataFromLocalStorage ( 'c_nap' ) ;
242
255
243
256
bidRequest . gdprConsent = {
@@ -252,7 +265,6 @@ describe('ConcertAdapter', function () {
252
265
const opts = {
253
266
iframeEnabled : true
254
267
} ;
255
- const storage = getStorageManager ( ) ;
256
268
storage . removeDataFromLocalStorage ( 'c_nap' ) ;
257
269
258
270
bidRequest . gdprConsent = {
@@ -268,7 +280,6 @@ describe('ConcertAdapter', function () {
268
280
const opts = {
269
281
iframeEnabled : true
270
282
} ;
271
- const storage = getStorageManager ( ) ;
272
283
storage . removeDataFromLocalStorage ( 'c_nap' ) ;
273
284
274
285
bidRequest . gdprConsent = {
0 commit comments