Skip to content

Commit

Permalink
Added Chat.init test
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-cebo committed Aug 7, 2024
1 parent ef079ef commit 09fc3e1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ kotlin {
implementation("com.pubnub:pubnub-kotlin-impl:9.2-DEV")
}
}

val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation("com.pubnub:pubnub-kotlin-test")
}
}
}

if (enableAnyIosTarget) {
Expand Down
29 changes: 29 additions & 0 deletions src/jvmTest/kotlin/compubnub/chat/ChatIntegrationTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package compubnub.chat

import com.pubnub.api.PubNubException
import com.pubnub.api.UserId
import com.pubnub.api.v2.PNConfiguration
import com.pubnub.api.v2.callbacks.Result
import com.pubnub.chat.Chat
import com.pubnub.chat.config.ChatConfiguration
import com.pubnub.chat.config.LogLevel
import com.pubnub.chat.init
import kotlin.test.Test

class ChatIntegrationTest {

@Test
fun canInitializeChatWithLogLevel() {
val chatConfig = ChatConfiguration(logLevel = LogLevel.INFO)
val pnConfiguration = PNConfiguration.builder(userId = UserId("myUserId"), subscribeKey = "mySubscribeKey").build()

Chat.init(chatConfig, pnConfiguration).async { result: Result<Chat> ->
result.onSuccess { chat: Chat ->
println("Chat successfully initialized having logLevel: ${chatConfig.logLevel}")
}.onFailure { exception: PubNubException ->
println("Exception initialising chat: ${exception.message}")
}
}

}
}

0 comments on commit 09fc3e1

Please sign in to comment.