X-Git-Url: http://git.lukelau.me/?a=blobdiff_plain;f=test%2FTest.hs;h=16c8d01cdb57be9f4710a98df48ad00c121c6fa3;hb=edee40c4aba2607c652cace2da780c373612665f;hp=ca135c7a379c3790f80e640262610b8887bde55b;hpb=12ac9c23d054e92a82146320e2b061c11a87e3f1;p=lsp-test.git diff --git a/test/Test.hs b/test/Test.hs index ca135c7..16c8d01 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 "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,7 +31,7 @@ main = hspec $ do it "fails a test" $ -- TODO: Catch the exception in haskell-lsp-test and provide nicer output - let session = runSession "test/recordings/renamePass" $ do + let session = runSession "hie --lsp" "test/data/renamePass" $ do openDoc "Desktop/simple.hs" "haskell" skipMany loggingNotification anyRequest @@ -43,8 +39,33 @@ main = hspec $ do describe "replay session" $ do it "passes a test" $ - replaySession "test/recordings/renamePass" `shouldReturn` True + replaySession "hie --lsp" "test/data/renamePass" `shouldReturn` True it "fails a test" $ - replaySession "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