Skip to content

Commit

Permalink
[JS] Fix getMemberships ignoring uuid parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
wkal-pubnub committed Nov 6, 2024
1 parent 11634e5 commit 69e3168
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,25 @@ class MembershipsTest : BaseIntegrationTest() {
assertEquals(customData, pnChannelDetails.custom?.value)
}

@Test
fun can_set_and_get_memberships_for_other_uuid() = runTest {
// when
val userId = "some-user-" + randomString()
pubnub.setMemberships(
channels = listOf(PNChannelMembership.Partial(channel, custom, status)),
uuid = userId,
includeCustom = includeCustom,
includeChannelDetails = PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM,
).await()

val result = pubnub.getMemberships(uuid = userId, filter = "channel.id == '$channel'", includeCustom = true).await()

// then
val pnChannelDetails = result.data.single { it.channel.id == channel }
assertEquals(channel, pnChannelDetails.channel.id)
assertEquals(customData, pnChannelDetails.custom?.value)
}

@Test
fun can_receive_set_membership_event() = runTest {
pubnub.test(backgroundScope) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.pubnub.api.models.consumer.pubsub.PNSignalResult
import com.pubnub.kmp.PLATFORM
import com.pubnub.test.BaseIntegrationTest
import com.pubnub.test.await
import com.pubnub.test.randomString
import com.pubnub.test.test
import kotlinx.coroutines.test.runTest
import kotlin.js.JsExport
Expand All @@ -27,7 +28,7 @@ data class ABC(
)

class PublishTest : BaseIntegrationTest() {
private val channel = "myChannel"
private val channel = "myChannel" + randomString()

@Test
fun can_publish_message_string() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ class PubNubImpl(val jsPubNub: PubNubJs) : PubNub {
return GetMembershipsImpl(
jsPubNub,
createJsObject {
uuid?.let { this.uuid = it }
this.sort = sort.toJsMap()
this.filter = filter
this.page = page.toMetadataPage()
Expand Down

0 comments on commit 69e3168

Please sign in to comment.