Skip to content

Commit 5f4a4d8

Browse files
committed
More tests, and minor cleanup
1 parent fa8dc89 commit 5f4a4d8

File tree

1 file changed

+95
-4
lines changed

1 file changed

+95
-4
lines changed

src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostWrapWithTagEndpointTest.cs

Lines changed: 95 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;
1818
public class CohostWrapWithTagEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper)
1919
{
2020
[Fact]
21-
public async Task ValidHtmlLocation_ReturnsResult()
21+
public async Task InsideHtml()
2222
{
2323
await VerifyWrapWithTagAsync(
2424
input: """
@@ -38,7 +38,98 @@ await VerifyWrapWithTagAsync(
3838
}
3939

4040
[Fact]
41-
public async Task CSharpLocation_ReturnsNull()
41+
public async Task HtmlInCSharp()
42+
{
43+
await VerifyWrapWithTagAsync(
44+
input: """
45+
@if (true)
46+
{
47+
[|<p></p>|]
48+
}
49+
""",
50+
expected: """
51+
@if (true)
52+
{
53+
<div><p></p></div>
54+
}
55+
""",
56+
htmlResponse: new VSInternalWrapWithTagResponse(
57+
LspFactory.CreateSingleLineRange(start: (1, 4), length: 0),
58+
[
59+
LspFactory.CreateTextEdit(position: (2, 4), "<div>"),
60+
LspFactory.CreateTextEdit(position: (2, 11), "</div>")
61+
]
62+
));
63+
}
64+
65+
[Fact]
66+
public async Task HtmlInCSharp_WithWhitespace()
67+
{
68+
await VerifyWrapWithTagAsync(
69+
input: """
70+
@if (true)
71+
{
72+
[| <p></p> |]
73+
}
74+
""",
75+
expected: """
76+
@if (true)
77+
{
78+
<div><p></p></div>
79+
}
80+
""",
81+
htmlResponse: new VSInternalWrapWithTagResponse(
82+
LspFactory.CreateSingleLineRange(start: (1, 4), length: 0),
83+
[
84+
LspFactory.CreateTextEdit(2, 4, 2, 5, "<div>"),
85+
LspFactory.CreateTextEdit(2, 12, 2, 13, "</div>")
86+
]
87+
));
88+
}
89+
90+
[Fact]
91+
public async Task NotInHtmlInCSharp_WithNewline()
92+
{
93+
await VerifyWrapWithTagAsync(
94+
input: """
95+
@if (true)
96+
{[|
97+
<p></p>|]
98+
}
99+
""",
100+
expected: null,
101+
htmlResponse: null);
102+
}
103+
104+
[Fact]
105+
public async Task RazorBlockStart()
106+
{
107+
await VerifyWrapWithTagAsync(
108+
input: """
109+
[|@if (true) { }
110+
<div>
111+
</div>|]
112+
""",
113+
expected: """
114+
<div>
115+
@if (true) { }
116+
<div>
117+
</div>
118+
</div>
119+
""",
120+
htmlResponse: new VSInternalWrapWithTagResponse(
121+
LspFactory.CreateSingleLineRange(start: (1, 4), length: 0),
122+
[
123+
LspFactory.CreateTextEdit(position: (0, 0), $"<div>{Environment.NewLine} "),
124+
LspFactory.CreateTextEdit(position: (1, 0), " "),
125+
LspFactory.CreateTextEdit(position: (2, 0), " "),
126+
LspFactory.CreateTextEdit(position: (2, 6), $"{Environment.NewLine}</div>")
127+
]
128+
));
129+
}
130+
131+
[Fact]
132+
public async Task NotInCodeBlock()
42133
{
43134
await VerifyWrapWithTagAsync(
44135
input: """
@@ -51,7 +142,7 @@ await VerifyWrapWithTagAsync(
51142
}
52143

53144
[Fact]
54-
public async Task ImplicitExpression_ReturnsResult()
145+
public async Task ImplicitExpression()
55146
{
56147
await VerifyWrapWithTagAsync(
57148
input: """
@@ -71,7 +162,7 @@ await VerifyWrapWithTagAsync(
71162
}
72163

73164
[Fact]
74-
public async Task HtmlWithTildes_FixesTextEdits()
165+
public async Task HtmlWithTildes()
75166
{
76167
await VerifyWrapWithTagAsync(
77168
input: """

0 commit comments

Comments
 (0)