Skip to content

Commit 644c510

Browse files
authored
Merge branch 'jwt/MOB-12231-create-an-iterableapi-class-for-api-calls' into jwt/MOB-12298-new-improve-logger
2 parents 2fa18f8 + 23d719a commit 644c510

5 files changed

Lines changed: 1818 additions & 20 deletions

File tree

android/src/main/java/com/iterable/reactnative/RNIterableAPIModuleImpl.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -600,11 +600,6 @@ public void onTokenRegistrationSuccessful(String authToken) {
600600
sendEvent(EventName.handleAuthSuccessCalled.name(), null);
601601
}
602602

603-
public void onTokenRegistrationFailed(Throwable object) {
604-
IterableLogger.v(TAG, "Failed to set authToken");
605-
sendEvent(EventName.handleAuthFailureCalled.name(), null);
606-
}
607-
608603
public void addListener(String eventName) {
609604
// Keep: Required for RN built in Event Emitter Calls.
610605
}

src/__mocks__/MockRNIterableAPI.ts

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ export class MockRNIterableAPI {
1616
});
1717
}
1818

19-
static setEmail(email: string, authToken?: string): void {
19+
static setEmail = jest.fn((email: string, authToken?: string): void => {
2020
MockRNIterableAPI.email = email;
2121
MockRNIterableAPI.token = authToken;
22-
}
22+
});
2323

2424
static async getUserId(): Promise<string | undefined> {
2525
return await new Promise((resolve) => {
2626
resolve(MockRNIterableAPI.userId);
2727
});
2828
}
2929

30-
static setUserId(userId: string, authToken?: string): void {
30+
static setUserId = jest.fn((userId: string, authToken?: string): void => {
3131
MockRNIterableAPI.userId = userId;
3232
MockRNIterableAPI.token = authToken;
33-
}
33+
});
3434

3535
static disableDeviceForCurrentUser = jest.fn();
3636

@@ -62,9 +62,11 @@ export class MockRNIterableAPI {
6262
});
6363
}
6464

65-
static setAttributionInfo(attributionInfo?: IterableAttributionInfo): void {
66-
MockRNIterableAPI.attributionInfo = attributionInfo;
67-
}
65+
static setAttributionInfo = jest.fn(
66+
(attributionInfo?: IterableAttributionInfo): void => {
67+
MockRNIterableAPI.attributionInfo = attributionInfo;
68+
}
69+
);
6870

6971
static initializeWithApiKey = jest.fn().mockResolvedValue(true);
7072

@@ -86,14 +88,16 @@ export class MockRNIterableAPI {
8688

8789
static setAutoDisplayPaused = jest.fn();
8890

89-
static async showMessage(
90-
_message: IterableInAppMessage,
91-
_consume: boolean
92-
): Promise<string | undefined> {
93-
return await new Promise((resolve) => {
94-
resolve(MockRNIterableAPI.clickedUrl);
95-
});
96-
}
91+
static showMessage = jest.fn(
92+
async (
93+
_messageId: string,
94+
_consume: boolean
95+
): Promise<string | undefined> => {
96+
return await new Promise((resolve) => {
97+
resolve(MockRNIterableAPI.clickedUrl);
98+
});
99+
}
100+
);
97101

98102
static removeMessage = jest.fn();
99103

@@ -109,6 +113,22 @@ export class MockRNIterableAPI {
109113

110114
static updateSubscriptions = jest.fn();
111115

116+
static getInboxMessages = jest.fn(
117+
async (): Promise<IterableInAppMessage[] | undefined> => {
118+
return await new Promise((resolve) => {
119+
resolve(MockRNIterableAPI.messages);
120+
});
121+
}
122+
);
123+
124+
static startSession = jest.fn();
125+
126+
static endSession = jest.fn();
127+
128+
static updateVisibleRows = jest.fn();
129+
130+
static getHtmlInAppContentForMessage = jest.fn();
131+
112132
// set messages function is to set the messages static property
113133
// this is for testing purposes only
114134
static setMessages(messages: IterableInAppMessage[]): void {

0 commit comments

Comments
 (0)