Bump up the number of jobs when building hie in travis
[lsp-test.git] / test / Test.hs
index 604ea1c834978c7432b5eeb0db92ae2d3d49e301..13e7ccc5d3066b687c7ca4391a3e6e8af62cbe77 100644 (file)
@@ -1,13 +1,16 @@
 {-# LANGUAGE DuplicateRecordFields #-}
 {-# LANGUAGE OverloadedStrings #-}
 import           Test.Hspec
+import           Data.Maybe
 import           Data.Proxy
 import           Control.Monad.IO.Class
 import           Control.Lens hiding (List)
 import           Language.Haskell.LSP.Test
-import           Language.Haskell.LSP.TH.DataTypesJSON
+import           Language.Haskell.LSP.Test.Replay
+import           Language.Haskell.LSP.Types
+import           Language.Haskell.LSP.Messages
 
-main = hspec $
+main = hspec $ do
   describe "manual session validation" $ 
     it "passes a test" $
       runSession "test/recordings/renamePass" $ do
@@ -16,19 +19,26 @@ main = hspec $
 
         sendNotification TextDocumentDidOpen (DidOpenTextDocumentParams docItem)
 
-        (NotificationMessage _ TextDocumentPublishDiagnostics (PublishDiagnosticsParams _ (List diags))) <-
-          getMessage :: Session PublishDiagnosticsNotification
+        skipMany loggingNotification
 
-        liftIO $ diags `shouldBe` []
+        NotPublishDiagnostics diagsNot <- notification
+
+        liftIO $ diagsNot ^. params . diagnostics `shouldBe` List []
         
         sendRequest (Proxy :: Proxy DocumentSymbolRequest)
                     TextDocumentDocumentSymbol
                     (DocumentSymbolParams docId)
 
-        (ResponseMessage _ _ (Just (List symbols)) Nothing) <- getMessage :: Session DocumentSymbolsResponse
+        RspDocumentSymbols rspSymbols <- response
+        
         liftIO $ do
-          let mainSymbol = head symbols
+          let (List symbols) = fromJust (rspSymbols ^. result)
+              mainSymbol = head symbols
           mainSymbol ^. name `shouldBe` "main"
           mainSymbol ^. kind `shouldBe` SkFunction
           mainSymbol ^. location . range `shouldBe` Range (Position 3 0) (Position 3 4)
           mainSymbol ^. containerName `shouldBe` Nothing
+  
+  describe "replay session" $
+    it "passes a test" $
+      replaySession "test/recordings/renamePass" `shouldReturn` True
\ No newline at end of file