@@ -231,6 +231,7 @@ codeActionTests = testGroup "code actions"
231
231
[ renameActionTests
232
232
, typeWildCardActionTests
233
233
, removeImportTests
234
+ , importRenameActionTests
234
235
]
235
236
236
237
renameActionTests :: TestTree
@@ -431,6 +432,27 @@ removeImportTests = testGroup "remove import actions"
431
432
liftIO $ expectedContentAfterAction @=? contentAfterAction
432
433
]
433
434
435
+ importRenameActionTests :: TestTree
436
+ importRenameActionTests = testGroup " import rename actions"
437
+ [ testSession " Data.Mape -> Data.Map" $ check " Map"
438
+ , testSession " Data.Mape -> Data.Maybe" $ check " Maybe" ] where
439
+ check modname = do
440
+ let content = T. unlines
441
+ [ " module Testing where"
442
+ , " import Data.Mape"
443
+ ]
444
+ doc <- openDoc' " Testing.hs" " haskell" content
445
+ _ <- waitForDiagnostics
446
+ actionsOrCommands <- getCodeActions doc (Range (Position 2 8 ) (Position 2 16 ))
447
+ let [changeToMap] = [action | CACodeAction action@ CodeAction { _title = actionTitle } <- actionsOrCommands, (" Data." <> modname) `T.isInfixOf` actionTitle ]
448
+ executeCodeAction changeToMap
449
+ contentAfterAction <- documentContents doc
450
+ let expectedContentAfterAction = T. unlines
451
+ [ " module Testing where"
452
+ , " import Data." <> modname
453
+ ]
454
+ liftIO $ expectedContentAfterAction @=? contentAfterAction
455
+
434
456
----------------------------------------------------------------------
435
457
-- Utils
436
458
0 commit comments