Skip to content

Commit d7256fd

Browse files
authored
Merge pull request #599 from Iterable/2.0.0-alpha/MOB-9995-reorganize-source-code
[MOB-9995] reorganize source code
2 parents 7cae386 + a7dccb5 commit d7256fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+525
-443
lines changed

src/IterableAction.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/IterableInAppClasses.ts

Lines changed: 0 additions & 132 deletions
This file was deleted.

src/__mocks__/MockRNIterableAPI.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { IterableAttributionInfo } from '../Iterable';
2-
import { IterableInAppMessage } from '../IterableInAppMessage';
1+
import { IterableAttributionInfo } from '../core';
2+
import { IterableInAppMessage } from '../inApp';
33

44
export class MockRNIterableAPI {
55
static email?: string;

src/__mocks__/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './MockLinking';
2+
export * from './MockRNIterableAPI';

src/__tests__/Iterable.test.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,21 @@ import { NativeEventEmitter } from 'react-native';
22

33
import { MockLinking } from '../__mocks__/MockLinking';
44
import { MockRNIterableAPI } from '../__mocks__/MockRNIterableAPI';
5-
import { TestHelper } from './TestHelper';
6-
5+
import { IterableLogger } from '../core';
76
// import from the same location that consumers import from
87
import {
98
Iterable,
109
IterableAction,
1110
IterableActionContext,
1211
IterableActionSource,
13-
IterableConfig,
14-
IterableLogLevel,
15-
} from '../index';
16-
import {
17-
EventName,
1812
IterableAttributionInfo,
1913
IterableCommerceItem,
20-
} from '../Iterable';
21-
import { IterableDataRegion } from '../IterableDataRegion';
22-
import { IterableLogger } from '../IterableLogger';
14+
IterableConfig,
15+
IterableDataRegion,
16+
IterableEventName,
17+
IterableLogLevel,
18+
} from '..';
19+
import { TestHelper } from './TestHelper';
2320

