X-Git-Url: https://git.lukelau.me/?a=blobdiff_plain;f=test%2FTest.hs;h=604ea1c834978c7432b5eeb0db92ae2d3d49e301;hb=df782ad008b840c0860173821226542e2e70f2e9;hp=7c7f272ad6f620c32735ae47aeeef896c2386b48;hpb=1f4a12c49be0cb8640d60c21f6499c5567646fba;p=lsp-test.git diff --git a/test/Test.hs b/test/Test.hs index 7c7f272..604ea1c 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -1,18 +1,34 @@ +{-# LANGUAGE DuplicateRecordFields #-} +{-# LANGUAGE OverloadedStrings #-} import Test.Hspec -import System.IO -import System.Directory -import Control.Lens +import Data.Proxy import Control.Monad.IO.Class -import Language.Haskell.LSP.Test.Recorded --- import Language.Haskell.LSP.Test.Parsing --- import Language.Haskell.LSP.Test.Files -import qualified Language.Haskell.LSP.TH.DataTypesJSON as LSP +import Control.Lens hiding (List) +import Language.Haskell.LSP.Test +import Language.Haskell.LSP.TH.DataTypesJSON main = hspec $ - describe "replay" $ - it "passes a replay" $ - replaySession "test/recordings/renamePass" $ do - x <- sendNextRequest - liftIO $ print x - y <- sendNextRequest - liftIO $ print y \ No newline at end of file + describe "manual session validation" $ + 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) + + (NotificationMessage _ TextDocumentPublishDiagnostics (PublishDiagnosticsParams _ (List diags))) <- + getMessage :: Session PublishDiagnosticsNotification + + liftIO $ diags `shouldBe` [] + + sendRequest (Proxy :: Proxy DocumentSymbolRequest) + TextDocumentDocumentSymbol + (DocumentSymbolParams docId) + + (ResponseMessage _ _ (Just (List symbols)) Nothing) <- getMessage :: Session DocumentSymbolsResponse + liftIO $ do + let 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