@@ -15,7 +15,7 @@ mocks.setupFakeTime();
1515const mockDomain = 'www.uidapi.com' ;
1616const mockUrl = `http://${ mockDomain } /test/index.html` ;
1717
18- const productDetails : ProductDetails = {
18+ const uid2ProductDetails : ProductDetails = {
1919 name : 'UID2' ,
2020 defaultBaseUrl : 'https://prod.uidapi.com' ,
2121 localStorageKey : 'UID2-sdk-identity' ,
@@ -41,13 +41,14 @@ const getUid2Cookie = mocks.getUid2Cookie;
4141const getUid2LocalStorage = mocks . getUid2LocalStorage ;
4242const removeUid2Cookie = mocks . removeUid2Cookie ;
4343const removeUid2LocalStorage = mocks . removeUid2LocalStorage ;
44+ const getUid2 = mocks . getUid2 ;
4445
4546const getConfigCookie = ( ) => {
4647 const docCookie = document . cookie ;
4748 if ( docCookie ) {
4849 const payload = docCookie
4950 . split ( '; ' )
50- . find ( ( row ) => row . startsWith ( productDetails . cookieName + '_config' + '=' ) ) ;
51+ . find ( ( row ) => row . startsWith ( uid2ProductDetails . cookieName + '_config' + '=' ) ) ;
5152 if ( payload ) {
5253 return JSON . parse ( decodeURIComponent ( payload . split ( '=' ) [ 1 ] ) ) ;
5354 }
@@ -75,7 +76,7 @@ describe('cookieDomain option', () => {
7576 } ) ;
7677
7778 test ( 'should not mention domain in the cookie string' , ( ) => {
78- const cookie = cookieMock . getSetCookieString ( productDetails . cookieName ) ;
79+ const cookie = cookieMock . getSetCookieString ( uid2ProductDetails . cookieName ) ;
7980 expect ( cookie ) . not . toBe ( '' ) ;
8081 expect ( cookie ) . not . toContain ( 'Domain=' ) ;
8182 } ) ;
@@ -94,7 +95,7 @@ describe('cookieDomain option', () => {
9495 } ) ;
9596
9697 test ( 'should use domain in the cookie string' , ( ) => {
97- const cookie = cookieMock . getSetCookieString ( productDetails . cookieName ) ;
98+ const cookie = cookieMock . getSetCookieString ( uid2ProductDetails . cookieName ) ;
9899 expect ( cookie ) . toContain ( `Domain=${ domain } ;` ) ;
99100 } ) ;
100101 } ) ;
@@ -111,7 +112,7 @@ describe('cookiePath option', () => {
111112 } ) ;
112113
113114 test ( 'should use the default path in the cookie string' , ( ) => {
114- const cookie = cookieMock . getSetCookieString ( productDetails . cookieName ) as string ;
115+ const cookie = cookieMock . getSetCookieString ( uid2ProductDetails . cookieName ) as string ;
115116 expect ( cookie + ';' ) . toContain ( 'Path=/;' ) ;
116117 } ) ;
117118 } ) ;
@@ -129,7 +130,7 @@ describe('cookiePath option', () => {
129130 } ) ;
130131
131132 test ( 'should use custom path in the cookie string' , ( ) => {
132- const cookie = cookieMock . getSetCookieString ( productDetails . cookieName ) as string ;
133+ const cookie = cookieMock . getSetCookieString ( uid2ProductDetails . cookieName ) as string ;
133134 expect ( cookie + ';' ) . toContain ( `Path=${ path } ;` ) ;
134135 } ) ;
135136 } ) ;
@@ -357,7 +358,7 @@ describe('multiple init calls', () => {
357358 } ) ;
358359
359360 test ( 'should update cookie manager' , ( ) => {
360- const cookie = cookieMock . getSetCookieString ( productDetails . cookieName ) ;
361+ const cookie = cookieMock . getSetCookieString ( UID2 . COOKIE_NAME ) ;
361362 expect ( cookie ) . toContain ( `Domain=${ cookieDomain } ;` ) ;
362363 expect ( cookie + ';' ) . toContain ( `Path=${ newCookiePath } ;` ) ;
363364 const configCookie = getConfigCookie ( ) ;
@@ -520,7 +521,7 @@ describe('Store config UID2', () => {
520521 beforeEach ( ( ) => {
521522 localStorage . removeItem ( 'UID2-sdk-identity_config' ) ;
522523 document . cookie =
523- productDetails . cookieName + '_config' + '=;expires=Tue, 1 Jan 1980 23:59:59 GMT;path=/' ;
524+ uid2ProductDetails . cookieName + '_config' + '=;expires=Tue, 1 Jan 1980 23:59:59 GMT;path=/' ;
524525 } ) ;
525526
526527 describe ( 'when useCookie is true' , ( ) => {
@@ -529,14 +530,14 @@ describe('Store config UID2', () => {
529530 const cookie = getConfigCookie ( ) ;
530531 expect ( cookie ) . toBeInstanceOf ( Object ) ;
531532 expect ( cookie ) . toHaveProperty ( 'cookieDomain' ) ;
532- const storageConfig = loadConfig ( productDetails ) ;
533+ const storageConfig = getConfigStorage ( ) ;
533534 expect ( storageConfig ) . toBeNull ( ) ;
534535 } ) ;
535536 } ) ;
536537 describe ( 'when useCookie is false' , ( ) => {
537538 test ( 'should store config in local storage' , ( ) => {
538539 uid2 . init ( { callback : callback , identity : identity , ...options } ) ;
539- const storageConfig = loadConfig ( productDetails ) ;
540+ const storageConfig = getConfigStorage ( ) ;
540541 expect ( storageConfig ) . toBeInstanceOf ( Object ) ;
541542 expect ( storageConfig ) . toHaveProperty ( 'cookieDomain' ) ;
542543 const cookie = getConfigCookie ( ) ;
@@ -546,11 +547,11 @@ describe('Store config UID2', () => {
546547 describe ( 'when useCookie is false' , ( ) => {
547548 test ( 'can successfully clear the config in storage' , ( ) => {
548549 uid2 . init ( { callback : callback , identity : identity , ...options } ) ;
549- let storageConfig = loadConfig ( productDetails ) ;
550+ let storageConfig = loadConfig ( uid2ProductDetails ) ;
550551 expect ( storageConfig ) . toBeInstanceOf ( Object ) ;
551552 expect ( storageConfig ) . toHaveProperty ( 'cookieDomain' ) ;
552- removeConfig ( previousOptions , productDetails ) ;
553- storageConfig = loadConfig ( productDetails ) ;
553+ removeConfig ( previousOptions , uid2ProductDetails ) ;
554+ storageConfig = loadConfig ( uid2ProductDetails ) ;
554555 expect ( storageConfig ) . toBeNull ( ) ;
555556 } ) ;
556557 } ) ;
0 commit comments