@@ -15,6 +15,13 @@ mocks.setupFakeTime();
1515const mockDomain = 'www.uidapi.com' ;
1616const mockUrl = `http://${ mockDomain } /test/index.html` ;
1717
18+ const productDetails : ProductDetails = {
19+ name : 'UID2' ,
20+ defaultBaseUrl : 'https://prod.uidapi.com' ,
21+ localStorageKey : 'UID2-sdk-identity' ,
22+ cookieName : '__uid_2' ,
23+ } ;
24+
1825beforeEach ( ( ) => {
1926 callback = jest . fn ( ) ;
2027 uid2 = new UID2 ( ) ;
@@ -41,7 +48,7 @@ const getConfigCookie = () => {
4148 if ( docCookie ) {
4249 const payload = docCookie
4350 . split ( '; ' )
44- . find ( ( row ) => row . startsWith ( UID2 . COOKIE_NAME + '_config' + '=' ) ) ;
51+ . find ( ( row ) => row . startsWith ( productDetails . cookieName + '_config' + '=' ) ) ;
4552 if ( payload ) {
4653 return JSON . parse ( decodeURIComponent ( payload . split ( '=' ) [ 1 ] ) ) ;
4754 }
@@ -69,7 +76,7 @@ describe('cookieDomain option', () => {
6976 } ) ;
7077
7178 test ( 'should not mention domain in the cookie string' , ( ) => {
72- const cookie = cookieMock . getSetCookieString ( UID2 . COOKIE_NAME ) ;
79+ const cookie = cookieMock . getSetCookieString ( productDetails . cookieName ) ;
7380 expect ( cookie ) . not . toBe ( '' ) ;
7481 expect ( cookie ) . not . toContain ( 'Domain=' ) ;
7582 } ) ;
@@ -88,7 +95,7 @@ describe('cookieDomain option', () => {
8895 } ) ;
8996
9097 test ( 'should use domain in the cookie string' , ( ) => {
91- const cookie = cookieMock . getSetCookieString ( UID2 . COOKIE_NAME ) ;
98+ const cookie = cookieMock . getSetCookieString ( productDetails . cookieName ) ;
9299 expect ( cookie ) . toContain ( `Domain=${ domain } ;` ) ;
93100 } ) ;
94101 } ) ;
@@ -105,7 +112,7 @@ describe('cookiePath option', () => {
105112 } ) ;
106113
107114 test ( 'should use the default path in the cookie string' , ( ) => {
108- const cookie = cookieMock . getSetCookieString ( UID2 . COOKIE_NAME ) as string ;
115+ const cookie = cookieMock . getSetCookieString ( productDetails . cookieName ) as string ;
109116 expect ( cookie + ';' ) . toContain ( 'Path=/;' ) ;
110117 } ) ;
111118 } ) ;
@@ -123,7 +130,7 @@ describe('cookiePath option', () => {
123130 } ) ;
124131
125132 test ( 'should use custom path in the cookie string' , ( ) => {
126- const cookie = cookieMock . getSetCookieString ( UID2 . COOKIE_NAME ) as string ;
133+ const cookie = cookieMock . getSetCookieString ( productDetails . cookieName ) as string ;
127134 expect ( cookie + ';' ) . toContain ( `Path=${ path } ;` ) ;
128135 } ) ;
129136 } ) ;
@@ -351,7 +358,7 @@ describe('multiple init calls', () => {
351358 } ) ;
352359
353360 test ( 'should update cookie manager' , ( ) => {
354- const cookie = cookieMock . getSetCookieString ( UID2 . COOKIE_NAME ) ;
361+ const cookie = cookieMock . getSetCookieString ( productDetails . cookieName ) ;
355362 expect ( cookie ) . toContain ( `Domain=${ cookieDomain } ;` ) ;
356363 expect ( cookie + ';' ) . toContain ( `Path=${ newCookiePath } ;` ) ;
357364 const configCookie = getConfigCookie ( ) ;
@@ -518,8 +525,7 @@ describe('Store config UID2', () => {
518525
519526 beforeEach ( ( ) => {
520527 localStorage . removeItem ( 'UID2-sdk-identity_config' ) ;
521- document . cookie =
522- UID2 . COOKIE_NAME + '_config' + '=;expires=Tue, 1 Jan 1980 23:59:59 GMT;path=/' ;
528+ document . cookie = productDetails + '_config' + '=;expires=Tue, 1 Jan 1980 23:59:59 GMT;path=/' ;
523529 } ) ;
524530
525531 describe ( 'when useCookie is true' , ( ) => {
0 commit comments