1
1
import { NativeEventEmitter } from 'react-native' ;
2
2
3
3
import { IterableLogger } from '../core' ;
4
- import { IterableInAppManager } from '../inApp' ;
5
4
6
5
import { MockRNIterableAPI } from '../__mocks__/MockRNIterableAPI' ;
7
6
@@ -202,10 +201,8 @@ describe('Iterable In App', () => {
202
201
203
202
// WHEN the simulated local queue is set to the in-app messages
204
203
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 ) => {
209
206
expect ( messagesObtained ) . toEqual ( messages ) ;
210
207
} ) ;
211
208
} ) ;
@@ -224,9 +221,8 @@ describe('Iterable In App', () => {
224
221
225
222
// WHEN the simulated clicked url is set to the clicked url
226
223
MockRNIterableAPI . setClickedUrl ( clickedUrl ) ;
227
- const inAppManager = new IterableInAppManager ( ) ;
228
224
// 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 ) => {
230
226
expect ( url ) . toEqual ( clickedUrl ) ;
231
227
} ) ;
232
228
} ) ;
@@ -242,10 +238,9 @@ describe('Iterable In App', () => {
242
238
const location : IterableInAppLocation = IterableInAppLocation . inApp ;
243
239
const source : IterableInAppDeleteSource =
244
240
IterableInAppDeleteSource . deleteButton ;
245
- const inAppManager = new IterableInAppManager ( ) ;
246
241
247
242
// WHEN Iterable.inAppManager.removeMessage is called
248
- inAppManager . removeMessage ( message , location , source ) ;
243
+ Iterable . inAppManager ? .removeMessage ( message , location , source ) ;
249
244
250
245
// THEN corresponding method is called on MockIterableAPI with appropriate parameters
251
246
expect ( MockRNIterableAPI . removeMessage ) . toBeCalledWith (
@@ -266,8 +261,7 @@ describe('Iterable In App', () => {
266
261
const read : boolean = true ;
267
262
268
263
// WHEN Iterable.inAppManager.setReadForMessage is called
269
- const inAppManager = new IterableInAppManager ( ) ;
270
- inAppManager . setReadForMessage ( message , read ) ;
264
+ Iterable . inAppManager ?. setReadForMessage ( message , read ) ;
271
265
272
266
// THEN corresponding method is called on MockRNIterableAPI with appropriate parameters
273
267
expect ( MockRNIterableAPI . setReadForMessage ) . toBeCalledWith (
@@ -281,8 +275,7 @@ describe('Iterable In App', () => {
281
275
const paused : boolean = true ;
282
276
283
277
// WHEN Iterable.inAppManager.setAutoDisplayPaused is called
284
- const inAppManager = new IterableInAppManager ( ) ;
285
- inAppManager . setAutoDisplayPaused ( paused ) ;
278
+ Iterable . inAppManager ?. setAutoDisplayPaused ( paused ) ;
286
279
287
280
// THEN corresponding method is called on MockRNIterableAPI with appropriate parameters
288
281
expect ( MockRNIterableAPI . setAutoDisplayPaused ) . toBeCalledWith ( paused ) ;
0 commit comments