Skip to content

Commit de4db13

Browse files
committed
refactor: remove IterableLogger instantiation from tests and clean up test structure
1 parent 9be2327 commit de4db13

2 files changed

Lines changed: 14 additions & 22 deletions

File tree

src/__tests__/IterableInApp.test.ts

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

3-
import { IterableLogger } from '../core';
4-
53
import { MockRNIterableAPI } from '../__mocks__/MockRNIterableAPI';
64

75
import {
@@ -21,7 +19,6 @@ import {
2119
describe('Iterable In App', () => {
2220
beforeEach(() => {
2321
jest.clearAllMocks();
24-
Iterable.logger = new IterableLogger(new IterableConfig());
2522
});
2623

2724
test('trackInAppOpen_params_methodCalledWithParams', () => {
@@ -202,9 +199,11 @@ describe('Iterable In App', () => {
202199
// WHEN the simulated local queue is set to the in-app messages
203200
MockRNIterableAPI.setMessages(messages);
204201
// THEN Iterable.inAppManager.getMessages returns the list of in-app messages
205-
return await Iterable.inAppManager?.getMessages().then((messagesObtained) => {
206-
expect(messagesObtained).toEqual(messages);
207-
});
202+
return await Iterable.inAppManager
203+
?.getMessages()
204+
.then((messagesObtained) => {
205+
expect(messagesObtained).toEqual(messages);
206+
});
208207
});
209208

210209
test('showMessage_messageAndConsume_returnsClickedUrl', async () => {
@@ -222,9 +221,11 @@ describe('Iterable In App', () => {
222221
// WHEN the simulated clicked url is set to the clicked url
223222
MockRNIterableAPI.setClickedUrl(clickedUrl);
224223
// THEN Iterable,inAppManager.showMessage returns the simulated clicked url
225-
return await Iterable.inAppManager?.showMessage(message, consume).then((url) => {
226-
expect(url).toEqual(clickedUrl);
227-
});
224+
return await Iterable.inAppManager
225+
?.showMessage(message, consume)
226+
.then((url) => {
227+
expect(url).toEqual(clickedUrl);
228+
});
228229
});
229230

230231
test('removeMessage_params_methodCalledWithParams', () => {

src/core/classes/Iterable.test.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,32 @@ import { NativeEventEmitter, Platform } from 'react-native';
22

33
import { MockLinking } from '../../__mocks__/MockLinking';
44
import { MockRNIterableAPI } from '../../__mocks__/MockRNIterableAPI';
5-
import { IterableLogger } from '..';
65
// import from the same location that consumers import from
76
import {
87
Iterable,
98
IterableAction,
109
IterableActionContext,
1110
IterableActionSource,
1211
IterableAttributionInfo,
12+
IterableAuthResponse,
1313
IterableCommerceItem,
1414
IterableConfig,
1515
IterableDataRegion,
1616
IterableEventName,
17-
IterableLogLevel,
18-
IterableInAppMessage,
1917
IterableInAppCloseSource,
2018
IterableInAppDeleteSource,
2119
IterableInAppLocation,
20+
IterableInAppMessage,
21+
IterableInAppShowResponse,
2222
IterableInAppTrigger,
2323
IterableInAppTriggerType,
24-
IterableAuthResponse,
25-
IterableInAppShowResponse,
24+
IterableLogLevel,
2625
} from '../..';
2726
import { TestHelper } from '../../__tests__/TestHelper';
2827

29-
const getDefaultConfig = () => {
30-
const config = new IterableConfig();
31-
config.logReactNativeSdkCalls = false;
32-
return config;
33-
};
34-
3528
describe('Iterable', () => {
3629
beforeEach(() => {
3730
jest.clearAllMocks();
38-
const config = getDefaultConfig();
39-
Iterable.logger = new IterableLogger(config);
4031
});
4132

4233
afterEach(() => {

0 commit comments

Comments
 (0)