-
-
Notifications
You must be signed in to change notification settings - Fork 389
/
Copy pathNotesTest.hs
64 lines (56 loc) · 2.48 KB
/
NotesTest.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
module Main (main) where
import Development.IDE.Test
import Ide.Plugin.Notes (Log, descriptor)
import System.Directory (canonicalizePath)
import System.FilePath ((</>))
import Test.Hls hiding (waitForBuildQueue)
plugin :: PluginTestDescriptor Log
plugin = mkPluginTestDescriptor descriptor "notes"
main :: IO ()
main = defaultTestRunner $
testGroup "Notes"
[ gotoNoteTests
]
gotoNoteTests :: TestTree
gotoNoteTests = testGroup "Goto Note Definition"
[ testCase "single_file" $ runSessionWithServer def plugin testDataDir $ do
doc <- openDoc "NoteDef.hs" "haskell"
waitForBuildQueue
waitForAllProgressDone
defs <- getDefinitions doc (Position 3 41)
liftIO $ do
fp <- canonicalizePath "NoteDef.hs"
defs @?= InL (Definition (InR [Location (filePathToUri fp) (Range (Position 8 9) (Position 8 9))]))
, testCase "liberal_format" $ runSessionWithServer def plugin testDataDir $ do
doc <- openDoc "NoteDef.hs" "haskell"
waitForBuildQueue
waitForAllProgressDone
defs <- getDefinitions doc (Position 5 64)
liftIO $ do
fp <- canonicalizePath "NoteDef.hs"
defs @?= InL (Definition (InR [Location (filePathToUri fp) (Range (Position 18 11) (Position 18 11))]))
, testCase "invalid_note" $ runSessionWithServer def plugin testDataDir $ do
doc <- openDoc "NoteDef.hs" "haskell"
waitForBuildQueue
waitForAllProgressDone
defs <- getDefinitions doc (Position 6 54)
liftIO $ do
defs @?= InL (Definition (InR []))
, testCase "no_note" $ runSessionWithServer def plugin testDataDir $ do
doc <- openDoc "NoteDef.hs" "haskell"
waitForBuildQueue
waitForAllProgressDone
defs <- getDefinitions doc (Position 1 0)
liftIO $ defs @?= InL (Definition (InR []))
, testCase "unopened_file" $ runSessionWithServer def plugin testDataDir $ do
doc <- openDoc "Other.hs" "haskell"
waitForCustomMessage "ghcide/cradle/loaded" (const $ Just ())
waitForBuildQueue
waitForAllProgressDone
defs <- getDefinitions doc (Position 5 20)
liftIO $ do
fp <- canonicalizePath "NoteDef.hs"
defs @?= InL (Definition (InR [Location (filePathToUri fp) (Range (Position 12 6) (Position 12 6))]))
]
testDataDir :: FilePath
testDataDir = "plugins" </> "hls-notes-plugin" </> "test" </> "testdata"