-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JS] Fix crash on sort parameter (#150)
* [JS] Fix sort parameter crash * PubNub js 0.9.4 release. --------- Co-authored-by: PubNub Release Bot <[email protected]>
- Loading branch information
1 parent
2edb7cc
commit bbef18b
Showing
11 changed files
with
112 additions
and
38 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
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
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
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
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
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 |
---|---|---|
@@ -1,9 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<baseline version="1.0"> | ||
<file name="src/jsMain/kotlin/UserJs.kt"> | ||
<error line="46" column="53" source="standard:comment-wrapping" /> | ||
</file> | ||
<file name="src/jsMain/kotlin/converters.kt"> | ||
<error line="137" column="14" source="standard:function-naming" /> | ||
<error line="147" column="14" source="standard:function-naming" /> | ||
</file> | ||
</baseline> |
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
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
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
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
67 changes: 67 additions & 0 deletions
67
pubnub-chat-impl/src/jsTest/kotlin/com/pubnub/kmp/ConvertersTest.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,67 @@ | ||
package com.pubnub.kmp | ||
|
||
import com.pubnub.api.models.consumer.objects.PNKey | ||
import com.pubnub.api.models.consumer.objects.PNMemberKey | ||
import com.pubnub.api.models.consumer.objects.PNMembershipKey | ||
import com.pubnub.api.models.consumer.objects.PNSortKey | ||
import extractSortKeys | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class ConvertersTest { | ||
@Test | ||
fun test_extractSortKeys() { | ||
val sortKeys1 = | ||
js( | ||
"""{"updated": null, "status": "asc", "type": "desc", "channel.id": null, "channel.name": "asc", "channel.updated": "desc", "channel.status": null, "channel.type": "asc"}""" | ||
) | ||
val sortKeysResult1: List<PNSortKey<PNMembershipKey>> = extractSortKeys(sortKeys1) | ||
assertEquals( | ||
listOf( | ||
PNSortKey.PNAsc(PNMembershipKey.UPDATED), | ||
PNSortKey.PNAsc(PNMembershipKey.STATUS), | ||
PNSortKey.PNDesc(PNMembershipKey.TYPE), | ||
PNSortKey.PNAsc(PNMembershipKey.CHANNEL_ID), | ||
PNSortKey.PNAsc(PNMembershipKey.CHANNEL_NAME), | ||
PNSortKey.PNDesc(PNMembershipKey.CHANNEL_UPDATED), | ||
PNSortKey.PNAsc(PNMembershipKey.CHANNEL_STATUS), | ||
PNSortKey.PNAsc(PNMembershipKey.CHANNEL_TYPE), | ||
).map { it.toSortParameter() }, | ||
sortKeysResult1.map { it.toSortParameter() } | ||
) | ||
|
||
val sortKeys2 = | ||
js( | ||
"""{"updated": null, "status": "asc", "type": "desc", "uuid.id": null, "uuid.name": "asc", "uuid.updated": "desc", "uuid.status": null, "uuid.type": "asc"}""" | ||
) | ||
val sortKeysResult2: List<PNSortKey<PNMemberKey>> = extractSortKeys(sortKeys2) | ||
|
||
assertEquals( | ||
listOf( | ||
PNSortKey.PNAsc(PNMemberKey.UPDATED), | ||
PNSortKey.PNAsc(PNMemberKey.STATUS), | ||
PNSortKey.PNDesc(PNMemberKey.TYPE), | ||
PNSortKey.PNAsc(PNMemberKey.UUID_ID), | ||
PNSortKey.PNAsc(PNMemberKey.UUID_NAME), | ||
PNSortKey.PNDesc(PNMemberKey.UUID_UPDATED), | ||
PNSortKey.PNAsc(PNMemberKey.UUID_STATUS), | ||
PNSortKey.PNAsc(PNMemberKey.UUID_TYPE), | ||
).map { it.toSortParameter() }, | ||
sortKeysResult2.map { it.toSortParameter() } | ||
) | ||
|
||
val sortKeys3 = js("""{"updated": null, "status": "asc", "type": "desc", "id": null, "name": "asc"}""") | ||
val sortKeysResult3: List<PNSortKey<PNKey>> = extractSortKeys(sortKeys3) | ||
|
||
assertEquals( | ||
listOf( | ||
PNSortKey.PNAsc(PNKey.UPDATED), | ||
PNSortKey.PNAsc(PNKey.STATUS), | ||
PNSortKey.PNDesc(PNKey.TYPE), | ||
PNSortKey.PNAsc(PNKey.ID), | ||
PNSortKey.PNAsc(PNKey.NAME), | ||
).map { it.toSortParameter() }, | ||
sortKeysResult3.map { it.toSortParameter() } | ||
) | ||
} | ||
} |