@@ -9,11 +9,12 @@ import {
9
9
} from 'modules/criteoBidAdapter.js' ;
10
10
import * as utils from 'src/utils.js' ;
11
11
import * as refererDetection from 'src/refererDetection.js' ;
12
+ import * as ajax from 'src/ajax.js' ;
12
13
import { config } from '../../../src/config.js' ;
13
14
import { BANNER , NATIVE , VIDEO } from '../../../src/mediaTypes.js' ;
14
15
15
16
describe ( 'The Criteo bidding adapter' , function ( ) {
16
- let utilsMock , sandbox ;
17
+ let utilsMock , sandbox , ajaxStub ;
17
18
18
19
beforeEach ( function ( ) {
19
20
$$PREBID_GLOBAL$$ . bidderSettings = {
@@ -26,13 +27,15 @@ describe('The Criteo bidding adapter', function () {
26
27
utilsMock = sinon . mock ( utils ) ;
27
28
28
29
sandbox = sinon . sandbox . create ( ) ;
30
+ ajaxStub = sandbox . stub ( ajax , 'ajax' ) ;
29
31
} ) ;
30
32
31
33
afterEach ( function ( ) {
32
34
$$PREBID_GLOBAL$$ . bidderSettings = { } ;
33
35
global . Criteo = undefined ;
34
36
utilsMock . restore ( ) ;
35
37
sandbox . restore ( ) ;
38
+ ajaxStub . restore ( ) ;
36
39
} ) ;
37
40
38
41
describe ( 'getUserSyncs' , function ( ) {
@@ -56,7 +59,9 @@ describe('The Criteo bidding adapter', function () {
56
59
cookiesAreEnabledStub ,
57
60
localStorageIsEnabledStub ,
58
61
getCookieStub ,
59
- getDataFromLocalStorageStub ;
62
+ setCookieStub ,
63
+ getDataFromLocalStorageStub ,
64
+ removeDataFromLocalStorageStub ;
60
65
61
66
beforeEach ( function ( ) {
62
67
getConfigStub = sinon . stub ( config , 'getConfig' ) ;
@@ -75,8 +80,10 @@ describe('The Criteo bidding adapter', function () {
75
80
localStorageIsEnabledStub = sinon . stub ( storage , 'localStorageIsEnabled' ) ;
76
81
localStorageIsEnabledStub . returns ( true ) ;
77
82
78
- getCookieStub = sinon . stub ( storage , 'getCookie' )
83
+ getCookieStub = sinon . stub ( storage , 'getCookie' ) ;
84
+ setCookieStub = sinon . stub ( storage , 'setCookie' ) ;
79
85
getDataFromLocalStorageStub = sinon . stub ( storage , 'getDataFromLocalStorage' ) ;
86
+ removeDataFromLocalStorageStub = sinon . stub ( storage , 'removeDataFromLocalStorage' ) ;
80
87
} ) ;
81
88
82
89
afterEach ( function ( ) {
@@ -86,7 +93,9 @@ describe('The Criteo bidding adapter', function () {
86
93
cookiesAreEnabledStub . restore ( ) ;
87
94
localStorageIsEnabledStub . restore ( ) ;
88
95
getCookieStub . restore ( ) ;
96
+ setCookieStub . restore ( ) ;
89
97
getDataFromLocalStorageStub . restore ( ) ;
98
+ removeDataFromLocalStorageStub . restore ( ) ;
90
99
} ) ;
91
100
92
101
it ( 'should not trigger sync if publisher is using fast bid' , function ( ) {
@@ -198,6 +207,25 @@ describe('The Criteo bidding adapter', function () {
198
207
url : `https://gum.criteo.com/syncframe?origin=criteoPrebidAdapter&topUrl=www.abc.com&us_privacy=ABC#${ JSON . stringify ( expectedHash ) . replace ( / " / g, '%22' ) } `
199
208
} ] ) ;
200
209
} ) ;
210
+
211
+ it ( 'should delete user data when calling onDataDeletionRequest' , ( ) => {
212
+ const cookieData = {
213
+ 'cto_bundle' : 'a'
214
+ } ;
215
+ const lsData = {
216
+ 'cto_bundle' : 'a'
217
+ }
218
+ getCookieStub . callsFake ( cookieName => cookieData [ cookieName ] ) ;
219
+ setCookieStub . callsFake ( ( cookieName , value , expires ) => cookieData [ cookieName ] = value ) ;
220
+ removeDataFromLocalStorageStub . callsFake ( name => lsData [ name ] = '' ) ;
221
+ spec . onDataDeletionRequest ( [ ] ) ;
222
+ expect ( getCookieStub . calledOnce ) . to . equal ( true ) ;
223
+ expect ( setCookieStub . calledOnce ) . to . equal ( true ) ;
224
+ expect ( removeDataFromLocalStorageStub . calledOnce ) . to . equal ( true ) ;
225
+ expect ( cookieData . cto_bundle ) . to . equal ( '' ) ;
226
+ expect ( lsData . cto_bundle ) . to . equal ( '' ) ;
227
+ expect ( ajaxStub . calledOnce ) . to . equal ( true ) ;
228
+ } ) ;
201
229
} ) ;
202
230
203
231
describe ( 'isBidRequestValid' , function ( ) {
0 commit comments