Skip to content

Commit e4b6fb5

Browse files
fixing where product details is defined
1 parent a1f736a commit e4b6fb5

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

src/euidSdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class EUID extends SdkBase {
2222
);
2323
return EUID.cookieName;
2424
}
25-
static get EuidDetails(): ProductDetails {
25+
private static get EuidDetails(): ProductDetails {
2626
return productDetails;
2727
}
2828

src/integrationTests/euidSdk.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import { sdkWindow, EUID, __euidInternalHandleScriptLoad, SdkOptions } from '../
55
import { EventType, CallbackHandler } from '../callbackManager';
66
import { __euidSSProviderScriptLoad } from '../secureSignalEuid';
77
import { UidSecureSignalProvider } from '../secureSignal_shared';
8-
import { ProductDetails } from '../product';
98
import { removeConfig } from '../configManager';
9+
import { ProductDetails } from '../product';
1010

1111
let callback: any;
1212
let asyncCallback: jest.Mock<CallbackHandler>;
13-
let euid: EUID;
1413
let xhrMock: any;
1514
let uid2ESP: UidSecureSignalProvider;
1615
let secureSignalProvidersPushMock: jest.Mock<(p: any) => Promise<void>>;
@@ -26,7 +25,7 @@ jest.spyOn(document, 'URL', 'get').mockImplementation(() => mockUrl);
2625

2726
const makeIdentity = mocks.makeIdentityV2;
2827

29-
const productDetails: ProductDetails = {
28+
const euidProductDetails: ProductDetails = {
3029
name: 'EUID',
3130
defaultBaseUrl: 'https://prod.euid.eu',
3231
localStorageKey: 'EUID-sdk-identity',
@@ -38,7 +37,7 @@ const getConfigCookie = () => {
3837
if (docCookie) {
3938
const payload = docCookie
4039
.split('; ')
41-
.find((row) => row.startsWith(productDetails.cookieName + '_config' + '='));
40+
.find((row) => row.startsWith(euidProductDetails.cookieName + '_config' + '='));
4241
if (payload) {
4342
return JSON.parse(decodeURIComponent(payload.split('=')[1]));
4443
}
@@ -160,7 +159,7 @@ describe('Store config EUID', () => {
160159
beforeEach(() => {
161160
sdkWindow.__euid = new EUID();
162161
document.cookie =
163-
productDetails.cookieName + '_config' + '=;expires=Tue, 1 Jan 1980 23:59:59 GMT;path=/';
162+
euidProductDetails.cookieName + '_config' + '=;expires=Tue, 1 Jan 1980 23:59:59 GMT;path=/';
164163
});
165164

166165
afterEach(() => {
@@ -190,7 +189,7 @@ describe('Store config EUID', () => {
190189
});
191190
let cookie = getConfigCookie();
192191
expect(cookie).toBeInstanceOf(Object);
193-
removeConfig({ ...options, useCookie: true }, productDetails);
192+
removeConfig({ ...options, useCookie: true }, euidProductDetails);
194193
cookie = getConfigCookie();
195194
expect(cookie).toBeNull();
196195
});

src/integrationTests/options.test.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mocks.setupFakeTime();
1515
const mockDomain = 'www.uidapi.com';
1616
const 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;
4141
const getUid2LocalStorage = mocks.getUid2LocalStorage;
4242
const removeUid2Cookie = mocks.removeUid2Cookie;
4343
const removeUid2LocalStorage = mocks.removeUid2LocalStorage;
44+
const getUid2 = mocks.getUid2;
4445

4546
const 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
});

src/mocks.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as jsdom from 'jsdom';
22
import { Cookie } from 'tough-cookie';
3-
import { UID2 } from './uid2Sdk';
43
import { Identity } from './Identity';
54
import { base64ToBytes, bytesToBase64 } from './encoding/base64';
65
import * as crypto from 'crypto';

0 commit comments

Comments
 (0)