-
Notifications
You must be signed in to change notification settings - Fork 6
Remove deprecated functions #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
2cf7c20
b866140
a1f736a
e4b6fb5
f8d1d8d
b53d79f
a9397a9
8bb6ec6
1f7ded2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,12 +5,11 @@ import { sdkWindow, EUID, __euidInternalHandleScriptLoad, SdkOptions } from '../ | |
| import { EventType, CallbackHandler } from '../callbackManager'; | ||
| import { __euidSSProviderScriptLoad } from '../secureSignalEuid'; | ||
| import { UidSecureSignalProvider } from '../secureSignal_shared'; | ||
| import { ProductDetails } from '../product'; | ||
| import { removeConfig } from '../configManager'; | ||
| import { ProductDetails } from '../product'; | ||
|
|
||
| let callback: any; | ||
| let asyncCallback: jest.Mock<CallbackHandler>; | ||
| let euid: EUID; | ||
| let xhrMock: any; | ||
| let uid2ESP: UidSecureSignalProvider; | ||
| let secureSignalProvidersPushMock: jest.Mock<(p: any) => Promise<void>>; | ||
|
|
@@ -26,12 +25,19 @@ jest.spyOn(document, 'URL', 'get').mockImplementation(() => mockUrl); | |
|
|
||
| const makeIdentity = mocks.makeIdentityV2; | ||
|
|
||
| const euidProductDetails: ProductDetails = { | ||
| name: 'EUID', | ||
| defaultBaseUrl: 'https://prod.euid.eu', | ||
| localStorageKey: 'EUID-sdk-identity', | ||
| cookieName: '__euid', | ||
| }; | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could possibly import these product details from |
||
| const getConfigCookie = () => { | ||
| const docCookie = document.cookie; | ||
| if (docCookie) { | ||
| const payload = docCookie | ||
| .split('; ') | ||
| .find((row) => row.startsWith(EUID.COOKIE_NAME + '_config' + '=')); | ||
| .find((row) => row.startsWith(euidProductDetails.cookieName + '_config' + '=')); | ||
| if (payload) { | ||
| return JSON.parse(decodeURIComponent(payload.split('=')[1])); | ||
| } | ||
|
|
@@ -150,17 +156,10 @@ describe('Store config EUID', () => { | |
| useCookie: false, | ||
| }; | ||
|
|
||
| const productDetails: ProductDetails = { | ||
| cookieName: '__euid', | ||
| defaultBaseUrl: 'http://test-host', | ||
| localStorageKey: 'EUID-sdk-identity', | ||
| name: 'EUID', | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| sdkWindow.__euid = new EUID(); | ||
| document.cookie = | ||
| EUID.COOKIE_NAME + '_config' + '=;expires=Tue, 1 Jan 1980 23:59:59 GMT;path=/'; | ||
| euidProductDetails.cookieName + '_config' + '=;expires=Tue, 1 Jan 1980 23:59:59 GMT;path=/'; | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
|
|
@@ -190,7 +189,7 @@ describe('Store config EUID', () => { | |
| }); | ||
| let cookie = getConfigCookie(); | ||
| expect(cookie).toBeInstanceOf(Object); | ||
| removeConfig({ ...options, useCookie: true }, productDetails); | ||
| removeConfig({ ...options, useCookie: true }, euidProductDetails); | ||
| cookie = getConfigCookie(); | ||
| expect(cookie).toBeNull(); | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,13 @@ mocks.setupFakeTime(); | |
| const mockDomain = 'www.uidapi.com'; | ||
| const mockUrl = `http://${mockDomain}/test/index.html`; | ||
|
|
||
| const uid2ProductDetails: ProductDetails = { | ||
| name: 'UID2', | ||
| defaultBaseUrl: 'https://prod.uidapi.com', | ||
| localStorageKey: 'UID2-sdk-identity', | ||
| cookieName: '__uid_2', | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| callback = jest.fn(); | ||
| uid2 = new UID2(); | ||
|
|
@@ -41,7 +48,7 @@ const getConfigCookie = () => { | |
| if (docCookie) { | ||
| const payload = docCookie | ||
| .split('; ') | ||
| .find((row) => row.startsWith(UID2.COOKIE_NAME + '_config' + '=')); | ||
| .find((row) => row.startsWith(uid2ProductDetails.cookieName + '_config' + '=')); | ||
| if (payload) { | ||
| return JSON.parse(decodeURIComponent(payload.split('=')[1])); | ||
| } | ||
|
|
@@ -69,7 +76,7 @@ describe('cookieDomain option', () => { | |
| }); | ||
|
|
||
| test('should not mention domain in the cookie string', () => { | ||
| const cookie = cookieMock.getSetCookieString(UID2.COOKIE_NAME); | ||
| const cookie = cookieMock.getSetCookieString(uid2ProductDetails.cookieName); | ||
| expect(cookie).not.toBe(''); | ||
| expect(cookie).not.toContain('Domain='); | ||
| }); | ||
|
|
@@ -88,7 +95,7 @@ describe('cookieDomain option', () => { | |
| }); | ||
|
|
||
| test('should use domain in the cookie string', () => { | ||
| const cookie = cookieMock.getSetCookieString(UID2.COOKIE_NAME); | ||
| const cookie = cookieMock.getSetCookieString(uid2ProductDetails.cookieName); | ||
| expect(cookie).toContain(`Domain=${domain};`); | ||
| }); | ||
| }); | ||
|
|
@@ -105,7 +112,7 @@ describe('cookiePath option', () => { | |
| }); | ||
|
|
||
| test('should use the default path in the cookie string', () => { | ||
| const cookie = cookieMock.getSetCookieString(UID2.COOKIE_NAME) as string; | ||
| const cookie = cookieMock.getSetCookieString(uid2ProductDetails.cookieName) as string; | ||
| expect(cookie + ';').toContain('Path=/;'); | ||
| }); | ||
| }); | ||
|
|
@@ -123,7 +130,7 @@ describe('cookiePath option', () => { | |
| }); | ||
|
|
||
| test('should use custom path in the cookie string', () => { | ||
| const cookie = cookieMock.getSetCookieString(UID2.COOKIE_NAME) as string; | ||
| const cookie = cookieMock.getSetCookieString(uid2ProductDetails.cookieName) as string; | ||
| expect(cookie + ';').toContain(`Path=${path};`); | ||
| }); | ||
| }); | ||
|
|
@@ -351,7 +358,7 @@ describe('multiple init calls', () => { | |
| }); | ||
|
|
||
| test('should update cookie manager', () => { | ||
| const cookie = cookieMock.getSetCookieString(UID2.COOKIE_NAME); | ||
| const cookie = cookieMock.getSetCookieString(uid2ProductDetails.cookieName); | ||
| expect(cookie).toContain(`Domain=${cookieDomain};`); | ||
| expect(cookie + ';').toContain(`Path=${newCookiePath};`); | ||
| const configCookie = getConfigCookie(); | ||
|
|
@@ -508,18 +515,13 @@ describe('Store config UID2', () => { | |
| refreshRetryPeriod: 1000, | ||
| useCookie: false, | ||
| }; | ||
| const productDetails: ProductDetails = { | ||
| cookieName: '__uid2', | ||
| defaultBaseUrl: 'http://test-host', | ||
| localStorageKey: 'UID2-sdk-identity', | ||
| name: 'UID2', | ||
| }; | ||
|
|
||
| const previousOptions: SdkOptions = options; | ||
|
|
||
| beforeEach(() => { | ||
| localStorage.removeItem('UID2-sdk-identity_config'); | ||
| document.cookie = | ||
| UID2.COOKIE_NAME + '_config' + '=;expires=Tue, 1 Jan 1980 23:59:59 GMT;path=/'; | ||
| uid2ProductDetails.cookieName + '_config' + '=;expires=Tue, 1 Jan 1980 23:59:59 GMT;path=/'; | ||
| }); | ||
|
|
||
| describe('when useCookie is true', () => { | ||
|
|
@@ -528,14 +530,14 @@ describe('Store config UID2', () => { | |
| const cookie = getConfigCookie(); | ||
| expect(cookie).toBeInstanceOf(Object); | ||
| expect(cookie).toHaveProperty('cookieDomain'); | ||
| const storageConfig = loadConfig(productDetails); | ||
| const storageConfig = getConfigStorage(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should have been |
||
| expect(storageConfig).toBeNull(); | ||
| }); | ||
| }); | ||
| describe('when useCookie is false', () => { | ||
| test('should store config in local storage', () => { | ||
| uid2.init({ callback: callback, identity: identity, ...options }); | ||
| const storageConfig = loadConfig(productDetails); | ||
| const storageConfig = getConfigStorage(); | ||
| expect(storageConfig).toBeInstanceOf(Object); | ||
| expect(storageConfig).toHaveProperty('cookieDomain'); | ||
| const cookie = getConfigCookie(); | ||
|
|
@@ -545,11 +547,11 @@ describe('Store config UID2', () => { | |
| describe('when useCookie is false', () => { | ||
| test('can successfully clear the config in storage', () => { | ||
| uid2.init({ callback: callback, identity: identity, ...options }); | ||
| let storageConfig = loadConfig(productDetails); | ||
| let storageConfig = loadConfig(uid2ProductDetails); | ||
| expect(storageConfig).toBeInstanceOf(Object); | ||
| expect(storageConfig).toHaveProperty('cookieDomain'); | ||
| removeConfig(previousOptions, productDetails); | ||
| storageConfig = loadConfig(productDetails); | ||
| removeConfig(previousOptions, uid2ProductDetails); | ||
| storageConfig = loadConfig(uid2ProductDetails); | ||
| expect(storageConfig).toBeNull(); | ||
| }); | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be private to match the corresponding function in
uid2Sdk.ts