mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 10:55:55 +03:00
parsing the space commands by checking for the size and last segment to find the space id to join/add to
This commit is contained in:
parent
da70d520bc
commit
493d9240c2
3 changed files with 16 additions and 4 deletions
1
changelog.d/6844.bugfix
Normal file
1
changelog.d/6844.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Fixes /addToSpace and /joinSpace commands showing invalid syntax warnings
|
|
@ -374,15 +374,15 @@ class CommandParser @Inject constructor() {
|
|||
}
|
||||
}
|
||||
Command.ADD_TO_SPACE.matches(slashCommand) -> {
|
||||
if (messageParts.size == 1) {
|
||||
ParsedCommand.AddToSpace(spaceId = message)
|
||||
if (messageParts.size == 2) {
|
||||
ParsedCommand.AddToSpace(spaceId = messageParts.last())
|
||||
} else {
|
||||
ParsedCommand.ErrorSyntax(Command.ADD_TO_SPACE)
|
||||
}
|
||||
}
|
||||
Command.JOIN_SPACE.matches(slashCommand) -> {
|
||||
if (messageParts.size == 1) {
|
||||
ParsedCommand.JoinSpace(spaceIdOrAlias = message)
|
||||
if (messageParts.size == 2) {
|
||||
ParsedCommand.JoinSpace(spaceIdOrAlias = messageParts.last())
|
||||
} else {
|
||||
ParsedCommand.ErrorSyntax(Command.JOIN_SPACE)
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ package im.vector.app.features.command
|
|||
import org.amshove.kluent.shouldBeEqualTo
|
||||
import org.junit.Test
|
||||
|
||||
private const val A_SPACE_ID = "!my-space-id"
|
||||
|
||||
class CommandParserTest {
|
||||
@Test
|
||||
fun parseSlashCommandEmpty() {
|
||||
|
@ -31,6 +33,15 @@ class CommandParserTest {
|
|||
test("/unknown with param", ParsedCommand.ErrorUnknownSlashCommand("/unknown"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseSlashAddToSpaceCommand() {
|
||||
test("/addToSpace $A_SPACE_ID", ParsedCommand.AddToSpace(A_SPACE_ID))
|
||||
}
|
||||
@Test
|
||||
fun parseSlashJoinSpaceCommand() {
|
||||
test("/joinSpace $A_SPACE_ID", ParsedCommand.JoinSpace(A_SPACE_ID))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseSlashCommandNotACommand() {
|
||||
test("", ParsedCommand.ErrorNotACommand)
|
||||
|
|
Loading…
Reference in a new issue