From 336efa1e8b27a2e93efe187cea454e1fd12ab569 Mon Sep 17 00:00:00 2001 From: Alex Plate <aleksei.plate@jetbrains.com> Date: Fri, 24 Nov 2023 17:49:04 +0200 Subject: [PATCH] Add some tests for one time mode --- .../vim/annotations/CommandOrMotion.kt | 2 +- .../insert/InsertSingleCommandActionTest.kt | 30 +++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/annotation-processors/src/main/kotlin/com/intellij/vim/annotations/CommandOrMotion.kt b/annotation-processors/src/main/kotlin/com/intellij/vim/annotations/CommandOrMotion.kt index 18ce2ed70..91e2771b4 100644 --- a/annotation-processors/src/main/kotlin/com/intellij/vim/annotations/CommandOrMotion.kt +++ b/annotation-processors/src/main/kotlin/com/intellij/vim/annotations/CommandOrMotion.kt @@ -44,7 +44,7 @@ enum class Mode(val abbrev: Char) { OP_PENDING('O'), /** - * Indicates this key mapping applies to Insert mode + * Indicates this key mapping applies to Insert or Replace modes */ INSERT('I'), diff --git a/src/test/java/org/jetbrains/plugins/ideavim/action/change/insert/InsertSingleCommandActionTest.kt b/src/test/java/org/jetbrains/plugins/ideavim/action/change/insert/InsertSingleCommandActionTest.kt index 5aa138e35..818bd6649 100644 --- a/src/test/java/org/jetbrains/plugins/ideavim/action/change/insert/InsertSingleCommandActionTest.kt +++ b/src/test/java/org/jetbrains/plugins/ideavim/action/change/insert/InsertSingleCommandActionTest.kt @@ -12,14 +12,38 @@ import com.maddyhome.idea.vim.state.mode.Mode import org.jetbrains.plugins.ideavim.VimTestCase import org.junit.jupiter.api.Test -class InsertSingleCommandActionTest : VimTestCase() { +class InsertSingleCommandActionTest : SingleCommandActionTest() { + override val command: String = "i" + override val mode: Mode = Mode.INSERT +} + +class ReplaceSingleCommandActionTest : SingleCommandActionTest() { + override val command: String = "R" + override val mode: Mode = Mode.REPLACE +} + +abstract class SingleCommandActionTest : VimTestCase() { + + abstract val command: String + abstract val mode: Mode + + @Test + fun `one operation`() { + doTest( + listOf(command, "<C-O>", "l"), + "I found ${c}it in a legendary land", + "I found i${c}t in a legendary land", + mode, + ) + } + @Test fun `test enter visual`() { doTest( - listOf("i", "<C-O>", "vlll", "<Esc>"), + listOf(command, "<C-O>", "vlll", "<Esc>"), "I found ${c}it in a legendary land", "I found it ${c}in a legendary land", -Mode.INSERT, + mode, ) } }