Fix embarassing error with publishDiagnosticsNotification
[lsp-test.git] / test / Test.hs
index 13e7ccc5d3066b687c7ca4391a3e6e8af62cbe77..652485e0af160279340ea8d6730dc37d33b075e9 100644 (file)
@@ -9,15 +9,13 @@ import           Language.Haskell.LSP.Test
 import           Language.Haskell.LSP.Test.Replay
 import           Language.Haskell.LSP.Types
 import           Language.Haskell.LSP.Messages
+import           ParsingTests
 
 main = hspec $ do
-  describe "manual session validation" $ 
+  describe "manual session validation" $ do
     it "passes a test" $
       runSession "test/recordings/renamePass" $ do
-        docItem <- getDocItem "Desktop/simple.hs" "haskell"
-        docId   <- TextDocumentIdentifier <$> getDocUri "Desktop/simple.hs"
-
-        sendNotification TextDocumentDidOpen (DidOpenTextDocumentParams docItem)
+        doc <- openDoc "Desktop/simple.hs" "haskell"
 
         skipMany loggingNotification
 
@@ -27,7 +25,7 @@ main = hspec $ do
         
         sendRequest (Proxy :: Proxy DocumentSymbolRequest)
                     TextDocumentDocumentSymbol
-                    (DocumentSymbolParams docId)
+                    (DocumentSymbolParams doc)
 
         RspDocumentSymbols rspSymbols <- response
         
@@ -39,6 +37,18 @@ main = hspec $ do
           mainSymbol ^. location . range `shouldBe` Range (Position 3 0) (Position 3 4)
           mainSymbol ^. containerName `shouldBe` Nothing
     
-  describe "replay session" $
+    it "fails a test" $
+      -- TODO: Catch the exception in haskell-lsp-test and provide nicer output
+      let session = runSession "test/recordings/renamePass" $ do
+                    openDoc "Desktop/simple.hs" "haskell"
+                    skipMany loggingNotification
+                    request
+        in session `shouldThrow` anyException
+  
+  describe "replay session" $ do
     it "passes a test" $
       replaySession "test/recordings/renamePass" `shouldReturn` True
+    it "fails a test" $
+      replaySession "test/recordings/renameFail" `shouldReturn` False
+  
+  parsingSpec
\ No newline at end of file