react-native-move-sdk 0.2.3 → 0.2.4

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.
@@ -28,15 +28,18 @@ fun String.toSnakeCase(): String {
28
28
  }
29
29
  }
30
30
 
31
- fun String.snakeToLowerCamelCase(): String {
32
- return snakeRegex.replace(this) {
33
- it.value.replace("_", "")
34
- .uppercase(Locale.getDefault())
35
- }
36
- }
37
-
38
31
  fun String.snakeToUpperCamelCase(): String {
39
- return this.snakeToLowerCamelCase().capitalize()
32
+ val camelCase = StringBuilder()
33
+ var prevChar = '_'
34
+ forEach {
35
+ if (prevChar == '_') {
36
+ camelCase.append(it.uppercase())
37
+ } else if (it != '_') {
38
+ camelCase.append(it.lowercaseChar())
39
+ }
40
+ prevChar = it
41
+ }
42
+ return camelCase.toString()
40
43
  }
41
44
 
42
45
  fun String.equalsService(service: MoveDetectionService): Boolean {
@@ -105,7 +105,7 @@ class NativeMoveSdkWrapper(private val context: Context) : MoveSdk.StateListener
105
105
 
106
106
  walkingServices.toArrayList().forEach {
107
107
  try {
108
- walkingServicesToUse.add(WalkingService.valueOf(it.toString().snakeToLowerCamelCase()))
108
+ walkingServicesToUse.add(WalkingService.valueOf(it.toString().snakeToUpperCamelCase()))
109
109
  } catch (t: Throwable) {
110
110
  t.printStackTrace()
111
111
  }
@@ -113,7 +113,7 @@ class NativeMoveSdkWrapper(private val context: Context) : MoveSdk.StateListener
113
113
 
114
114
  drivingServices.toArrayList().forEach {
115
115
  try {
116
- drivingServicesToUse.add(DrivingService.valueOf(it.toString().snakeToLowerCamelCase()))
116
+ drivingServicesToUse.add(DrivingService.valueOf(it.toString().snakeToUpperCamelCase()))
117
117
  } catch (t: Throwable) {
118
118
  t.printStackTrace()
119
119
  }
@@ -5,6 +5,7 @@ import `in`.dolph.move.sdk.EVENT_AUTH_OVERLAY_PERMISSION
5
5
  import `in`.dolph.move.sdk.MoveSdkModule
6
6
  import `in`.dolph.move.sdk.NativeMoveSdkWrapper
7
7
  import `in`.dolph.move.sdk.failuresToArray
8
+ import `in`.dolph.move.sdk.snakeToUpperCamelCase
8
9
  import `in`.dolph.move.sdk.toSnakeCase
9
10
  import android.content.Context
10
11
  import android.content.SharedPreferences
@@ -35,6 +36,38 @@ class MoveWrapperTest {
35
36
  fun teardown(): Unit {
36
37
  }
37
38
 
39
+ @Test
40
+ fun `test sdk walking service`(): Unit {
41
+
42
+ val walkingSnakeServices = arrayListOf("LOCATION")
43
+ val walkingServicesToUse = mutableListOf<WalkingService>()
44
+ walkingSnakeServices.forEach {
45
+ try {
46
+ walkingServicesToUse.add(WalkingService.valueOf(it.snakeToUpperCamelCase()))
47
+ } catch (t: Throwable) {
48
+ t.printStackTrace()
49
+ }
50
+ }
51
+
52
+ Assert.assertEquals(1, walkingServicesToUse.size)
53
+ }
54
+
55
+ @Test
56
+ fun `test sdk driving service`(): Unit {
57
+
58
+ val drivingSnakeServices = arrayListOf("DISTRACTION_FREE_DRIVING", "DRIVING_BEHAVIOUR")
59
+ val drivingServicesToUse = mutableListOf<DrivingService>()
60
+ drivingSnakeServices.forEach {
61
+ try {
62
+ drivingServicesToUse.add(DrivingService.valueOf(it.snakeToUpperCamelCase()))
63
+ } catch (t: Throwable) {
64
+ t.printStackTrace()
65
+ }
66
+ }
67
+
68
+ Assert.assertEquals(2, drivingServicesToUse.size)
69
+ }
70
+
38
71
  @Test
39
72
  fun `test sdk state snake case`(): Unit {
40
73
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-move-sdk",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "React Native library for MOVE SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",