Skip to content

Commit f713bf3

Browse files
Merge pull request #880 from Iterable/feature/SDK-518-increase-test-coverage
[SDK-518] - Increase test coverage
2 parents 9e6161d + d79f08d commit f713bf3

24 files changed

Lines changed: 1471 additions & 6 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,5 @@ docs/
9999
.agent/
100100
.claude/
101101
.cursor/
102+
.opencode/
102103
.pi/

jest.config.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,28 @@ module.exports = {
2020
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
2121
coverageThreshold: {
2222
global: {
23-
branches: 10,
24-
functions: 30,
25-
lines: 30,
26-
statements: 30,
23+
branches: 53,
24+
functions: 47,
25+
lines: 58,
26+
statements: 58,
27+
},
28+
'src/core/classes/Iterable.ts': {
29+
statements: 90,
30+
branches: 85,
31+
functions: 95,
32+
lines: 90,
33+
},
34+
'src/core/classes/IterableApi.ts': {
35+
statements: 95,
36+
branches: 70,
37+
functions: 95,
38+
lines: 95,
39+
},
40+
'src/core/classes/IterableConfig.ts': {
41+
statements: 95,
42+
branches: 90,
43+
functions: 90,
44+
lines: 95,
2745
},
2846
},
2947
};

src/__tests__/index.test.tsx

