-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from aminekarimii/test-core-analytiks-module
Test core analytiks module
- Loading branch information
Showing
5 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,4 +67,4 @@ class MixpanelAnalyticsClient( | |
override fun pushAll() { | ||
mixpanelClient.flush() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
analytiks-core/src/androidTest/java/com/analytiks/core/formatters/BundleFormatterTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.analytiks.core.formatters | ||
|
||
import com.analytiks.core.model.Param | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class BundleFormatterTest { | ||
private val bundleStrategy = BundleFormatStrategy() | ||
|
||
@Test | ||
fun testFormatProperties() { | ||
val properties = arrayOf( | ||
Param("property1", "value1"), | ||
Param("property2", "value2") | ||
) | ||
|
||
val result = bundleStrategy(*properties) | ||
|
||
assertEquals("value1", result.getString("property1")) | ||
assertEquals("value2", result.getString("property2")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
analytiks-core/src/test/java/com/analytiks/core/formatters/Formatters.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.analytiks.core.formatters | ||
|
||
import com.analytiks.core.model.Param | ||
import org.json.JSONObject | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
class Formatters { | ||
|
||
private val eventProps = arrayOf( | ||
Param("key1", "value1"), | ||
Param("key2", "value2"), | ||
Param("key3", "value3") | ||
) | ||
|
||
private val jsonStrategy = JSONFormatStrategy() | ||
private val mapStrategy = MapFormatStrategy() | ||
|
||
@Test | ||
fun `formatProperties should return JSONObject with correct properties`() { | ||
val expectedJson = JSONObject( | ||
mapOf( | ||
"key1" to "value1", | ||
"key2" to "value2", | ||
"key3" to "value3" | ||
) | ||
) | ||
|
||
val actualJson = jsonStrategy(*eventProps) | ||
|
||
assertEquals(expectedJson.toString(), actualJson.toString()) | ||
} | ||
|
||
@Test | ||
fun `mapStrategy should return Map with correct properties`() { | ||
val expectedMap = mapOf( | ||
"key1" to "value1", | ||
"key2" to "value2", | ||
"key3" to "value3" | ||
) | ||
|
||
val actualMapProperties = mapStrategy(*eventProps) | ||
|
||
assertEquals(expectedMap.toString(), actualMapProperties.toString()) | ||
} | ||
|
||
} |