Skip to content

Commit d3f1d5b

Browse files
In HtmlValidatorTests add Validate_WhenWorkingDirectoryAndConfigPathAreAbsolute test
1 parent d78fb30 commit d3f1d5b

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"elements": [
3+
"html5"
4+
],
5+
"extends": [
6+
"html-validate:recommended"
7+
],
8+
"rules": {
9+
"no-trailing-whitespace": "off"
10+
}
11+
}

test/Atata.HtmlValidation.IntegrationTests/Atata.HtmlValidation.IntegrationTests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
</ItemGroup>
1717

1818
<ItemGroup>
19+
<None Update=".htmlvalidate.json">
20+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
21+
</None>
1922
<None Update="TestPages\Errors0.html">
2023
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2124
</None>

test/Atata.HtmlValidation.IntegrationTests/HtmlValidatorTests.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,44 @@ public void Validate_WithManyErrors()
5050

5151
Directory.Delete(workingDirectory, true);
5252
}
53+
54+
[Test]
55+
public void Validate_WhenWorkingDirectoryAndConfigPathAreAbsolute()
56+
{
57+
string workingDirectory = Path.Combine(
58+
AppDomain.CurrentDomain.BaseDirectory,
59+
"artifacts",
60+
Path.GetRandomFileName());
61+
62+
HtmlValidator sut = new(
63+
new()
64+
{
65+
OutputFormatter = HtmlValidateFormatter.Names.Json,
66+
WorkingDirectory = workingDirectory,
67+
ConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ".htmlvalidate.json")
68+
},
69+
null);
70+
71+
StringBuilder htmlBuilder = new(
72+
"""
73+
<!DOCTYPE html>
74+
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
75+
<head>
76+
<meta charset="utf-8">
77+
<title>Some title</title>
78+
</head>
79+
<body>
80+
Hello world!
81+
</body>
82+
</html>
83+
""");
84+
85+
var result = sut.Validate(htmlBuilder.ToString());
86+
87+
result.ToResultSubject()
88+
.ValueOf(x => x.IsSuccessful).Should.BeTrue()
89+
.ValueOf(x => x.Output).Should.Be("[]")
90+
.ValueOf(x => x.HtmlFilePath).Should.BeNull()
91+
.ValueOf(x => x.ResultFilePath).Should.BeNull();
92+
}
5393
}

0 commit comments

Comments
 (0)