-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
69 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
64 changes: 64 additions & 0 deletions
64
core/android/src/test/kotlin/com/walletconnect/android/internal/VerifyClientTest.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,64 @@ | ||
package com.walletconnect.android.internal | ||
|
||
import com.walletconnect.android.verify.client.VerifyClient | ||
import com.walletconnect.android.verify.domain.VerifyRepository | ||
import com.walletconnect.android.verify.domain.VerifyResult | ||
import io.mockk.coVerify | ||
import io.mockk.mockk | ||
import kotlinx.coroutines.test.StandardTestDispatcher | ||
import kotlinx.coroutines.test.TestScope | ||
import kotlinx.coroutines.test.runTest | ||
import org.junit.After | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.koin.core.KoinApplication | ||
import org.koin.core.context.startKoin | ||
import org.koin.core.context.stopKoin | ||
import org.koin.dsl.module | ||
|
||
class VerifyClientTest { | ||
private lateinit var koinApp: KoinApplication | ||
private var verifyRepository: VerifyRepository = mockk(relaxed = true) | ||
private lateinit var verifyClient: VerifyClient | ||
private val testDispatcher = StandardTestDispatcher() | ||
private val testScope = TestScope(testDispatcher) | ||
|
||
@Before | ||
fun setup() { | ||
koinApp = startKoin { | ||
modules(module { | ||
single { verifyRepository } | ||
}) | ||
} | ||
verifyClient = VerifyClient(koinApp, testScope) | ||
} | ||
|
||
@After | ||
fun tearDown() { | ||
stopKoin() | ||
} | ||
|
||
@Test | ||
fun `resolve should call resolve on verifyRepository`() = runTest { | ||
val attestationId = "attestationId" | ||
val metadataUrl = "https://metadata.url" | ||
val onSuccess = mockk<(VerifyResult) -> Unit>(relaxed = true) | ||
val onError = mockk<(Throwable) -> Unit>(relaxed = true) | ||
|
||
verifyClient.resolve(attestationId, metadataUrl, onSuccess, onError) | ||
|
||
coVerify { verifyRepository.resolve(attestationId, metadataUrl, onSuccess, onError) } | ||
} | ||
|
||
@Test | ||
fun `resolveV2 should call resolveV2 on verifyRepository`() = runTest { | ||
val attestation = "attestation" | ||
val metadataUrl = "https://metadata.url" | ||
val onSuccess = mockk<(VerifyResult) -> Unit>(relaxed = true) | ||
val onError = mockk<(Throwable) -> Unit>(relaxed = true) | ||
|
||
verifyClient.resolveV2(attestation, metadataUrl, onSuccess, onError) | ||
|
||
coVerify { verifyRepository.resolveV2(attestation, metadataUrl, onSuccess, onError) } | ||
} | ||
} |
File renamed without changes.