Skip to content

Commit 787f492

Browse files
1grzyb1claude
andcommitted
VIM-4134 update tests for new module structure
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a9b8546 commit 787f492

File tree

15 files changed

+166
-277
lines changed

15 files changed

+166
-277
lines changed

scripts-ts/package-lock.json

Lines changed: 95 additions & 136 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/test/java/org/jetbrains/plugins/ideavim/action/change/delete/JoinNotificationTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2023 The IdeaVim authors
2+
* Copyright 2003-2026 The IdeaVim authors
33
*
44
* Use of this source code is governed by an MIT-style
55
* license that can be found in the LICENSE.txt file or at
@@ -14,7 +14,7 @@ import com.intellij.notification.ActionCenter
1414
import com.intellij.notification.Notification
1515
import com.maddyhome.idea.vim.VimPlugin
1616
import com.maddyhome.idea.vim.api.injector
17-
import com.maddyhome.idea.vim.group.NotificationService
17+
import com.maddyhome.idea.vim.group.VimNotifications
1818
import org.jetbrains.plugins.ideavim.TestIjOptionConstants
1919
import org.jetbrains.plugins.ideavim.VimTestCase
2020
import org.junit.jupiter.api.Test
@@ -34,7 +34,7 @@ class JoinNotificationTest : VimTestCase() {
3434
}.last()
3535