2421
describe('Iterable', () => {
2522
beforeEach(() => {
@@ -253,7 +250,7 @@ describe('Iterable', () => {
253250
);
254251
// sets up event emitter
255252
const nativeEmitter = new NativeEventEmitter();
256-
nativeEmitter.removeAllListeners(EventName.handleUrlCalled);
253+
nativeEmitter.removeAllListeners(IterableEventName.handleUrlCalled);
257254
// sets up config file and urlHandler function
258255
// urlHandler set to return false
259256
const config = new IterableConfig();
@@ -276,7 +273,7 @@ describe('Iterable', () => {
276273
context: { action: actionDict, source: 'inApp' },
277274
};
278275
// WHEN handleUrlCalled event is emitted
279-
nativeEmitter.emit(EventName.handleUrlCalled, dict);
276+
nativeEmitter.emit(IterableEventName.handleUrlCalled, dict);
280277
// THEN urlHandler and MockLinking is called with expected url
281278
return await TestHelper.delayed(0, () => {
282279
expect(config.urlHandler).toBeCalledWith(expectedUrl, dict.context);
@@ -289,7 +286,7 @@ describe('Iterable', () => {
289286
);
290287
// sets up event emitter
291288
const nativeEmitter = new NativeEventEmitter();
292-
nativeEmitter.removeAllListeners(EventName.handleUrlCalled);
289+
nativeEmitter.removeAllListeners(IterableEventName.handleUrlCalled);
293290
// sets up config file and urlHandler function
294291
// urlHandler set to return false
295292
const config = new IterableConfig();
@@ -312,7 +309,7 @@ describe('Iterable', () => {
312309
context: { action: actionDict, source: 'inApp' },
313310
};
314311
// WHEN handleUrlCalled event is emitted
315-
nativeEmitter.emit(EventName.handleUrlCalled, dict);
312+
nativeEmitter.emit(IterableEventName.handleUrlCalled, dict);
316313
// THEN urlHandler is called and MockLinking.openURL is not called
317314
return await TestHelper.delayed(0, () => {
318315
expect(config.urlHandler).toBeCalledWith(expectedUrl, dict.context);
@@ -325,7 +322,7 @@ describe('Iterable', () => {
325322
);
326323
// sets up event emitter
327324
const nativeEmitter = new NativeEventEmitter();
328-
nativeEmitter.removeAllListeners(EventName.handleUrlCalled);
325+
nativeEmitter.removeAllListeners(IterableEventName.handleUrlCalled);
329326
// sets up config file and urlHandler function
330327
// urlHandler set to return true
331328
const config = new IterableConfig();
@@ -348,7 +345,7 @@ describe('Iterable', () => {
348345
context: { action: actionDict, source: 'inApp' },
349346
};
350347
// WHEN handleUrlCalled event is emitted
351-
nativeEmitter.emit(EventName.handleUrlCalled, dict);
348+
nativeEmitter.emit(IterableEventName.handleUrlCalled, dict);
352349
// THEN urlHandler is called and MockLinking.openURL is not called
353350
return await TestHelper.delayed(0, () => {
354351
expect(config.urlHandler).toBeCalledWith(expectedUrl, dict.context);
@@ -361,7 +358,9 @@ describe('Iterable', () => {
361358
);
362359
// sets up event emitter
363360
const nativeEmitter = new NativeEventEmitter();
364-
nativeEmitter.removeAllListeners(EventName.handleCustomActionCalled);
361+
nativeEmitter.removeAllListeners(
362+
IterableEventName.handleCustomActionCalled
363+
);
365364
// sets up config file and customActionHandler function
366365
// customActionHandler set to return true
367366
const config = new IterableConfig();
@@ -382,7 +381,7 @@ describe('Iterable', () => {
382381
context: { action: actionDict, source: IterableActionSource.inApp },
383382
};
384383
// WHEN handleCustomActionCalled event is emitted
385-
nativeEmitter.emit(EventName.handleCustomActionCalled, dict);
384+
nativeEmitter.emit(IterableEventName.handleCustomActionCalled, dict);
386385
// THEN customActionHandler is called with expected action and expected context
387386
const expectedAction = new IterableAction(actionName, actionData);
388387
const expectedContext = new IterableActionContext(

src/__tests__/IterableInApp.test.ts

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

3+
import { IterableLogger } from '../core';
34
import { MockRNIterableAPI } from '../__mocks__/MockRNIterableAPI';
45

5-
import { Iterable, EventName } from '../Iterable';
6-
import { IterableConfig } from '../IterableConfig';
7-
import { IterableInAppMessage } from '../IterableInAppMessage';
86
import {
7+
Iterable,
8+
IterableConfig,
9+
IterableEventName,
10+
IterableInAppCloseSource,
11+
IterableInAppDeleteSource,
912
IterableInAppLocation,
13+
IterableInAppMessage,
14+
IterableInAppShowResponse,
1015
IterableInAppTrigger,
1116
IterableInAppTriggerType,
1217
IterableInboxMetadata,
13-
IterableInAppCloseSource,
14-
IterableInAppShowResponse,
15-
IterableInAppDeleteSource,
16-
} from '../IterableInAppClasses';
17-
import { IterableLogger } from '../IterableLogger';
18+
} from '..';
1819

1920
describe('Iterable In App', () => {
2021
beforeEach(() => {
@@ -137,7 +138,7 @@ describe('Iterable In App', () => {
137138
test('inAppHandler_messageAndEventEmitted_methodCalledWithMessage', () => {
138139
// sets up event emitter
139140
const nativeEmitter = new NativeEventEmitter();
140-
nativeEmitter.removeAllListeners(EventName.handleInAppCalled);
141+
nativeEmitter.removeAllListeners(IterableEventName.handleInAppCalled);
141142

142143
// sets up config file and inAppHandler function
143144
const config = new IterableConfig();
@@ -170,7 +171,7 @@ describe('Iterable In App', () => {
170171
);
171172

172173
// WHEN handleInAppCalled event is emitted
173-
nativeEmitter.emit(EventName.handleInAppCalled, messageDict);
174+
nativeEmitter.emit(IterableEventName.handleInAppCalled, messageDict);
174175

175176
// THEN inAppHandler and MockRNIterableAPI.setInAppShowResponse is called with message
176177
expect(config.inAppHandler).toBeCalledWith(expectedMessage);

0 commit comments

Comments
 (0)