Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 35 additions & 15 deletions src/__mocks__/MockRNIterableAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ export class MockRNIterableAPI {
});
}

static setEmail(email: string, authToken?: string): void {
static setEmail = jest.fn((email: string, authToken?: string): void => {
MockRNIterableAPI.email = email;
MockRNIterableAPI.token = authToken;
}
});

static async getUserId(): Promise<string | undefined> {
return await new Promise((resolve) => {
resolve(MockRNIterableAPI.userId);
});
}

static setUserId(userId: string, authToken?: string): void {
static setUserId = jest.fn((userId: string, authToken?: string): void => {
MockRNIterableAPI.userId = userId;
MockRNIterableAPI.token = authToken;
}
});

static disableDeviceForCurrentUser = jest.fn();

Expand Down Expand Up @@ -62,9 +62,11 @@ export class MockRNIterableAPI {
});
}

static setAttributionInfo(attributionInfo?: IterableAttributionInfo): void {
MockRNIterableAPI.attributionInfo = attributionInfo;
}
static setAttributionInfo = jest.fn(
(attributionInfo?: IterableAttributionInfo): void => {
MockRNIterableAPI.attributionInfo = attributionInfo;
}
);

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

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

static setAutoDisplayPaused = jest.fn();

static async showMessage(
_message: IterableInAppMessage,
_consume: boolean
): Promise<string | undefined> {
return await new Promise((resolve) => {
resolve(MockRNIterableAPI.clickedUrl);
});
}
static showMessage = jest.fn(
async (
_messageId: string,
_consume: boolean
): Promise<string | undefined> => {
return await new Promise((resolve) => {
resolve(MockRNIterableAPI.clickedUrl);
});
}
);

static removeMessage = jest.fn();

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

static updateSubscriptions = jest.fn();

static getInboxMessages = jest.fn(
async (): Promise<IterableInAppMessage[] | undefined> => {
return await new Promise((resolve) => {
resolve(MockRNIterableAPI.messages);
});
}
);

static startSession = jest.fn();

static endSession = jest.fn();

static updateVisibleRows = jest.fn();

static getHtmlInAppContentForMessage = jest.fn();

// set messages function is to set the messages static property
// this is for testing purposes only
static setMessages(messages: IterableInAppMessage[]): void {
Expand Down
Loading