X-Git-Url: http://git.lukelau.me/?a=blobdiff_plain;f=test%2FTest.hs;h=ce8a3573c3f92edaf0c5efa4a523be83479625a9;hb=f3a1c846d97e7d081375501835695334ddd3b34f;hp=a639e38dbb1dd222bc5b202a513623d0a3b53f97;hpb=7d0ddb8022d9cccc68a99008dd55c1d39ddda3e7;p=lsp-test.git diff --git a/test/Test.hs b/test/Test.hs index a639e38..ce8a357 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -12,18 +12,14 @@ import ParsingTests main = hspec $ do describe "manual session" $ do it "passes a test" $ - runSession "hie --lsp" "test/recordings/renamePass" $ do + runSession "hie --lsp" "test/data/renamePass" $ do doc <- openDoc "Desktop/simple.hs" "haskell" skipMany loggingNotification - diagsNot <- notification :: Session PublishDiagnosticsNotification - - liftIO $ diagsNot ^. params . diagnostics `shouldBe` List [] - - sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc) + checkNoDiagnostics - rspSymbols <- response :: Session DocumentSymbolsResponse + rspSymbols <- documentSymbols doc liftIO $ do let (List symbols) = fromJust (rspSymbols ^. result) @@ -35,16 +31,44 @@ main = hspec $ do it "fails a test" $ -- TODO: Catch the exception in haskell-lsp-test and provide nicer output - let session = runSession "hie --lsp" "test/recordings/renamePass" $ do + let session = runSession "hie --lsp" "test/data/renamePass" $ do openDoc "Desktop/simple.hs" "haskell" skipMany loggingNotification anyRequest in session `shouldThrow` anyException + it "can get initialize response" $ runSession "hie --lsp" "test/data/renamePass" $ do + rsp <- getInitializeResponse + liftIO $ rsp ^. result `shouldNotBe` Nothing describe "replay session" $ do it "passes a test" $ - replaySession "hie --lsp" "test/recordings/renamePass" `shouldReturn` True + replaySession "hie --lsp" "test/data/renamePass" `shouldReturn` True it "fails a test" $ - replaySession "hie --lsp" "test/recordings/renameFail" `shouldReturn` False + replaySession "hie --lsp" "test/data/renameFail" `shouldReturn` False + + describe "manual javascript session" $ + it "passes a test" $ + runSession "javascript-typescript-stdio" "test/data/javascriptPass" $ do + doc <- openDoc "test.js" "javascript" + + checkNoDiagnostics + + rspSymbols <- documentSymbols doc + + let (List symbols) = fromJust (rspSymbols ^. result) + fooSymbol = head symbols + liftIO $ do + fooSymbol ^. name `shouldBe` "foo" + fooSymbol ^. kind `shouldBe` SkFunction parsingSpec + +checkNoDiagnostics :: Session () +checkNoDiagnostics = do + diagsNot <- notification :: Session PublishDiagnosticsNotification + liftIO $ diagsNot ^. params . diagnostics `shouldBe` List [] + +documentSymbols :: TextDocumentIdentifier -> Session DocumentSymbolsResponse +documentSymbols doc = do + sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc) + response \ No newline at end of file