@@ -19,6 +19,8 @@ import Language.Haskell.LSP.Types
19
19
import qualified Language.Haskell.LSP.Types.Lens as L
20
20
import qualified Language.Haskell.LSP.Types.Capabilities as C
21
21
import Test.Hls.Util
22
+ import Test.Hspec.Expectations
23
+
22
24
import Test.Tasty
23
25
import Test.Tasty.ExpectedFailure (ignoreTestBecause , expectFailBecause )
24
26
import Test.Tasty.HUnit
@@ -293,17 +295,19 @@ redundantImportTests = testGroup "redundant import code actions" [
293
295
runSession hlsCommand fullCaps " test/testdata/redundantImportTest/" $ do
294
296
doc <- openDoc " src/CodeActionRedundant.hs" " haskell"
295
297
296
- diags <- waitForDiagnosticsFrom doc
298
+ diags <- waitForDiagnosticsFromSource doc " typecheck "
297
299
liftIO $ expectDiagnostic diags [" The import of" , " Data.List" , " is redundant" ]
298
300
299
301
mActions <- getAllCodeActions doc
300
302
301
- let allActions@ [removeAction, removeAllAction, makeAllExplicitAction] = map fromAction mActions
303
+ let allActions = map fromAction mActions
304
+ actionTitles = map (view L. title) allActions
305
+
306
+ liftIO $ actionTitles `shouldContain` [" Remove import" , " Remove all redundant imports" ]
307
+
308
+ let Just removeAction = find (\ x -> x ^. L. title == " Remove import" ) allActions
302
309
303
310
liftIO $ do
304
- removeAction ^. L. title @?= " Remove import"
305
- removeAllAction ^. L. title @?= " Remove all redundant imports"
306
- makeAllExplicitAction ^. L. title @?= " Make all imports explicit"
307
311
forM_ allActions $ \ a -> a ^. L. kind @?= Just CodeActionQuickFix
308
312
forM_ allActions $ \ a -> a ^. L. command @?= Nothing
309
313
forM_ allActions $ \ a -> isJust (a ^. L. edit) @? " Has edit"
@@ -318,7 +322,7 @@ redundantImportTests = testGroup "redundant import code actions" [
318
322
319
323
, testCase " doesn't touch other imports" $ runSession hlsCommand noLiteralCaps " test/testdata/redundantImportTest/" $ do
320
324
doc <- openDoc " src/MultipleImports.hs" " haskell"
321
- _ <- waitForDiagnosticsFrom doc
325
+ _ <- waitForDiagnosticsFromSource doc " typecheck "
322
326
CACommand cmd : _ <- getAllCodeActions doc
323
327
executeCommand cmd
324
328
contents <- documentContents doc
0 commit comments