-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
7 changed files
with
57 additions
and
18 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
2 changes: 2 additions & 0 deletions
2
litecommands-core/src/test/java/dev/rollczi/litecommands/LiteTestSenderArgument.java
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
12 changes: 12 additions & 0 deletions
12
litecommands-core/src/test/java/dev/rollczi/litecommands/LiteTestSenderBind.java
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,12 @@ | ||
package dev.rollczi.litecommands; | ||
|
||
import dev.rollczi.litecommands.bind.LiteBind; | ||
|
||
public class LiteTestSenderBind implements LiteBind { | ||
|
||
@Override | ||
public Object apply(LiteInvocation invocation) { | ||
return new LiteTestSender(); | ||
} | ||
|
||
} |
40 changes: 23 additions & 17 deletions
40
litecommands-core/src/test/java/dev/rollczi/litecommands/complete/SuggestionTest.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 |
---|---|---|
@@ -1,44 +1,50 @@ | ||
package dev.rollczi.litecommands.complete | ||
|
||
import dev.rollczi.litecommands.LiteCommandsSpec | ||
import dev.rollczi.litecommands.component.LiteComponent | ||
import dev.rollczi.litecommands.LiteTestFactory | ||
import dev.rollczi.litecommands.LiteTestPlatform | ||
import org.junit.jupiter.api.Assertions.assertArrayEquals | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
class SuggestionTest : LiteCommandsSpec() { | ||
|
||
private val section = factory.createSection(TestSuggestionCommand::class.java).get() | ||
private val testSuggestionCommand = TestSuggestionCommand() | ||
private val testSuggestionCommandWithJoiner = TestSuggestionCommandWithJoiner() | ||
private val liteCommands = LiteTestFactory.builder() | ||
.commandInstance(testSuggestionCommand) | ||
.commandInstance(testSuggestionCommandWithJoiner) | ||
.register() | ||
|
||
private var invocationAc : LiteComponent.ContextOfResolving = contextCreator.apply("ac", arrayOf("")) | ||
private val platform: LiteTestPlatform = liteCommands.getPlatformManager() | ||
|
||
@Test | ||
fun `without arg tabulation test`() { | ||
assertArrayEquals(arrayOf("help", "manage"), section.resolveCompletion(invocationAc).toTypedArray()) | ||
assertArrayEquals(arrayOf("help", "manage"), platform.suggestion("ac", arrayOf("")).toTypedArray()) | ||
} | ||
|
||
private var invocationAcHelp : LiteComponent.ContextOfResolving = contextCreator.apply("ac", arrayOf("help", "")) | ||
|
||
@Test | ||
fun `empty tabulation test`() { | ||
assertArrayEquals(emptyArray<String>(), section.resolveCompletion(invocationAcHelp).toTypedArray()) | ||
assertArrayEquals(emptyArray<String>(), platform.suggestion("ac", arrayOf("help", "")).toTypedArray()) | ||
} | ||
|
||
private var invocationAcManage : LiteComponent.ContextOfResolving = contextCreator.apply("ac", arrayOf("manage", "")) | ||
private var invocationAcMove : LiteComponent.ContextOfResolving = contextCreator.apply("ac", arrayOf("manage", "move", "")) | ||
|
||
@Test | ||
fun `inner section tabulation test` () { | ||
assertArrayEquals(arrayOf("move"), section.resolveCompletion(invocationAcManage).toTypedArray()) | ||
assertArrayEquals(arrayOf("test1", "test2", "test3"), section.resolveCompletion(invocationAcMove).toTypedArray()) | ||
assertArrayEquals(arrayOf("move"), platform.suggestion("ac", arrayOf("manage", "")).toTypedArray()) | ||
assertArrayEquals(arrayOf("test1", "test2", "test3"), platform.suggestion("ac", arrayOf("manage", "move", "")).toTypedArray()) | ||
} | ||
|
||
private var invocationAcMoveBack : LiteComponent.ContextOfResolving = contextCreator.apply("ac", arrayOf("manage", "mo")) | ||
private var invocationAcMoveIn : LiteComponent.ContextOfResolving = contextCreator.apply("ac", arrayOf("manage", "move")) | ||
|
||
@Test | ||
fun `back tabulation test` () { | ||
assertArrayEquals(arrayOf("move"), section.resolveCompletion(invocationAcMoveBack).toTypedArray()) | ||
assertArrayEquals(arrayOf("move"), section.resolveCompletion(invocationAcMoveIn).toTypedArray()) | ||
assertArrayEquals(arrayOf("move"), platform.suggestion("ac", arrayOf("manage", "mo")).toTypedArray()) | ||
assertArrayEquals(arrayOf("move"), platform.suggestion("ac", arrayOf("manage", "move")).toTypedArray()) | ||
} | ||
|
||
@Test | ||
fun `completion with joiner` () { | ||
assertEquals(0, platform.suggestion("joiner", arrayOf("test")).size) | ||
assertEquals(0, platform.suggestion("joiner", arrayOf("test", "test")).size) | ||
assertEquals(0, platform.suggestion("joiner", arrayOf("test", "test", "test")).size) | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...core/src/test/java/dev/rollczi/litecommands/complete/TestSuggestionCommandWithJoiner.java
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,14 @@ | ||
package dev.rollczi.litecommands.complete; | ||
|
||
import dev.rollczi.litecommands.annotations.Execute; | ||
import dev.rollczi.litecommands.annotations.Joiner; | ||
import dev.rollczi.litecommands.annotations.MinArgs; | ||
import dev.rollczi.litecommands.annotations.Section; | ||
|
||
@Section(route = "joiner") | ||
public class TestSuggestionCommandWithJoiner { | ||
|
||
@Execute @MinArgs(1) | ||
public void execute(@Joiner String text) {} | ||
|
||
} |