3636
try {
37-
kotlin.test.assertEquals(NotificationService.IDEAVIM_NOTIFICATION_TITLE, notification.title)
37+
kotlin.test.assertEquals(VimNotifications.IDEAVIM_NOTIFICATION_TITLE, notification.title)
3838
assertTrue(TestIjOptionConstants.ideajoin in notification.content)
3939
kotlin.test.assertEquals(3, notification.actions.size)
4040
} finally {

src/test/java/org/jetbrains/plugins/ideavim/action/copy/IdeaPutNotificationsTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2023 The IdeaVim authors
2+
* Copyright 2003-2026 The IdeaVim authors
33
*
44
* Use of this source code is governed by an MIT-style
55
* license that can be found in the LICENSE.txt file or at
@@ -13,7 +13,7 @@ import com.intellij.notification.Notification
1313
import com.intellij.openapi.application.ApplicationManager
1414
import com.maddyhome.idea.vim.VimPlugin
1515
import com.maddyhome.idea.vim.api.injector
16-
import com.maddyhome.idea.vim.group.NotificationService
16+
import com.maddyhome.idea.vim.group.VimNotifications
1717
import com.maddyhome.idea.vim.newapi.vim
1818
import com.maddyhome.idea.vim.options.OptionConstants
1919
import com.maddyhome.idea.vim.state.mode.SelectionType
@@ -45,7 +45,7 @@ class IdeaPutNotificationsTest : VimTestCase() {
4545

4646
val notification = notifications().last()
4747
try {
48-
kotlin.test.assertEquals(NotificationService.IDEAVIM_NOTIFICATION_TITLE, notification.title)
48+
kotlin.test.assertEquals(VimNotifications.IDEAVIM_NOTIFICATION_TITLE, notification.title)
4949
kotlin.test.assertTrue(OptionConstants.clipboard_ideaput in notification.content)
5050
kotlin.test.assertEquals(2, notification.actions.size)
5151
} finally {

src/test/java/org/jetbrains/plugins/ideavim/action/motion/gn/GnNextTextObjectTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2023 The IdeaVim authors
2+
* Copyright 2003-2026 The IdeaVim authors
33
*
44
* Use of this source code is governed by an MIT-style
55
* license that can be found in the LICENSE.txt file or at
@@ -11,6 +11,7 @@
1111
package org.jetbrains.plugins.ideavim.action.motion.gn
1212

1313
import com.maddyhome.idea.vim.VimPlugin
14+
import com.maddyhome.idea.vim.api.VimSearchGroupBase
1415
import com.maddyhome.idea.vim.api.injector
1516
import com.maddyhome.idea.vim.common.Direction
1617
import com.maddyhome.idea.vim.state.mode.Mode
@@ -85,7 +86,7 @@ class GnNextTextObjectTest : VimTestCase() {
8586

8687
private fun doTestWithSearch(keys: List<KeyStroke>, before: String, after: String) {
8788
configureByText(before)
88-
VimPlugin.getSearch().setLastSearchState("test", "", Direction.FORWARDS)
89+
(VimPlugin.getSearch() as VimSearchGroupBase).setLastSearchState("test", "", Direction.FORWARDS)
8990
typeText(keys)
9091
assertState(after)
9192
assertState(Mode.NORMAL())

src/test/java/org/jetbrains/plugins/ideavim/action/motion/gn/GnPreviousTextObjectTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2023 The IdeaVim authors
2+
* Copyright 2003-2026 The IdeaVim authors
33
*
44
* Use of this source code is governed by an MIT-style
55
* license that can be found in the LICENSE.txt file or at
@@ -11,6 +11,7 @@
1111
package org.jetbrains.plugins.ideavim.action.motion.gn
1212

1313
import com.maddyhome.idea.vim.VimPlugin
14+
import com.maddyhome.idea.vim.api.VimSearchGroupBase
1415
import com.maddyhome.idea.vim.api.injector
1516
import com.maddyhome.idea.vim.common.Direction
1617
import com.maddyhome.idea.vim.state.mode.Mode
@@ -63,7 +64,7 @@ class GnPreviousTextObjectTest : VimTestCase() {
6364

6465
private fun doTestWithSearch(keys: List<KeyStroke>, before: String, after: String) {
6566
configureByText(before)
66-
VimPlugin.getSearch().setLastSearchState("test", "", Direction.FORWARDS)
67+
(VimPlugin.getSearch() as VimSearchGroupBase).setLastSearchState("test", "", Direction.FORWARDS)
6768
typeText(keys)
6869
assertState(after)
6970
assertState(Mode.NORMAL())

src/test/java/org/jetbrains/plugins/ideavim/action/motion/gn/VisualSelectNextSearchTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2023 The IdeaVim authors
2+
* Copyright 2003-2026 The IdeaVim authors
33
*
44
* Use of this source code is governed by an MIT-style
55
* license that can be found in the LICENSE.txt file or at
@@ -10,6 +10,7 @@ package org.jetbrains.plugins.ideavim.action.motion.gn
1010
import com.intellij.idea.TestFor
1111
import com.maddyhome.idea.vim.VimPlugin
1212
import com.maddyhome.idea.vim.action.motion.search.SearchWholeWordForwardAction
13+
import com.maddyhome.idea.vim.api.VimSearchGroupBase
1314
import com.maddyhome.idea.vim.api.injector
1415
import com.maddyhome.idea.vim.common.Direction
1516
import com.maddyhome.idea.vim.state.mode.Mode
@@ -57,7 +58,7 @@ class VisualSelectNextSearchTest : VimTestCase() {
5758
@Test
5859
fun testWithoutSpaces() {
5960
configureByText("test<caret>test")
60-
VimPlugin.getSearch().setLastSearchState("test", "", Direction.FORWARDS)
61+
(VimPlugin.getSearch() as VimSearchGroupBase).setLastSearchState("test", "", Direction.FORWARDS)
6162
typeText(injector.parser.parseKeys("gn"))
6263
assertOffset(7)
6364
assertSelection("test")

src/test/java/org/jetbrains/plugins/ideavim/action/motion/gn/VisualSelectPreviousSearchTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2023 The IdeaVim authors
2+
* Copyright 2003-2026 The IdeaVim authors
33
*
44
* Use of this source code is governed by an MIT-style
55
* license that can be found in the LICENSE.txt file or at
@@ -10,6 +10,7 @@ package org.jetbrains.plugins.ideavim.action.motion.gn
1010
import com.intellij.idea.TestFor
1111
import com.maddyhome.idea.vim.VimPlugin
1212
import com.maddyhome.idea.vim.action.motion.search.SearchWholeWordForwardAction
13+
import com.maddyhome.idea.vim.api.VimSearchGroupBase
1314
import com.maddyhome.idea.vim.api.injector
1415
import com.maddyhome.idea.vim.common.Direction
1516
import com.maddyhome.idea.vim.state.mode.Mode
@@ -54,7 +55,7 @@ class VisualSelectPreviousSearchTest : VimTestCase() {
5455
@Test
5556
fun testWithoutSpaces() {
5657
configureByText("tes<caret>ttest")
57-
VimPlugin.getSearch().setLastSearchState("test", "", Direction.FORWARDS)
58+
(VimPlugin.getSearch() as VimSearchGroupBase).setLastSearchState("test", "", Direction.FORWARDS)
5859
typeText(injector.parser.parseKeys("gN"))
5960
assertOffset(0)
6061
assertSelection("test")

src/test/java/org/jetbrains/plugins/ideavim/action/motion/mark/MotionMarkActionTest.kt

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2023 The IdeaVim authors
2+
* Copyright 2003-2026 The IdeaVim authors
33
*
44
* Use of this source code is governed by an MIT-style
55
* license that can be found in the LICENSE.txt file or at
@@ -8,13 +8,13 @@
88

99
package org.jetbrains.plugins.ideavim.action.motion.mark
1010

11+
import com.intellij.ide.bookmark.BookmarkType
1112
import com.intellij.ide.bookmark.BookmarksManager
1213
import com.intellij.ide.bookmark.LineBookmark
1314
import com.intellij.openapi.application.ApplicationManager
1415
import com.intellij.testFramework.PlatformTestUtil
1516
import com.maddyhome.idea.vim.api.injector
16-
import com.maddyhome.idea.vim.group.createLineBookmark
17-
import com.maddyhome.idea.vim.group.mnemonic
17+
import com.maddyhome.idea.vim.group.bookmark.BookmarkBackendService
1818
import org.jetbrains.plugins.ideavim.VimTestCase
1919
import org.junit.jupiter.api.Test
2020

@@ -102,7 +102,15 @@ class MotionMarkActionTest : VimTestCase() {
102102
""".trimIndent()
103103
configureByText(text)
104104
enterCommand("set ideamarks")
105-
fixture.project.createLineBookmark(fixture.editor, 2, 'A')
105+
val bookmarkService = BookmarkBackendService.getInstance()
106+
bookmarkService.createOrGetSystemMark(
107+
'A',
108+
2,
109+
0,
110+
fixture.file.virtualFile.path,
111+
fixture.project.locationHash,
112+
fixture.file.virtualFile.fileSystem.protocol
113+
)
106114
ApplicationManager.getApplication().invokeAndWait {
107115
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
108116
}
@@ -124,10 +132,25 @@ class MotionMarkActionTest : VimTestCase() {
124132
configureByText(text)
125133
enterCommand("set ideamarks")
126134

127-
val bookmark = fixture.project.createLineBookmark(fixture.editor, 2, 'A')
128-
129-
BookmarksManager.getInstance(fixture.project)?.remove(bookmark!!)
130-
fixture.project.createLineBookmark(fixture.editor, 4, 'A')
135+
val bookmarkService = BookmarkBackendService.getInstance()
136+
bookmarkService.createOrGetSystemMark(
137+
'A',
138+
2,
139+
0,
140+
fixture.file.virtualFile.path,
141+
fixture.project.locationHash,
142+
fixture.file.virtualFile.fileSystem.protocol
143+
)
144+
145+
bookmarkService.removeBookmark('A')
146+
bookmarkService.createOrGetSystemMark(
147+
'A',
148+
4,
149+
0,
150+
fixture.file.virtualFile.path,
151+
fixture.project.locationHash,
152+
fixture.file.virtualFile.fileSystem.protocol
153+
)
131154
ApplicationManager.getApplication().invokeAndWait {
132155
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
133156
}
@@ -140,10 +163,13 @@ class MotionMarkActionTest : VimTestCase() {
140163

141164
private fun checkMarks(vararg marks: Pair<Char, Int>) {
142165
val project = fixture.project
143-
val validBookmarks = BookmarksManager.getInstance(project)!!.bookmarks.sortedBy { it.mnemonic(project) }
166+
val bookmarksManager = BookmarksManager.getInstance(project)!!
167+
val validBookmarks = bookmarksManager.bookmarks
168+
.filter { bookmarksManager.getType(it) != BookmarkType.DEFAULT }
169+
.sortedBy { bookmarksManager.getType(it)!!.mnemonic }
144170
kotlin.test.assertEquals(marks.size, validBookmarks.size)
145171
marks.sortedBy { it.first }.forEachIndexed { index, (mn, line) ->
146-
kotlin.test.assertEquals(mn, validBookmarks[index].mnemonic(project))
172+
kotlin.test.assertEquals(mn, bookmarksManager.getType(validBookmarks[index])!!.mnemonic)
147173
kotlin.test.assertEquals(line, (validBookmarks[index] as LineBookmark).line)
148174
}
149175
}

src/test/java/org/jetbrains/plugins/ideavim/action/motion/search/SearchAgainPreviousActionTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2023 The IdeaVim authors
2+
* Copyright 2003-2026 The IdeaVim authors
33
*
44
* Use of this source code is governed by an MIT-style
55
* license that can be found in the LICENSE.txt file or at
@@ -9,6 +9,7 @@
99
package org.jetbrains.plugins.ideavim.action.motion.search
1010

1111
import com.maddyhome.idea.vim.VimPlugin
12+
import com.maddyhome.idea.vim.api.VimSearchGroupBase
1213
import com.maddyhome.idea.vim.common.Direction
1314
import org.jetbrains.plugins.ideavim.SkipNeovimReason
1415
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@@ -203,7 +204,7 @@ class SearchAgainPreviousActionTest : VimTestCase() {
203204

204205
private fun doTestWithSearch(keys: String, before: String, after: String) {
205206
doTest(keys, before, after) {
206-
VimPlugin.getSearch().setLastSearchState("all", "", Direction.FORWARDS)
207+
(VimPlugin.getSearch() as VimSearchGroupBase).setLastSearchState("all", "", Direction.FORWARDS)
207208
}
208209
}
209210
}

src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/commands/GlobalCommandTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2023 The IdeaVim authors
2+
* Copyright 2003-2026 The IdeaVim authors
33
*
44
* Use of this source code is governed by an MIT-style
55
* license that can be found in the LICENSE.txt file or at
@@ -239,7 +239,7 @@ class GlobalCommandTest : VimTestCase() {
239239

240240
@Test
241241
fun `test check history`() {
242-
VimPlugin.getHistory().clear()
242+
(VimPlugin.getHistory() as com.maddyhome.idea.vim.group.HistoryGroup).clear()
243243
val initialEntries = VimPlugin.getHistory().getEntries(VimHistory.Type.Command, 0, 0)
244244
doTest(
245245
"g/found/d",

0 commit comments

Comments
 (0)