Lines changed: 209 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,210 @@
1-
describe('index', () => {
2-
it.todo('write a test');
1+
import {
2+
Iterable,
3+
IterableAction,
4+
IterableActionContext,
5+
IterableActionSource,
6+
IterableAttributionInfo,
7+
IterableAuthFailureReason,
8+
IterableAuthResponse,
9+
IterableAuthResponseResult,
10+
IterableCommerceItem,
11+
IterableConfig,
12+
IterableDataRegion,
13+
IterableEdgeInsets,
14+
IterableEmbeddedManager,
15+
IterableEmbeddedView,
16+
IterableEmbeddedViewType,
17+
IterableHtmlInAppContent,
18+
IterableInAppCloseSource,
19+
IterableInAppContentType,
20+
IterableInAppDeleteSource,
21+
IterableInAppLocation,
22+
IterableInAppManager,
23+
IterableInAppMessage,
24+
IterableInAppShowResponse,
25+
IterableInAppTrigger,
26+
IterableInAppTriggerType,
27+
IterableInbox,
28+
IterableInboxDataModel,
29+
IterableInboxEmptyState,
30+
IterableInboxMessageCell,
31+
IterableInboxMetadata,
32+
IterableLogLevel,
33+
IterableLogger,
34+
IterablePushPlatform,
35+
IterableRetryBackoff,
36+
useAppStateListener,
37+
useDeviceOrientation,
38+
} from '../index';
39+
40+
describe('public SDK surface', () => {
41+
it('exports the static facade', () => {
42+
expect(Iterable).toBeDefined();
43+
expect(typeof Iterable.initialize).toBe('function');
44+
});
45+
46+
it('exports core model classes', () => {
47+
expect(IterableAction).toBeDefined();
48+
expect(IterableActionContext).toBeDefined();
49+
expect(IterableAttributionInfo).toBeDefined();
50+
expect(IterableAuthResponse).toBeDefined();
51+
expect(IterableCommerceItem).toBeDefined();
52+
expect(IterableConfig).toBeDefined();
53+
expect(IterableEdgeInsets).toBeDefined();
54+
expect(IterableLogger).toBeDefined();
55+
});
56+
57+
it('exports core enums', () => {
58+
expect(IterableActionSource).toBeDefined();
59+
expect(IterableAuthFailureReason).toBeDefined();
60+
expect(IterableAuthResponseResult).toBeDefined();
61+
expect(IterableDataRegion).toBeDefined();
62+
expect(IterableLogLevel).toBeDefined();
63+
expect(IterablePushPlatform).toBeDefined();
64+
expect(IterableRetryBackoff).toBeDefined();
65+
});
66+
67+
it('exports in-app model classes and enums', () => {
68+
expect(IterableHtmlInAppContent).toBeDefined();
69+
expect(IterableInAppManager).toBeDefined();
70+
expect(IterableInAppMessage).toBeDefined();
71+
expect(IterableInAppTrigger).toBeDefined();
72+
expect(IterableInboxMetadata).toBeDefined();
73+
expect(IterableInAppCloseSource).toBeDefined();
74+
expect(IterableInAppContentType).toBeDefined();
75+
expect(IterableInAppDeleteSource).toBeDefined();
76+
expect(IterableInAppLocation).toBeDefined();
77+
expect(IterableInAppShowResponse).toBeDefined();
78+
expect(IterableInAppTriggerType).toBeDefined();
79+
});
80+
81+
it('exports inbox components and types', () => {
82+
expect(IterableInbox).toBeDefined();
83+
expect(IterableInboxDataModel).toBeDefined();
84+
expect(IterableInboxEmptyState).toBeDefined();
85+
expect(IterableInboxMessageCell).toBeDefined();
86+
});
87+
88+
it('exports embedded messaging surface', () => {
89+
expect(IterableEmbeddedManager).toBeDefined();
90+
expect(IterableEmbeddedView).toBeDefined();
91+
expect(IterableEmbeddedViewType).toBeDefined();
92+
});
93+
94+
it('exports hooks', () => {
95+
expect(useAppStateListener).toBeDefined();
96+
expect(useDeviceOrientation).toBeDefined();
97+
});
98+
99+
describe('exported enum values', () => {
100+
it('IterableActionSource contains expected members', () => {
101+
expect(IterableActionSource.push).toBe(0);
102+
expect(IterableActionSource.appLink).toBe(1);
103+
expect(IterableActionSource.inApp).toBe(2);
104+
expect(IterableActionSource.embedded).toBe(3);
105+
});
106+
107+
it('IterableInAppCloseSource contains expected members', () => {
108+
expect(IterableInAppCloseSource.back).toBe(0);
109+
expect(IterableInAppCloseSource.link).toBe(1);
110+
expect(IterableInAppCloseSource.unknown).toBe(100);
111+
});
112+
113+
it('IterableInAppLocation contains expected members', () => {
114+
expect(IterableInAppLocation.inApp).toBe(0);
115+
expect(IterableInAppLocation.inbox).toBe(1);
116+
});
117+
118+
it('IterableInAppShowResponse contains expected members', () => {
119+
expect(IterableInAppShowResponse.show).toBe(0);
120+
expect(IterableInAppShowResponse.skip).toBe(1);
121+
});
122+
123+
it('IterableInAppTriggerType contains expected members', () => {
124+
expect(IterableInAppTriggerType.immediate).toBe(0);
125+
expect(IterableInAppTriggerType.event).toBe(1);
126+
expect(IterableInAppTriggerType.never).toBe(2);
127+
});
128+
129+
it('IterableDataRegion contains expected members', () => {
130+
expect(IterableDataRegion.US).toBe(0);
131+
expect(IterableDataRegion.EU).toBe(1);
132+
});
133+
134+
it('IterableLogLevel contains expected members', () => {
135+
expect(IterableLogLevel.error).toBe(3);
136+
expect(IterableLogLevel.debug).toBe(1);
137+
expect(IterableLogLevel.info).toBe(2);
138+
});
139+
140+
it('IterablePushPlatform contains expected members', () => {
141+
expect(IterablePushPlatform.sandbox).toBe(0);
142+
expect(IterablePushPlatform.production).toBe(1);
143+
expect(IterablePushPlatform.auto).toBe(2);
144+
});
145+
146+
it('IterableRetryBackoff contains expected members', () => {
147+
expect(IterableRetryBackoff.linear).toBe('LINEAR');
148+
expect(IterableRetryBackoff.exponential).toBe('EXPONENTIAL');
149+
});
150+
151+
it('IterableEmbeddedViewType contains expected members', () => {
152+
expect(IterableEmbeddedViewType.Banner).toBe(0);
153+
expect(IterableEmbeddedViewType.Card).toBe(1);
154+
expect(IterableEmbeddedViewType.Notification).toBe(2);
155+
});
156+
});
157+
158+
describe('exported hooks are functions', () => {
159+
it('useAppStateListener is a function', () => {
160+
expect(typeof useAppStateListener).toBe('function');
161+
});
162+
163+
it('useDeviceOrientation is a function', () => {
164+
expect(typeof useDeviceOrientation).toBe('function');
165+
});
166+
});
167+
168+
describe('exported components are valid React components', () => {
169+
it('IterableInbox is a valid React component', () => {
170+
expect(IterableInbox).toBeDefined();
171+
// React components are functions or classes (forwardRef objects expose a render fn)
172+
const type = typeof IterableInbox;
173+
expect(
174+
type === 'function' ||
175+
type === 'object' ||
176+
type === 'symbol'
177+
).toBe(true);
178+
});
179+
180+
it('IterableInboxEmptyState is a valid React component', () => {
181+
expect(IterableInboxEmptyState).toBeDefined();
182+
const type = typeof IterableInboxEmptyState;
183+
expect(
184+
type === 'function' ||
185+
type === 'object' ||
186+
type === 'symbol'
187+
).toBe(true);
188+
});
189+
190+
it('IterableInboxMessageCell is a valid React component', () => {
191+
expect(IterableInboxMessageCell).toBeDefined();
192+
const type = typeof IterableInboxMessageCell;
193+
expect(
194+
type === 'function' ||
195+
type === 'object' ||
196+
type === 'symbol'
197+
).toBe(true);
198+
});
199+
200+
it('IterableEmbeddedView is a valid React component', () => {
201+
expect(IterableEmbeddedView).toBeDefined();
202+
const type = typeof IterableEmbeddedView;
203+
expect(
204+
type === 'function' ||
205+
type === 'object' ||
206+
type === 'symbol'
207+
).toBe(true);
208+
});
209+
});
3210
});

0 commit comments

Comments
 (0)