Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mprew97 committed Oct 17, 2024
1 parent 8165b4a commit 0785b10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
18 changes: 5 additions & 13 deletions src/authorization/authorization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getInAppMessages } from '../inapp';
import { track, trackInAppClose } from '../events';
import { updateSubscriptions, updateUser, updateUserEmail } from '../users';
import { trackPurchase, updateCart } from '../commerce';
import { GETMESSAGES_PATH } from '../constants';
import { GETMESSAGES_PATH, INITIALIZE_ERROR } from '../constants';

const localStorageMock = {
getItem: jest.fn(),
Expand Down Expand Up @@ -380,9 +380,7 @@ describe('User Identification', () => {
packageName: 'my-lil-website'
});
} catch (e) {
expect(e).toStrictEqual(
new Error('Cannot make API request until a user is signed in')
);
expect(e).toStrictEqual(INITIALIZE_ERROR);
}
});

Expand All @@ -398,9 +396,7 @@ describe('User Identification', () => {
packageName: 'my-lil-website'
});
} catch (e) {
expect(e).toStrictEqual(
new Error('Cannot make API request until a user is signed in')
);
expect(e).toStrictEqual(INITIALIZE_ERROR);
}
});
});
Expand Down Expand Up @@ -714,9 +710,7 @@ describe('User Identification', () => {
packageName: 'my-lil-website'
});
} catch (e) {
expect(e).toStrictEqual(
new Error('Cannot make API request until a user is signed in')
);
expect(e).toStrictEqual(INITIALIZE_ERROR);
}
});

Expand All @@ -733,9 +727,7 @@ describe('User Identification', () => {
packageName: 'my-lil-website'
});
} catch (e) {
expect(e).toStrictEqual(
new Error('Cannot make API request until a user is signed in')
);
expect(e).toStrictEqual(INITIALIZE_ERROR);
}
});
});
Expand Down
4 changes: 3 additions & 1 deletion src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ export const baseIterableRequest = <T = any>(
const endpoint = payload?.url ?? '';

// for most Iterable API endpoints, we require a userId or email to be set

console.log({ auth: getTypeOfAuth() });
if (
!ENDPOINTS_REQUIRING_USER.includes(endpoint) &&
getTypeOfAuth() === null
) {
Promise.reject(INITIALIZE_ERROR);
return Promise.reject(INITIALIZE_ERROR);
}
if (payload.validation?.data && payload.data) {
payload.validation.data.validateSync(payload.data, { abortEarly: false });
Expand Down

0 comments on commit 0785b10

Please sign in to comment.