Skip to content

Commit 6deeae3

Browse files
committed
refactor: simplify IterableInAppManager usage in tests by directly accessing Iterable.inAppManager
1 parent 78e22b2 commit 6deeae3

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/__tests__/IterableInApp.test.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { NativeEventEmitter } from 'react-native';
22

33
import { IterableLogger } from '../core';
4-
import { IterableInAppManager } from '../inApp';
54

65
import { MockRNIterableAPI } from '../__mocks__/MockRNIterableAPI';
76

@@ -202,10 +201,8 @@ describe('Iterable In App', () => {
202201

203202
// WHEN the simulated local queue is set to the in-app messages
204203
MockRNIterableAPI.setMessages(messages);
205-
const inAppManager = new IterableInAppManager();
206-
207-
// THEN Iterable,inAppManager.getMessages returns the list of in-app messages
208-
return await inAppManager.getMessages().then((messagesObtained) => {
204+
// THEN Iterable.inAppManager.getMessages returns the list of in-app messages
205+
return await Iterable.inAppManager?.getMessages().then((messagesObtained) => {
209206
expect(messagesObtained).toEqual(messages);
210207
});
211208
});
@@ -224,9 +221,8 @@ describe('Iterable In App', () => {
224221

225222
// WHEN the simulated clicked url is set to the clicked url
226223
MockRNIterableAPI.setClickedUrl(clickedUrl);
227-
const inAppManager = new IterableInAppManager();
228224
// THEN Iterable,inAppManager.showMessage returns the simulated clicked url
229-
return await inAppManager.showMessage(message, consume).then((url) => {
225+
return await Iterable.inAppManager?.showMessage(message, consume).then((url) => {
230226
expect(url).toEqual(clickedUrl);
231227
});
232228
});
@@ -242,10 +238,9 @@ describe('Iterable In App', () => {
242238
const location: IterableInAppLocation = IterableInAppLocation.inApp;
243239
const source: IterableInAppDeleteSource =
244240
IterableInAppDeleteSource.deleteButton;
245-
const inAppManager = new IterableInAppManager();
246241

247242
// WHEN Iterable.inAppManager.removeMessage is called
248-
inAppManager.removeMessage(message, location, source);
243+
Iterable.inAppManager?.removeMessage(message, location, source);
249244

250245
// THEN corresponding method is called on MockIterableAPI with appropriate parameters
251246
expect(MockRNIterableAPI.removeMessage).toBeCalledWith(
@@ -266,8 +261,7 @@ describe('Iterable In App', () => {
266261
const read: boolean = true;
267262

268263
// WHEN Iterable.inAppManager.setReadForMessage is called
269-
const inAppManager = new IterableInAppManager();
270-
inAppManager.setReadForMessage(message, read);
264+
Iterable.inAppManager?.setReadForMessage(message, read);
271265

272266
// THEN corresponding method is called on MockRNIterableAPI with appropriate parameters
273267
expect(MockRNIterableAPI.setReadForMessage).toBeCalledWith(
@@ -281,8 +275,7 @@ describe('Iterable In App', () => {
281275
const paused: boolean = true;
282276

283277
// WHEN Iterable.inAppManager.setAutoDisplayPaused is called
284-
const inAppManager = new IterableInAppManager();
285-
inAppManager.setAutoDisplayPaused(paused);
278+
Iterable.inAppManager?.setAutoDisplayPaused(paused);
286279

287280
// THEN corresponding method is called on MockRNIterableAPI with appropriate parameters
288281
expect(MockRNIterableAPI.setAutoDisplayPaused).toBeCalledWith(paused);

0 commit comments

Comments
 (0)