Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update targetSdk version for core + all modules #250

Merged
merged 13 commits into from
Feb 18, 2025
Prev Previous commit
Next Next commit
spyk test fixes for remotecommanddispatcher
  • Loading branch information
jameskeith committed Feb 4, 2025
commit 98ec9d88c36fe342e00148cf23920377d4096699
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import io.mockk.*
import io.mockk.impl.annotations.MockK
import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import java.io.File
Expand Down Expand Up @@ -52,7 +53,10 @@ class RemoteCommandDispatcherTests {
@Test
fun validAddAndProcessJsonRemoteCommand() {
val remoteCommandDispatcher = RemoteCommandDispatcher(tealiumContext, mockNetworkClient, mockRemoteCommandsManager)
val remoteCommand = spyk(TestCommand())
var invoked = false
val remoteCommand = TestCommand {
invoked = true
}

every { mockRemoteCommandsManager.add(any(), any(), any()) } just Runs
every { mockRemoteCommandsManager.getRemoteCommandConfigRetriever(any()) } returns remoteCommandConfigRetriever
Expand All @@ -63,18 +67,21 @@ class RemoteCommandDispatcherTests {
val dispatch = TealiumEvent("event_test", mapOf("key1" to "value1", "key2" to "value2"))
remoteCommandDispatcher.onProcessRemoteCommand(dispatch)

verify { remoteCommand.onInvoke(any()) }
assertTrue(invoked)
}

@Test
fun validAddAndProcessWebViewRemoteCommand() {
val remoteCommandDispatcher = RemoteCommandDispatcher(tealiumContext, mockNetworkClient)
val webViewCommand = spyk(TestCommand())
var invoked = false
val webViewCommand = TestCommand {
invoked = true
}

remoteCommandDispatcher.add(webViewCommand)
remoteCommandDispatcher.onRemoteCommandSend(RemoteCommandRequest(createResponseHandler(), "tealium://test?request={\"config\":{\"response_id\":\"123\"}, \"payload\":{\"hello\": \"world\"}}"))

verify { webViewCommand.onInvoke(any()) }
assertTrue(invoked)
}

@Test
Expand Down Expand Up @@ -110,8 +117,8 @@ class RemoteCommandDispatcherTests {
}
}

open class TestCommand : RemoteCommand("test", "description") {
open class TestCommand(private val onInvoked: ((RemoteCommand.Response?) -> Unit)? = null) : RemoteCommand("test", "description") {
public override fun onInvoke(p0: Response?) {

onInvoked?.invoke(p0)
}
}
Loading