@@ -306,7 +306,7 @@ const ANALYTICS_MESSAGE = {
306
306
describe ( 'magnite analytics adapter' , function ( ) {
307
307
let sandbox ;
308
308
let clock ;
309
- let getDataFromLocalStorageStub , setDataInLocalStorageStub , localStorageIsEnabledStub ;
309
+ let getDataFromLocalStorageStub , setDataInLocalStorageStub , localStorageIsEnabledStub , removeDataFromLocalStorageStub ;
310
310
let gptSlot0 ;
311
311
let gptSlotRenderEnded0 ;
312
312
beforeEach ( function ( ) {
@@ -325,6 +325,7 @@ describe('magnite analytics adapter', function () {
325
325
getDataFromLocalStorageStub = sinon . stub ( storage , 'getDataFromLocalStorage' ) ;
326
326
setDataInLocalStorageStub = sinon . stub ( storage , 'setDataInLocalStorage' ) ;
327
327
localStorageIsEnabledStub = sinon . stub ( storage , 'localStorageIsEnabled' ) ;
328
+ removeDataFromLocalStorageStub = sinon . stub ( storage , 'removeDataFromLocalStorage' )
328
329
sandbox = sinon . sandbox . create ( ) ;
329
330
330
331
localStorageIsEnabledStub . returns ( true ) ;
@@ -355,6 +356,7 @@ describe('magnite analytics adapter', function () {
355
356
getDataFromLocalStorageStub . restore ( ) ;
356
357
setDataInLocalStorageStub . restore ( ) ;
357
358
localStorageIsEnabledStub . restore ( ) ;
359
+ removeDataFromLocalStorageStub . restore ( ) ;
358
360
magniteAdapter . disableAnalytics ( ) ;
359
361
} ) ;
360
362
@@ -1932,19 +1934,21 @@ describe('magnite analytics adapter', function () {
1932
1934
} ) ;
1933
1935
} ) ;
1934
1936
1935
- it ( 'getHostNameFromReferer correctly grabs hostname from an input URL' , function ( ) {
1936
- let inputUrl = 'https://www.prebid.org/some/path?pbjs_debug=true' ;
1937
- expect ( getHostNameFromReferer ( inputUrl ) ) . to . equal ( 'www.prebid.org' ) ;
1938
- inputUrl = 'https://www.prebid.com/some/path?pbjs_debug=true' ;
1939
- expect ( getHostNameFromReferer ( inputUrl ) ) . to . equal ( 'www.prebid.com' ) ;
1940
- inputUrl = 'https://prebid.org/some/path?pbjs_debug=true' ;
1941
- expect ( getHostNameFromReferer ( inputUrl ) ) . to . equal ( 'prebid.org' ) ;
1942
- inputUrl = 'http://xn--p8j9a0d9c9a.xn--q9jyb4c/' ;
1943
- expect ( typeof getHostNameFromReferer ( inputUrl ) ) . to . equal ( 'string' ) ;
1944
-
1945
- // not non-UTF char's in query / path which break if noDecodeWholeURL not set
1946
- inputUrl = 'https://prebid.org/search_results/%95x%8Em%92%CA/?category=000' ;
1947
- expect ( getHostNameFromReferer ( inputUrl ) ) . to . equal ( 'prebid.org' ) ;
1937
+ describe ( 'getHostNameFromReferer' , ( ) => {
1938
+ it ( 'correctly grabs hostname from an input URL' , function ( ) {
1939
+ let inputUrl = 'https://www.prebid.org/some/path?pbjs_debug=true' ;
1940
+ expect ( getHostNameFromReferer ( inputUrl ) ) . to . equal ( 'www.prebid.org' ) ;
1941
+ inputUrl = 'https://www.prebid.com/some/path?pbjs_debug=true' ;
1942
+ expect ( getHostNameFromReferer ( inputUrl ) ) . to . equal ( 'www.prebid.com' ) ;
1943
+ inputUrl = 'https://prebid.org/some/path?pbjs_debug=true' ;
1944
+ expect ( getHostNameFromReferer ( inputUrl ) ) . to . equal ( 'prebid.org' ) ;
1945
+ inputUrl = 'http://xn--p8j9a0d9c9a.xn--q9jyb4c/' ;
1946
+ expect ( typeof getHostNameFromReferer ( inputUrl ) ) . to . equal ( 'string' ) ;
1947
+
1948
+ // not non-UTF char's in query / path which break if noDecodeWholeURL not set
1949
+ inputUrl = 'https://prebid.org/search_results/%95x%8Em%92%CA/?category=000' ;
1950
+ expect ( getHostNameFromReferer ( inputUrl ) ) . to . equal ( 'prebid.org' ) ;
1951
+ } ) ;
1948
1952
} ) ;
1949
1953
1950
1954
describe ( `handle currency conversions` , ( ) => {
@@ -1985,4 +1989,22 @@ describe('magnite analytics adapter', function () {
1985
1989
expect ( bidResponseObj . bidPriceUSD ) . to . equal ( 0 ) ;
1986
1990
} ) ;
1987
1991
} ) ;
1992
+
1993
+ describe ( 'onDataDeletionRequest' , ( ) => {
1994
+ it ( 'attempts to delete the magnite cookie when local storage is enabled' , ( ) => {
1995
+ magniteAdapter . onDataDeletionRequest ( ) ;
1996
+
1997
+ expect ( removeDataFromLocalStorageStub . getCall ( 0 ) . args [ 0 ] ) . to . equal ( 'mgniSession' ) ;
1998
+ } ) ;
1999
+
2000
+ it ( 'throws an error if it cannot access the cookie' , ( done ) => {
2001
+ localStorageIsEnabledStub . returns ( false ) ;
2002
+ try {
2003
+ magniteAdapter . onDataDeletionRequest ( ) ;
2004
+ } catch ( error ) {
2005
+ expect ( error . message ) . to . equal ( 'Unable to access local storage, no data deleted' ) ;
2006
+ done ( ) ;
2007
+ }
2008
+ } )
2009
+ } ) ;
1988
2010
} ) ;
0 commit comments