Skip to content

Commit b1fb06c

Browse files
Fix: Update test cases
1 parent d832799 commit b1fb06c

File tree

3 files changed

+3
-20
lines changed

3 files changed

+3
-20
lines changed

src/components/sirenProvider.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type {
66
InitConfigType,
77
NotificationDataType,
88
NotificationsApiResponse,
9-
SirenErrorType,
109
UnviewedCountApiResponse
1110
} from '@sirenapp/js-sdk/dist/esm/types';
1211

@@ -15,8 +14,6 @@ import { generateUniqueId, isNonEmptyArray, logger } from '../utils/commonUtils'
1514
import {
1615
events,
1716
eventTypes,
18-
IN_APP_RECIPIENT_UNAUTHENTICATED,
19-
MAXIMUM_RETRY_COUNT,
2017
EventType
2118
} from '../utils/constants';
2219
import { useSiren } from '../utils';
@@ -70,7 +67,6 @@ export const useSirenContext = (): SirenContextProp => useContext(SirenContext);
7067
* @param {React.ReactNode} props.children - Child components that will have access to the Siren context.
7168
*/
7269
const SirenProvider: React.FC<SirenProvider> = ({ config, children }) => {
73-
let retryCount = 0;
7470

7571
const { markAllAsViewed } = useSiren();
7672

@@ -155,21 +151,10 @@ const SirenProvider: React.FC<SirenProvider> = ({ config, children }) => {
155151
return {
156152
token: config.userToken,
157153
recipientId: config.recipientId,
158-
onError: retryVerification,
159154
actionCallbacks: actionCallbacks
160155
};
161156
};
162157

163-
const retryVerification = (error: SirenErrorType) => {
164-
if (error.Code === IN_APP_RECIPIENT_UNAUTHENTICATED && retryCount < MAXIMUM_RETRY_COUNT)
165-
setTimeout(() => {
166-
initialize();
167-
retryCount++;
168-
}, 5000);
169-
170-
if (retryCount === MAXIMUM_RETRY_COUNT) stopRealTimeFetch();
171-
};
172-
173158
// Function to initialize the Siren SDK and fetch notifications
174159
const initialize = (): void => {
175160
const dataParams: InitConfigType = getDataParams();

tests/components/sirenProvider.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@ describe('SirenProvider', () => {
2323
<Text>Child</Text>
2424
</SirenProvider>
2525
);
26-
const mocErrorFn = jest.fn();
2726
const mockEventHandler = jest.fn();
2827

2928
const sirenObject = new Siren({
3029
token: 'user-token',
3130
recipientId: 'recipient-id',
32-
onError: mocErrorFn,
3331
actionCallbacks: {
3432
onEventReceive: mockEventHandler,
3533
}

tests/utils/sirenHook.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe('useSiren hook', () => {
108108
const untilDate = '2024-02-28T00:00:00Z';
109109
const response = await markAsReadByDate(untilDate);
110110

111-
expect(mockSiren.markAsReadByDate).toHaveBeenCalledWith(untilDate);
111+
expect(mockSiren.markAsReadByDate).toHaveBeenCalledWith({startDate: untilDate});
112112
expect(response).toEqual(ActionResponse);
113113
});
114114

@@ -126,7 +126,7 @@ describe('useSiren hook', () => {
126126
expect(response).toEqual(ActionResponse);
127127
});
128128

129-
it('should call siren.deleteByDate and update notifications list when siren exists and untilDate is provided', async () => {;
129+
it('should call siren.deleteByDate and update notifications list when siren exists and untilDate is provided', async () => {
130130

131131
jest.spyOn(sirenProvider, 'useSirenContext').mockReturnValue({
132132
siren: mockSiren as Siren,
@@ -137,7 +137,7 @@ describe('useSiren hook', () => {
137137
const untilDate = '2024-02-28T00:00:00Z';
138138
const response = await deleteByDate(untilDate);
139139

140-
expect(mockSiren.deleteByDate).toHaveBeenCalledWith(untilDate);
140+
expect(mockSiren.deleteByDate).toHaveBeenCalledWith({startDate: untilDate});
141141
expect(response).toEqual(ActionResponse);
142142
});
143143

0 commit comments

Comments
 (0)