1+ /* eslint-disable */
2+ /**
3+ * Mock for react-native-mparticle
4+ * This mock provides a simple API that mimics the essential functionality
5+ */
6+
7+ // Mock classes
8+ class User {
9+ constructor ( userId ) {
10+ this . userId = userId ;
11+ }
12+
13+ getMpid ( ) {
14+ return this . userId ;
15+ }
16+
17+ setUserAttribute ( ) { }
18+ getUserAttributes ( callback ) {
19+ callback ( { testAttribute : 'testValue' } ) ;
20+ }
21+ setUserTag ( ) { }
22+ incrementUserAttribute ( ) { }
23+ removeUserAttribute ( ) { }
24+ getUserIdentities ( callback ) {
25+ callback ( { email : 'test@example.com' } ) ;
26+ }
27+ getFirstSeen ( callback ) {
28+ callback ( Date . now ( ) - 86400000 ) ;
29+ }
30+ getLastSeen ( callback ) {
31+ callback ( Date . now ( ) ) ;
32+ }
33+ }
34+
35+ class IdentityRequest {
36+ setEmail ( email ) {
37+ this . email = email ;
38+ return this ;
39+ }
40+
41+ setCustomerID ( customerId ) {
42+ this . customerId = customerId ;
43+ return this ;
44+ }
45+
46+ setUserIdentity ( userIdentity , identityType ) {
47+ this [ identityType ] = userIdentity ;
48+ return this ;
49+ }
50+ }
51+
52+ class Identity {
53+ static getCurrentUser ( completion ) {
54+ var currentUser = new User ( 'mockUserId123' ) ;
55+ completion ( currentUser ) ;
56+ }
57+
58+ static login ( request , completion ) {
59+ completion ( null , 'mockUserId123' , 'mockPreviousUserId456' ) ;
60+ }
61+
62+ static logout ( request , completion ) {
63+ completion ( null , 'mockUserId123' ) ;
64+ }
65+
66+ static identify ( request , completion ) {
67+ completion ( null , 'mockUserId123' , 'mockPreviousUserId456' ) ;
68+ }
69+
70+ static modify ( request , completion ) {
71+ completion ( null , 'mockUserId123' , 'mockPreviousUserId456' ) ;
72+ }
73+
74+ static aliasUsers ( request , completion ) {
75+ completion ( true , null ) ;
76+ }
77+ }
78+
79+ class Product {
80+ constructor ( name , sku , price , quantity = 1 ) {
81+ this . name = name ;
82+ this . sku = sku ;
83+ this . price = price ;
84+ this . quantity = quantity ;
85+ }
86+ }
87+
88+ class TransactionAttributes {
89+ constructor ( transactionId ) {
90+ this . transactionId = transactionId ;
91+ }
92+ }
93+
94+ class CommerceEvent {
95+ static createProductActionEvent ( productActionType , products , transactionAttributes ) {
96+ return new CommerceEvent ( ) ;
97+ }
98+ }
99+
100+ class AliasRequest {
101+ sourceMpid ( mpid ) {
102+ this . sourceMpid = mpid ;
103+ return this ;
104+ }
105+
106+ destinationMpid ( mpid ) {
107+ this . destinationMpid = mpid ;
108+ return this ;
109+ }
110+
111+ startTime ( time ) {
112+ this . startTime = time ;
113+ return this ;
114+ }
115+
116+ endTime ( time ) {
117+ this . endTime = time ;
118+ return this ;
119+ }
120+ }
121+
122+ // Mock Rokt
123+ const Rokt = {
124+ selectPlacements : ( ) => Promise . resolve ( )
125+ } ;
126+
127+ // Constants
128+ const EventType = {
129+ Navigation : 1 ,
130+ Location : 2 ,
131+ Search : 3 ,
132+ Transaction : 4 ,
133+ UserContent : 5 ,
134+ UserPreference : 6 ,
135+ Social : 7 ,
136+ Other : 8 ,
137+ Media : 9
138+ } ;
139+
140+ const UserIdentityType = {
141+ Email : 7 ,
142+ CustomerId : 1 ,
143+ Alias : 8
144+ } ;
145+
146+ const ProductActionType = {
147+ AddToCart : 1 ,
148+ RemoveFromCart : 2 ,
149+ Checkout : 3 ,
150+ Purchase : 7
151+ } ;
152+
153+ // Main mock object
154+ const MParticle = {
155+ // Classes
156+ User,
157+ IdentityRequest,
158+ Identity,
159+ Product,
160+ TransactionAttributes,
161+ CommerceEvent,
162+ AliasRequest,
163+ Rokt,
164+
165+ // Constants
166+ EventType,
167+ UserIdentityType,
168+ ProductActionType,
169+
170+ // Methods
171+ logEvent : ( ) => { } ,
172+ logCommerceEvent : ( ) => { } ,
173+ logPushRegistration : ( ) => { } ,
174+ getSession : ( callback ) => callback ( { sessionId : 'mockSessionId123' } ) ,
175+ setOptOut : ( ) => { } ,
176+ getOptOut : ( callback ) => callback ( false ) ,
177+ isKitActive : ( kitId , callback ) => callback ( true ) ,
178+ getAttributions : ( callback ) => callback ( { attributionResults : 'mock results' } ) ,
179+ upload : ( ) => { } ,
180+ setUploadInterval : ( ) => { } ,
181+ setLocation : ( ) => { }
182+ } ;
183+
184+ module . exports = MParticle ;
0 commit comments