Skip to content

Commit 2cf7c20

Browse files
remove use of cookie name in test files
1 parent 03ffd1b commit 2cf7c20

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/integrationTests/euidSdk.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ describe('Store config EUID', () => {
160160
beforeEach(() => {
161161
sdkWindow.__euid = new EUID();
162162
document.cookie =
163-
EUID.COOKIE_NAME + '_config' + '=;expires=Tue, 1 Jan 1980 23:59:59 GMT;path=/';
163+
productDetails.cookieName + '_config' + '=;expires=Tue, 1 Jan 1980 23:59:59 GMT;path=/';
164164
});
165165

166166
afterEach(() => {

src/integrationTests/options.test.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ mocks.setupFakeTime();
1515
const mockDomain = 'www.uidapi.com';
1616
const 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+
1825
beforeEach(() => {
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

Comments
 (0)