Skip to content

Commit dd5b4f5

Browse files
TheBlob42artempyanykh
authored andcommitted
test: tags test adaptions
- fix tags completion tests - add tags to document symbol tests - implement workspace symbol tests (including tags)
1 parent cb44455 commit dd5b4f5

File tree

2 files changed

+82
-11
lines changed

2 files changed

+82
-11
lines changed

Tests/SymbolsTests.fs

+73-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,76 @@ open Xunit
44

55
open Ionide.LanguageServerProtocol.Types
66

7+
open Marksman.Misc
78
open Marksman.Helpers
9+
open Marksman.Workspace
10+
11+
module WorkspaceSymbol =
12+
let doc1 =
13+
FakeDoc.Mk(path = "doc1.md", contentLines = [| "# A"; "#tag1" |])
14+
15+
let doc2 =
16+
FakeDoc.Mk(path = "doc2.md", contentLines = [| "# B"; "#tag1 #tag2" |])
17+
18+
let folder = FakeFolder.Mk [ doc1; doc2 ]
19+
let workspace = Workspace.ofFolders None [ folder ]
20+
21+
[<Fact>]
22+
let symbols_noQuery =
23+
let symbols = Symbols.workspaceSymbols "" workspace
24+
25+
Assert.Equal(
26+
[ { Name = "H1: A"
27+
Kind = SymbolKind.String
28+
ContainerName = None
29+
Location = { Uri = (Doc.uri doc1); Range = Range.Mk(0, 0, 0, 3) } }
30+
{ Name = "Tag: tag1"
31+
Kind = SymbolKind.String
32+
ContainerName = None
33+
Location = { Uri = (Doc.uri doc1); Range = Range.Mk(1, 0, 1, 5) } }
34+
{ Name = "H1: B"
35+
Kind = SymbolKind.String
36+
ContainerName = None
37+
Location = { Uri = (Doc.uri doc2); Range = Range.Mk(0, 0, 0, 3) } }
38+
{ Name = "Tag: tag1"
39+
Kind = SymbolKind.String
40+
ContainerName = None
41+
Location = { Uri = (Doc.uri doc2); Range = Range.Mk(1, 0, 1, 5) } }
42+
{ Name = "Tag: tag2"
43+
Kind = SymbolKind.String
44+
ContainerName = None
45+
Location = { Uri = (Doc.uri doc2); Range = Range.Mk(1, 6, 1, 11) } } ],
46+
symbols
47+
)
48+
49+
[<Fact>]
50+
let symbols_withQuery () =
51+
let symbols = Symbols.workspaceSymbols "Tag:" workspace
52+
53+
Assert.Equal(
54+
[ { Name = "Tag: tag1"
55+
Kind = SymbolKind.String
56+
ContainerName = None
57+
Location = { Uri = (Doc.uri doc1); Range = Range.Mk(1, 0, 1, 5) } }
58+
{ Name = "Tag: tag1"
59+
Kind = SymbolKind.String
60+
ContainerName = None
61+
Location = { Uri = (Doc.uri doc2); Range = Range.Mk(1, 0, 1, 5) } }
62+
{ Name = "Tag: tag2"
63+
Kind = SymbolKind.String
64+
ContainerName = None
65+
Location = { Uri = (Doc.uri doc2); Range = Range.Mk(1, 6, 1, 11) } } ],
66+
symbols
67+
)
868

969
module DocSymbols =
1070
let fakeDoc =
1171
FakeDoc.Mk(
1272
[| "# E" //
1373
"## D"
74+
"#t1"
1475
"### B"
76+
"#t2"
1577
"## C"
1678
"# A" |]
1779
)
@@ -26,7 +88,16 @@ module DocSymbols =
2688
| _ -> failwith "Unexpected symbol type"
2789
|> Array.map (fun x -> x.Name)
2890

29-
Assert.Equal<string>([| "H1: E"; "H2: D"; "H3: B"; "H2: C"; "H1: A" |], symNames)
91+
Assert.Equal<string>(
92+
[| "H1: E"
93+
"H2: D"
94+
"H3: B"
95+
"H2: C"
96+
"H1: A"
97+
"Tag: t1"
98+
"Tag: t2" |],
99+
symNames
100+
)
30101

31102
[<Fact>]
32103
let order_Hierarchy () =
@@ -45,4 +116,4 @@ module DocSymbols =
45116

46117
syms |> Array.iter collect
47118

48-
Assert.Equal<string>([| "E"; "D"; "B"; "C"; "A" |], names)
119+
Assert.Equal<string>([| "E"; "D"; "t1"; "B"; "t2"; "C"; "A" |], names)

Tests/_snapshots/Tags.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"tagOpening": {
33
"AutoGenerated": [
4-
"(1,16)-(1,16): tag / ",
5-
"(1,16)-(1,16): anotherTag / ",
6-
"(1,16)-(1,16): ta / ",
7-
"(1,16)-(1,16): somethingElse / ",
8-
"(1,16)-(1,16): otherDocTag / "
4+
"(1,16)-(1,16): tag / <no-filter>",
5+
"(1,16)-(1,16): anotherTag / <no-filter>",
6+
"(1,16)-(1,16): ta / <no-filter>",
7+
"(1,16)-(1,16): somethingElse / <no-filter>",
8+
"(1,16)-(1,16): otherDocTag / <no-filter>"
99
]
1010
},
1111
"tagWithName": {
1212
"AutoGenerated": [
13-
"(2,13)-(2,15): tag / ta",
14-
"(2,13)-(2,15): anotherTag / ta",
15-
"(2,13)-(2,15): otherDocTag / ta"
13+
"(2,13)-(2,15): tag / <no-filter>",
14+
"(2,13)-(2,15): anotherTag / <no-filter>",
15+
"(2,13)-(2,15): otherDocTag / <no-filter>"
1616
]
1717
}
18-
}
18+
}

0 commit comments

Comments
 (0)