@blueconic/blueconic-react-native 3.2.3 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,7 @@ import com.facebook.react.bridge.NativeModule;
10
10
  import com.facebook.react.bridge.ReactApplicationContext;
11
11
  import com.facebook.react.uimanager.ViewManager;
12
12
  import com.facebook.react.bridge.JavaScriptModule;
13
+
13
14
  public class BlueConicClientPackage implements ReactPackage {
14
15
 
15
16
  @Override
@@ -5,8 +5,8 @@ import java.util.HashMap;
5
5
  import java.util.Map;
6
6
 
7
7
  import com.blueconic.BlueConicClient;
8
- import com.blueconic.BlueConicClient.InteractionContext;
9
- import com.blueconic.BlueConicClient.Plugin;
8
+ import com.blueconic.InteractionContext;
9
+ import com.blueconic.Plugin;
10
10
 
11
11
  /**
12
12
  * The BlueConicInteraction class is a custom BlueConic plugin that receives parameters from the BlueConic backend
@@ -21,7 +21,8 @@ public class BlueConicInteraction implements Plugin {
21
21
  /**
22
22
  * Called by the BlueConic SDK for Android when a dialogue of this type is configured to be present on the current
23
23
  * screen.
24
- * @param client the BlueConicClient
24
+ *
25
+ * @param client the BlueConicClient
25
26
  * @param context the InteractionContext of the interaction plugin
26
27
  */
27
28
  @Override
@@ -51,7 +52,7 @@ public class BlueConicInteraction implements Plugin {
51
52
 
52
53
  this.properties = properties;
53
54
 
54
- if (this.properties != null && interactionId != null) {
55
+ if (interactionId != null) {
55
56
  BlueConicClientModule.publishDialogueEvent(this.properties, "onBlueConicPluginLoad");
56
57
  }
57
58
  }
@@ -0,0 +1,649 @@
1
+ package com.blueconic.reactnative
2
+
3
+ import android.app.Activity
4
+ import android.os.Handler
5
+ import android.os.Looper
6
+ import android.os.SystemClock
7
+ import com.blueconic.BlueConicClient
8
+ import com.blueconic.Segment
9
+ import com.blueconic.impl.BlueConicClientImpl
10
+ import com.blueconic.reactnative.utils.MockCallback
11
+ import com.blueconic.reactnative.utils.MockPromise
12
+ import com.blueconic.reactnative.utils.MockWritableArray
13
+ import com.blueconic.reactnative.utils.MockWritableMap
14
+ import com.facebook.react.bridge.Callback
15
+ import com.facebook.react.bridge.Promise
16
+ import com.facebook.react.bridge.ReactApplicationContext
17
+ import com.facebook.react.bridge.WritableArray
18
+ import com.facebook.react.bridge.WritableMap
19
+ import io.mockk.MockKAnnotations
20
+ import io.mockk.every
21
+ import io.mockk.impl.annotations.MockK
22
+ import io.mockk.mockk
23
+ import io.mockk.mockkStatic
24
+ import io.mockk.verify
25
+ import org.junit.Assert.assertEquals
26
+ import org.junit.Before
27
+ import org.junit.Test
28
+ import java.util.Date
29
+
30
+
31
+ class BlueConicClientModuleTests {
32
+ @MockK
33
+ lateinit var reactContext: ReactApplicationContext
34
+ @MockK
35
+ lateinit var blueConicClient: BlueConicClientImpl
36
+
37
+ private lateinit var module: BlueConicClientModule
38
+
39
+ @Before
40
+ fun setUp() {
41
+ MockKAnnotations.init(this, relaxed = true)
42
+
43
+ mockkStatic(Looper::class)
44
+ val mockLooper = mockk<Looper>(relaxed = true)
45
+ every { Looper.getMainLooper() } returns mockLooper
46
+
47
+ val mockHandler = mockk<Handler>(relaxed = true)
48
+
49
+ mockkStatic(SystemClock::class)
50
+ every { SystemClock.uptimeMillis() } returns 123456L
51
+
52
+ module = object : BlueConicClientModule(reactContext) {
53
+ override fun getBlueConicClientInstance(): BlueConicClient {
54
+ return blueConicClient
55
+ }
56
+ override fun getHandler(): Handler {
57
+ return mockHandler
58
+ }
59
+ override fun getWritableArray(): WritableArray {
60
+ return MockWritableArray()
61
+ }
62
+ override fun getWritableMap(): WritableMap {
63
+ return MockWritableMap()
64
+ }
65
+ }
66
+ }
67
+
68
+ @Test
69
+ fun `getProfileId should resolve with profile ID`() {
70
+ // Given
71
+ val promise = mockk<Promise>(relaxed = true)
72
+ val expectedProfileId = "testProfileId"
73
+
74
+ every { blueConicClient.profileId } returns expectedProfileId
75
+
76
+ // When
77
+ module.getProfileIdAsync(promise)
78
+
79
+ // Then
80
+ verify { promise.resolve(expectedProfileId) }
81
+ }
82
+
83
+ @Test
84
+ fun `getProfileIdWithCallback should invoke callback with profile ID`() {
85
+ // Given
86
+ val callback = mockk<Callback>(relaxed = true)
87
+ val expectedProfileId = "testProfileId"
88
+ every { blueConicClient.profileId } returns expectedProfileId
89
+
90
+ // When
91
+ module.getProfileIdWithCallback(callback)
92
+
93
+ // Then
94
+ verify { callback.invoke(expectedProfileId) }
95
+ }
96
+
97
+ @Test
98
+ fun `getProfileValue should resolve promise with value`() {
99
+ // Given
100
+ val property = "testProperty"
101
+ val value = "testValue"
102
+ every { blueConicClient.getProfileValues(property) } returns listOf(value)
103
+ val expectedValue = MockWritableArray().apply { pushString(value) }
104
+ // When
105
+ module.getProfileValuesAsync(property, object : MockPromise() {
106
+ override fun resolve(values: Any?) {
107
+ //Then
108
+ val result = values as MockWritableArray
109
+ assertEquals(result.toArrayList()[0], expectedValue.toArrayList()[0])
110
+ }
111
+ })
112
+ }
113
+
114
+ @Test
115
+ fun `getProfileValue should invoke callback with value`() {
116
+ // Given
117
+ val property = "testProperty"
118
+ val value = "testValue"
119
+ every { blueConicClient.getProfileValue(property) } returns value
120
+ val expectedValue = MockWritableArray().apply { pushString(value) }
121
+ // When
122
+ module.getProfileValueWithCallback(property, object : MockCallback() {
123
+ override fun invoke(vararg args: Any?) {
124
+ val result = args[0] as MockWritableArray
125
+ assertEquals(result.toArrayList()[0], expectedValue.toArrayList()[0])
126
+ }
127
+ })
128
+ }
129
+
130
+
131
+ @Test
132
+ fun `getProfileValues should resolve promise with value`() {
133
+ // Given
134
+ val property = "testProperty"
135
+ val value = listOf("testValue1", "testValue2")
136
+ every { blueConicClient.getProfileValues(property) } returns value
137
+ val expectedValue = MockWritableArray().apply { pushArray(module.fromList(value)) }
138
+ // When
139
+ module.getProfileValuesAsync(property, object : MockPromise() {
140
+ override fun resolve(values: Any?) {
141
+ //Then
142
+ val result = values as MockWritableArray
143
+ assertEquals(result.toArrayList()[0], expectedValue.toArrayList()[0])
144
+ assertEquals(result.toArrayList()[1], expectedValue.toArrayList()[1])
145
+ }
146
+ })
147
+ }
148
+
149
+ @Test
150
+ fun `getProfileValues should invoke callback with value`() {
151
+ // Given
152
+ val property = "testProperty"
153
+ val value = listOf("testValue1", "testValue2")
154
+ every { blueConicClient.getProfileValues(property) } returns value
155
+ val expectedValue = MockWritableArray().apply { pushArray(module.fromList(value)) }
156
+ // When
157
+ module.getProfileValuesWithCallback(property, object : MockCallback() {
158
+ override fun invoke(vararg args: Any?) {
159
+ val result = args[0] as MockWritableArray
160
+ assertEquals(result.toArrayList()[0], expectedValue.toArrayList()[0])
161
+ assertEquals(result.toArrayList()[1], expectedValue.toArrayList()[1])
162
+ }
163
+ })
164
+ }
165
+
166
+ @Test
167
+ fun `getAllProfilePropertiesAsync should resolve promise with values`() {
168
+ // Given
169
+ val propertyNames = listOf("testProperty1", "testProperty2")
170
+ val propertyValue = listOf("testValue1", "testValue2")
171
+ every { blueConicClient.profilePropertyNames } returns propertyNames
172
+ every { blueConicClient.getProfileValues(propertyNames[0]) } returns listOf(propertyValue[0])
173
+ every { blueConicClient.getProfileValues(propertyNames[1]) } returns listOf(propertyValue[1])
174
+ val expectedValue = MockWritableArray()
175
+ for (name in propertyNames) {
176
+ val valuesMap = MockWritableMap().apply {
177
+ putString("id", name)
178
+ putString("value", propertyValue[propertyNames.indexOf(name)])
179
+ }
180
+ expectedValue.pushMap(valuesMap)
181
+ }
182
+ // When
183
+ module.getAllProfilePropertiesAsync(object : MockPromise() {
184
+ override fun resolve(values: Any?) {
185
+ //Then
186
+ val result = values as MockWritableArray
187
+ val test1 = result.toArrayList()[0] as MockWritableMap
188
+ val test2 = result.toArrayList()[1] as MockWritableMap
189
+ assertEquals(test1.getString("id"), propertyNames[0])
190
+ assertEquals(test1.getString("value"), propertyValue[0])
191
+ assertEquals(test2.getString("id"), propertyNames[1])
192
+ assertEquals(test2.getString("value"), propertyValue[1])
193
+ }
194
+ })
195
+ }
196
+
197
+ @Test
198
+ fun `getPrivacyLegislation should resolve promise with value`() {
199
+ // Given
200
+ val value = "GDPR"
201
+ every { blueConicClient.privacyLegislation } returns value
202
+ val expectedValue = MockWritableArray().apply { pushString(value) }
203
+ // When
204
+ module.getPrivacyLegislationAsync(object : MockPromise() {
205
+ override fun resolve(values: Any?) {
206
+ //Then
207
+ val result = values as MockWritableArray
208
+ assertEquals(result.toArrayList()[0], expectedValue.toArrayList()[0])
209
+ }
210
+ })
211
+ }
212
+
213
+ @Test
214
+ fun `getPrivacyLegislation should invoke callback with value`() {
215
+ // Given
216
+ val value = "GDPR"
217
+ every { blueConicClient.privacyLegislation } returns value
218
+ val expectedValue = MockWritableArray().apply { pushString(value) }
219
+ // When
220
+ module.getPrivacyLegislationWithCallback(object : MockCallback() {
221
+ override fun invoke(vararg args: Any?) {
222
+ val result = args[0] as MockWritableArray
223
+ assertEquals(result.toArrayList()[0], expectedValue.toArrayList()[0])
224
+ }
225
+ })
226
+ }
227
+
228
+ @Test
229
+ fun `getConsentedObjectives should resolve promise with value`() {
230
+ // Given
231
+ val value = listOf("tracking")
232
+ every { blueConicClient.consentedObjectives } returns value
233
+ val expectedValue = MockWritableArray().apply { pushArray(module.fromList(value)) }
234
+ // When
235
+ module.getConsentedObjectivesAsync(object : MockPromise() {
236
+ override fun resolve(values: Any?) {
237
+ //Then
238
+ val result = values as MockWritableArray
239
+ assertEquals(result.toArrayList()[0], expectedValue.toArrayList()[0])
240
+ }
241
+ })
242
+ }
243
+
244
+ @Test
245
+ fun `getConsentedObjectives should invoke callback with value`() {
246
+ // Given
247
+ val value = listOf("tracking")
248
+ every { blueConicClient.consentedObjectives } returns value
249
+ val expectedValue = MockWritableArray().apply { pushArray(module.fromList(value)) }
250
+ // When
251
+ module.getConsentedObjectivesWithCallback(object : MockCallback() {
252
+ override fun invoke(vararg args: Any?) {
253
+ val result = args[0] as MockWritableArray
254
+ assertEquals(result.toArrayList()[0], expectedValue.toArrayList()[0])
255
+ }
256
+ })
257
+ }
258
+
259
+ @Test
260
+ fun `getRefusedObjectives should resolve promise with value`() {
261
+ // Given
262
+ val value = listOf("analytics")
263
+ every { blueConicClient.refusedObjectives } returns value
264
+ val expectedValue = MockWritableArray().apply { pushArray(module.fromList(value)) }
265
+ // When
266
+ module.getRefusedObjectivesAsync(object : MockPromise() {
267
+ override fun resolve(values: Any?) {
268
+ //Then
269
+ val result = values as MockWritableArray
270
+ assertEquals(result.toArrayList()[0], expectedValue.toArrayList()[0])
271
+ }
272
+ })
273
+ }
274
+
275
+ @Test
276
+ fun `getRefusedObjectives should invoke callback with value`() {
277
+ // Given
278
+ val value = listOf("analytics")
279
+ every { blueConicClient.refusedObjectives } returns value
280
+ val expectedValue = MockWritableArray().apply { pushArray(module.fromList(value)) }
281
+ // When
282
+ module.getRefusedObjectivesWithCallback(object : MockCallback() {
283
+ override fun invoke(vararg args: Any?) {
284
+ val result = args[0] as MockWritableArray
285
+ assertEquals(result.toArrayList()[0], expectedValue.toArrayList()[0])
286
+ }
287
+ })
288
+ }
289
+
290
+ @Test
291
+ fun `setLocale should set locale`() {
292
+ // Given
293
+ val locale = "en_US"
294
+ // When
295
+ module.setLocale(locale)
296
+ // Then
297
+ verify { blueConicClient.setLocale(locale) }
298
+ }
299
+
300
+ @Test
301
+ fun `getSegments should resolve promise with values`() {
302
+ // Given
303
+ val segments = mutableListOf<Segment>(object : Segment {
304
+ override val id: String = "segment1"
305
+ override val name: String = "NL"
306
+ })
307
+ every { blueConicClient.segments } returns segments
308
+ val expectedValue = MockWritableArray()
309
+ for (segment in segments) {
310
+ val valuesMap = MockWritableMap().apply {
311
+ putString("id", segment.id)
312
+ putString("name", segment.name)
313
+ }
314
+ expectedValue.pushMap(valuesMap)
315
+ }
316
+ // When
317
+ module.getSegments(object : MockPromise() {
318
+ override fun resolve(values: Any?) {
319
+ //Then
320
+ val result = values as MockWritableArray
321
+ val test1 = result.toArrayList()[0] as MockWritableMap
322
+ assertEquals(test1.getString("id"), segments[0].id)
323
+ assertEquals(test1.getString("name"), segments[0].name)
324
+ }
325
+ })
326
+ }
327
+
328
+ @Test
329
+ fun `getSegments should invoke callback with values`() {
330
+ // Given
331
+ val segments = mutableListOf<Segment>(object : Segment {
332
+ override val id: String
333
+ get() = "segment1"
334
+ override val name: String
335
+ get() = "NL"
336
+ })
337
+ every { blueConicClient.segments } returns segments
338
+ val expectedValue = MockWritableArray()
339
+ for (segment in segments) {
340
+ val valuesMap = MockWritableMap().apply {
341
+ putString("id", segment.id)
342
+ putString("name", segment.name)
343
+ }
344
+ expectedValue.pushMap(valuesMap)
345
+ }
346
+ // When
347
+ module.getSegmentsWithCallback(object : MockCallback() {
348
+ override fun invoke(vararg args: Any?) {
349
+ //Then
350
+ val result = args[0] as MockWritableArray
351
+ val test1 = result.toArrayList()[0] as MockWritableMap
352
+ assertEquals(test1.getString("id"), segments[0].id)
353
+ assertEquals(test1.getString("name"), segments[0].name)
354
+ }
355
+ })
356
+ }
357
+
358
+ @Test
359
+ fun `addProfileValue should add value to profile`() {
360
+ // Given
361
+ val property = "testProperty"
362
+ val value = "testValue"
363
+ // When
364
+ module.addProfileValue(property, value)
365
+ // Then
366
+ verify { blueConicClient.addProfileValue(property, value) }
367
+ }
368
+
369
+ @Test
370
+ fun `addProfileValues should add values to profile`() {
371
+ // Given
372
+ val property = "testProperty"
373
+ val value = MockWritableArray().apply { pushString("testValue") }
374
+ // When
375
+ module.addProfileValues(property, value)
376
+ // Then
377
+ verify { blueConicClient.addProfileValues(property, any()) }
378
+ }
379
+
380
+ @Test
381
+ fun `setProfileValue should add value to profile`() {
382
+ // Given
383
+ val property = "testProperty"
384
+ val value = "testValue"
385
+ // When
386
+ module.setProfileValue(property, value)
387
+ // Then
388
+ verify { blueConicClient.setProfileValue(property, value) }
389
+ }
390
+
391
+ @Test
392
+ fun `setProfileValues should set values to profile`() {
393
+ // Given
394
+ val property = "testProperty"
395
+ val value = MockWritableArray().apply { pushString("testValue") }
396
+ // When
397
+ module.setProfileValues(property, value)
398
+ // Then
399
+ verify { blueConicClient.setProfileValues(property, any()) }
400
+ }
401
+
402
+ @Test
403
+ fun `incrementProfileValue should increment value to profile`() {
404
+ // Given
405
+ val property = "testProperty"
406
+ val value = "testValue"
407
+ // When
408
+ module.incrementProfileValue(property, value)
409
+ // Then
410
+ verify { blueConicClient.incrementProfileValue(property, value) }
411
+ }
412
+
413
+ @Test
414
+ fun `createEvent should send an event to platform`() {
415
+ // Given
416
+ val event = "testEvent"
417
+ val properties = MockWritableMap().apply { putString("testProperty", "testValue") }
418
+ // When
419
+ module.createEvent(event, properties)
420
+ // Then
421
+ verify { blueConicClient.createEvent(event, any(), any(), any()) }
422
+ }
423
+
424
+ @Test
425
+ fun `createEventAsync should send an event to platform and resolve promise`() {
426
+ // Given
427
+ val event = "testEvent"
428
+ val properties = MockWritableMap().apply { putString("testProperty", "testValue") }
429
+ // When
430
+ module.createEventAsync(event, properties, MockPromise())
431
+ // Then
432
+ verify { blueConicClient.createEvent(event, any(), any(), any()) }
433
+ }
434
+
435
+ @Test
436
+ fun `createEventWithCallback should send an event to platform and invoke callback`() {
437
+ // Given
438
+ val event = "testEvent"
439
+ val properties = MockWritableMap().apply { putString("testProperty", "testValue") }
440
+ // When
441
+ module.createEventWithCallback(event, properties, MockCallback())
442
+ // Then
443
+ verify { blueConicClient.createEvent(event, any(), any(), any()) }
444
+ }
445
+
446
+ @Test
447
+ fun `updateProfile should call profile update`() {
448
+ // When
449
+ module.updateProfile()
450
+ // Then
451
+ verify { blueConicClient.updateProfile() }
452
+ }
453
+
454
+ @Test
455
+ fun `updateProfileAsync should call profile update and resolve promise`() {
456
+ // When
457
+ module.updateProfileAsync(MockPromise())
458
+ // Then
459
+ verify { blueConicClient.updateProfile(any()) }
460
+ }
461
+
462
+ @Test
463
+ fun `updateProfileWithCallback should call profile update and invoke callback`() {
464
+ // When
465
+ module.updateProfileWithCallback(MockCallback())
466
+ // Then
467
+ verify { blueConicClient.updateProfile(any()) }
468
+ }
469
+
470
+ @Test
471
+ fun `createPageViewEvent should send a PAGEVIEW event to platform`() {
472
+ // Given
473
+ val screen = "screenName"
474
+ // When
475
+ module.createPageViewEvent(screen, MockWritableMap())
476
+ // Then
477
+ verify { blueConicClient.createPageViewEvent(screen, any<Activity>(), any<HashMap<String, String>>(), any()) }
478
+ }
479
+
480
+ @Test
481
+ fun `createPageViewEventAsync should send a PAGEVIEW event to platform and resolve promise`() {
482
+ // Given
483
+ val screen = "screenName"
484
+ // When
485
+ module.createPageViewEventAsync(screen, MockWritableMap(), MockPromise())
486
+ // Then
487
+ verify { blueConicClient.createPageViewEvent(screen, any<Activity>(), any<HashMap<String, String>>(), any()) }
488
+ }
489
+
490
+ @Test
491
+ fun `createPageViewEventWithCallback should send a PAGEVIEW event to platform and invoke callback`() {
492
+ // Given
493
+ val screen = "screenName"
494
+ // When
495
+ module.createPageViewEventWithCallback(screen, MockWritableMap(), MockCallback())
496
+ // Then
497
+ verify { blueConicClient.createPageViewEvent(screen, any<Activity>(), any<HashMap<String, String>>(), any()) }
498
+ }
499
+
500
+ @Test
501
+ fun `createTimelineEvent should send a timeline event to platform`() {
502
+ // Given
503
+ val timelineEventType = "event"
504
+ val properties = MockWritableMap().apply { putString("testProperty", "testValue") }
505
+ val dateTime = Date().time
506
+ // When
507
+ module.createTimelineEvent(timelineEventType, dateTime.toDouble(), properties)
508
+ // Then
509
+ verify { blueConicClient.createTimelineEvent(timelineEventType, Date(dateTime), any<HashMap<String, Any>>(), null) }
510
+ }
511
+
512
+ @Test
513
+ fun `createTimelineEventAsync should send a timeline event to platform and resolve promise`() {
514
+ // Given
515
+ val timelineEventType = "event"
516
+ val properties = MockWritableMap().apply { putString("testProperty", "testValue") }
517
+ val dateTime = Date().time
518
+ // When
519
+ module.createTimelineEventAsync(timelineEventType, dateTime.toDouble(), properties, MockPromise())
520
+ // Then
521
+ verify { blueConicClient.createTimelineEvent(timelineEventType, Date(dateTime), any<HashMap<String, Any>>(), any()) }
522
+ }
523
+
524
+ @Test
525
+ fun `createTimelineEventWithCallback should send a timeline event to platform and invoke callback`() {
526
+ // Given
527
+ val timelineEventType = "event"
528
+ val properties = MockWritableMap().apply { putString("testProperty", "testValue") }
529
+ val dateTime = Date().time
530
+ // When
531
+ module.createTimelineEventWithCallback(timelineEventType, dateTime.toDouble(), properties, MockCallback())
532
+ // Then
533
+ verify { blueConicClient.createTimelineEvent(timelineEventType, Date(dateTime), any<HashMap<String, Any>>(), any()) }
534
+ }
535
+
536
+ @Test
537
+ fun `createTimelineEventById should send a timeline event to platform`() {
538
+ // Given
539
+ val timelineId = "id"
540
+ val timelineEventType = "event"
541
+ val properties = MockWritableMap().apply { putString("testProperty", "testValue") }
542
+ val dateTime = Date().time
543
+ // When
544
+ module.createTimelineEventById(timelineId, timelineEventType, dateTime.toDouble(), properties)
545
+ // Then
546
+ verify { blueConicClient.createTimelineEventById(timelineId, timelineEventType, Date(dateTime), any<HashMap<String, Any>>(), null) }
547
+ }
548
+
549
+ @Test
550
+ fun `createTimelineEventByIdAsync should send a timeline event to platform and resolve promise`() {
551
+ // Given
552
+ val timelineId = "id"
553
+ val timelineEventType = "event"
554
+ val properties = MockWritableMap().apply { putString("testProperty", "testValue") }
555
+ val dateTime = Date().time
556
+ // When
557
+ module.createTimelineEventByIdAsync(timelineId, timelineEventType, dateTime.toDouble(), properties, MockPromise())
558
+ // Then
559
+ verify { blueConicClient.createTimelineEventById(timelineId, timelineEventType, Date(dateTime), any<HashMap<String, Any>>(), any()) }
560
+ }
561
+
562
+ @Test
563
+ fun `createTimelineEventByIdWithCallback should send a timeline event to platform and invoke callback`() {
564
+ // Given
565
+ val timelineId = "id"
566
+ val timelineEventType = "event"
567
+ val properties = MockWritableMap().apply { putString("testProperty", "testValue") }
568
+ val dateTime = Date().time
569
+ // When
570
+ module.createTimelineEventByIdWithCallback(timelineId, timelineEventType, dateTime.toDouble(), properties, MockCallback())
571
+ // Then
572
+ verify { blueConicClient.createTimelineEventById(timelineId, timelineEventType, Date(dateTime), any<HashMap<String, Any>>(), any()) }
573
+ }
574
+
575
+ @Test
576
+ fun `publishClickEvent should send a click event to platform`() {
577
+ // Given
578
+ val selector = "selector"
579
+ // When
580
+ module.publishClickEvent(selector, null)
581
+ // Then
582
+ verify { blueConicClient.eventManager.publishClickEvent(any()) }
583
+ }
584
+
585
+ @Test
586
+ fun `publishClickEventWithContext should send a click event to platform`() {
587
+ // Given
588
+ val selector = "selector"
589
+ val context = MockWritableArray().apply { pushString("context") }
590
+ // When
591
+ module.publishClickEvent(selector, context)
592
+ // Then
593
+ verify { blueConicClient.eventManager.publishClickEvent(any(), any()) }
594
+ }
595
+
596
+ @Test
597
+ fun `publishFormSubmitEvent should send a form submit event to platform`() {
598
+ // Given
599
+ val selector = "selector"
600
+ // When
601
+ module.publishFormSubmitEvent(selector, null)
602
+ // Then
603
+ verify { blueConicClient.eventManager.publishFormSubmitEvent(any()) }
604
+ }
605
+
606
+ @Test
607
+ fun `publishFormSubmitEventWithContext should send a click event to platform`() {
608
+ // Given
609
+ val selector = "selector"
610
+ val context = MockWritableArray().apply { pushString("context") }
611
+ // When
612
+ module.publishFormSubmitEvent(selector, context)
613
+ // Then
614
+ verify { blueConicClient.eventManager.publishFormSubmitEvent(any(), any()) }
615
+ }
616
+
617
+ @Test
618
+ fun `publishUpdateContentEvent should send a update content event to platform`() {
619
+ // Given
620
+ val selector = "selector"
621
+ val value = "value"
622
+ // When
623
+ module.publishUpdateContentEvent(selector, value)
624
+ // Then
625
+ verify { blueConicClient.eventManager.publishUpdateContentEvent(any(), any()) }
626
+ }
627
+
628
+ @Test
629
+ fun `publishUpdateValuesEvent should send a update values event to platform`() {
630
+ // Given
631
+ val selector = "selector"
632
+ val value = "value"
633
+ // When
634
+ module.publishUpdateContentEvent(selector, value)
635
+ // Then
636
+ verify { blueConicClient.eventManager.publishUpdateContentEvent(any(), any()) }
637
+ }
638
+
639
+ @Test
640
+ fun `publishAdvancedEvent should send a advanced event to platform`() {
641
+ // Given
642
+ val selector = "selector"
643
+ val context = MockWritableArray().apply { pushString("context") }
644
+ // When
645
+ module.publishAdvancedEvent(selector, context)
646
+ // Then
647
+ verify { blueConicClient.eventManager.publishAdvancedEvent(any(), any()) }
648
+ }
649
+ }
@@ -0,0 +1,8 @@
1
+ package com.blueconic.reactnative.utils
2
+
3
+ import com.facebook.react.bridge.Callback
4
+
5
+ open class MockCallback : Callback {
6
+ override fun invoke(vararg args: Any?) {
7
+ }
8
+ }