mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2024-12-29 07:42:48 +01:00
Add some tests for the getcmdtype() function
This commit is contained in:
parent
52737c60cf
commit
c75e6756c0
src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/vimscript/model/functions/handlers
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2003-2024 The IdeaVim authors
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE.txt file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*/
|
||||
|
||||
package org.jetbrains.plugins.ideavim.ex.implementation.functions
|
||||
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.ui.ex.ExEntryPanel
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class GetCmdTypeFunctionTest : VimTestCase() {
|
||||
|
||||
@Test
|
||||
fun `test getcmdtype() for a regular command`() {
|
||||
configureByText("\n")
|
||||
enterCommand("cmap <expr> z getcmdtype()")
|
||||
typeText(":fooz")
|
||||
assertEquals("foo:", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test getcmdtype() for a forward search`() {
|
||||
configureByText("\n")
|
||||
enterCommand("cmap <expr> z getcmdtype()")
|
||||
typeText("/fooz")
|
||||
assertEquals("foo/", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test getcmdtype() for a backward search`() {
|
||||
configureByText("\n")
|
||||
enterCommand("cmap <expr> z getcmdtype()")
|
||||
typeText("?fooz")
|
||||
assertEquals("foo?", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test getcmdtype() for an expression command`() {
|
||||
configureByText("\n")
|
||||
enterCommand("cmap <expr> z getcmdtype()")
|
||||
typeText("i<C-r>=fooz")
|
||||
assertEquals("foo=", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText)
|
||||
}
|
||||
|
||||
}
|
@ -22,7 +22,6 @@ import com.maddyhome.idea.vim.vimscript.model.functions.FunctionHandler
|
||||
/*
|
||||
Return the current command-line type. Possible return values are:
|
||||
: normal Ex command
|
||||
> debug mode command debug-mode
|
||||
/ forward search command
|
||||
? backward search command
|
||||
= i_CTRL-R_=
|
||||
@ -30,6 +29,7 @@ Return the current command-line type. Possible return values are:
|
||||
Returns an empty string otherwise.
|
||||
|
||||
Not yet implemented:
|
||||
> debug mode command debug-mode
|
||||
@ input() command
|
||||
- :insert or :append command
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user