Skip to content

Commit

Permalink
revert, outside of scope
Browse files Browse the repository at this point in the history
  • Loading branch information
mprew97 committed Sep 11, 2024
1 parent 1e5f554 commit 1761b43
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
20 changes: 10 additions & 10 deletions src/authorization/authorization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('API Key Interceptors', () => {
packageName: 'my-lil-website'
});
expect(response.config.headers['Api-Key']).toBe('123');
expect(response.config.headers['Authorization']).toBe(
expect(response.config.headers.Authorization).toBe(
`Bearer ${MOCK_JWT_KEY}`
);
});
Expand All @@ -125,7 +125,7 @@ describe('API Key Interceptors', () => {
packageName: 'my-lil-website'
});
expect(response.config.headers['Api-Key']).toBe('123');
expect(response.config.headers['Authorization']).toBe(
expect(response.config.headers.Authorization).toBe(
`Bearer ${MOCK_JWT_KEY}`
);
});
Expand Down Expand Up @@ -230,8 +230,8 @@ describe('API Key Interceptors', () => {
await updateUserEmail('[email protected]');

jest.advanceTimersByTime(60000 * 4.1);
/*
called once originally, a second time after the email was changed,
/*
called once originally, a second time after the email was changed,
and a third after the JWT was about to expire
*/
expect(mockGenerateJWT).toHaveBeenCalledTimes(3);
Expand Down Expand Up @@ -279,8 +279,8 @@ describe('API Key Interceptors', () => {
});

jest.advanceTimersByTime(60000 * 4.1);
/*
called once originally, a second time after the email was changed,
/*
called once originally, a second time after the email was changed,
and a third after the JWT was about to expire
*/
expect(mockGenerateJWT).toHaveBeenCalledTimes(3);
Expand Down Expand Up @@ -313,8 +313,8 @@ describe('API Key Interceptors', () => {
});

jest.advanceTimersByTime(60000 * 4.1);
/*
called once originally, a second time after the email was changed,
/*
called once originally, a second time after the email was changed,
and a third after the JWT was about to expire
*/
expect(mockGenerateJWT).toHaveBeenCalledTimes(3);
Expand Down Expand Up @@ -1075,7 +1075,7 @@ describe('User Identification', () => {
packageName: 'my-lil-website'
});
expect(response.config.headers['Api-Key']).toBe('123');
expect(response.config.headers['Authorization']).toBe(
expect(response.config.headers.Authorization).toBe(
`Bearer ${MOCK_JWT_KEY}`
);
});
Expand All @@ -1092,7 +1092,7 @@ describe('User Identification', () => {
packageName: 'my-lil-website'
});
expect(response.config.headers['Api-Key']).toBe('123');
expect(response.config.headers['Authorization']).toBe(
expect(response.config.headers.Authorization).toBe(
`Bearer ${MOCK_JWT_KEY}`
);
});
Expand Down
6 changes: 3 additions & 3 deletions src/commerce/commerce.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-param-reassign */
import { ENDPOINTS } from '../constants';
import { INITIALIZE_ERROR, ENDPOINTS } from '../constants';
import { baseIterableRequest } from '../request';
import { TrackPurchaseRequestParams, UpdateCartRequestParams } from './types';
import { IterableResponse } from '../types';
Expand All @@ -16,7 +16,7 @@ export const updateCart = (payload: UpdateCartRequestParams) => {
if (canTrackAnonUser()) {
const anonymousUserEventManager = new AnonymousUserEventManager();
anonymousUserEventManager.trackAnonUpdateCart(payload);
return Promise.resolve();
return Promise.reject(INITIALIZE_ERROR);
}
return baseIterableRequest<IterableResponse>({
method: 'POST',
Expand All @@ -43,7 +43,7 @@ export const trackPurchase = (payload: TrackPurchaseRequestParams) => {
if (canTrackAnonUser()) {
const anonymousUserEventManager = new AnonymousUserEventManager();
anonymousUserEventManager.trackAnonPurchaseEvent(payload);
return Promise.resolve();
return Promise.reject(INITIALIZE_ERROR);
}
return baseIterableRequest<IterableResponse>({
method: 'POST',
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,5 @@ export const UPDATECART_ITEM_PREFIX = 'updateCart.updatedShoppingCartItems.';
export const PURCHASE_ITEM_PREFIX = `${PURCHASE_ITEM}.`;

export const MERGE_SUCCESSFULL = 'MERGE_SUCCESSFULL';
export const INITIALIZE_ERROR =
'Iterable SDK must be initialized with an API key and user email/userId before calling SDK methods';
4 changes: 2 additions & 2 deletions src/events/events.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-param-reassign */
import { ENDPOINTS } from '../constants';
import { INITIALIZE_ERROR, ENDPOINTS } from '../constants';
import { baseIterableRequest } from '../request';
import { InAppTrackRequestParams } from './inapp/types';
import { IterableResponse } from '../types';
Expand All @@ -14,7 +14,7 @@ export const track = (payload: InAppTrackRequestParams) => {
if (canTrackAnonUser()) {
const anonymousUserEventManager = new AnonymousUserEventManager();
anonymousUserEventManager.trackAnonEvent(payload);
return Promise.resolve();
return Promise.reject(INITIALIZE_ERROR);
}
return baseIterableRequest<IterableResponse>({
method: 'POST',
Expand Down
4 changes: 2 additions & 2 deletions src/users/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { UpdateSubscriptionParams, UpdateUserParams } from './types';
import { updateSubscriptionsSchema, updateUserSchema } from './users.schema';
import { AnonymousUserEventManager } from '../anonymousUserTracking/anonymousUserEventManager';
import { canTrackAnonUser } from '../utils/commonFunctions';
import { ENDPOINTS } from '../constants';
import { INITIALIZE_ERROR, ENDPOINTS } from '../constants';

export const updateUserEmail = (newEmail: string) =>
baseIterableRequest<IterableResponse>({
Expand All @@ -31,7 +31,7 @@ export const updateUser = (payloadParam: UpdateUserParams = {}) => {
if (canTrackAnonUser()) {
const anonymousUserEventManager = new AnonymousUserEventManager();
anonymousUserEventManager.trackAnonUpdateUser(payload);
return Promise.resolve();
return Promise.reject(INITIALIZE_ERROR);
}
return baseIterableRequest<IterableResponse>({
method: 'POST',
Expand Down

0 comments on commit 1761b43

Please sign in to comment.