Skip to content

Commit

Permalink
Add Trigger Tests
Browse files Browse the repository at this point in the history
- Add Robolectric
  • Loading branch information
jennantilla committed Jul 30, 2024
1 parent 544bce1 commit 495013b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.onesignal.inAppMessages.internal

import br.com.colman.kotest.android.extensions.robolectric.RobolectricTest
import com.onesignal.OneSignal
import com.onesignal.debug.LogLevel
import com.onesignal.debug.internal.logging.Logging
Expand All @@ -9,6 +10,7 @@ import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import java.util.UUID

@RobolectricTest
class InAppMessagesTests : FunSpec({
val iamClickId = "button_id_123"
val limit = 5
Expand Down Expand Up @@ -58,7 +60,7 @@ class InAppMessagesTests : FunSpec({
}

beforeAny {
Logging.logLevel = LogLevel.NONE
Logging.logLevel = LogLevel.VERBOSE
// TODO: add more from Player Model @BeforeClass in InAppMessagingUnitTests.java
}

Expand Down Expand Up @@ -166,7 +168,12 @@ class InAppMessagesTests : FunSpec({
}

test("testBuiltMessageTrigger") {
// TODO
val trigger = message.triggers[0][0]

trigger.kind shouldBe Trigger.OSTriggerKind.SESSION_TIME
trigger.operatorType shouldBe Trigger.OSTriggerOperator.GREATER_THAN_OR_EQUAL_TO
trigger.property shouldBe null
trigger.value shouldBe 3
}

test("testParsesMessageActions") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ class InAppMessagingHelpers {
val variants: Map<String, Map<String, String>>
get() = inAppMessage.variants

internal val triggers: List<List<Trigger>>
get() = inAppMessage.triggers

val clickedClickIds: MutableSet<String>
get() = inAppMessage.clickedClickIds

Expand Down

0 comments on commit 495013b

Please sign in to comment.