Skip to content

Commit

Permalink
Add a test running on an HTML file
Browse files Browse the repository at this point in the history
  • Loading branch information
divinerites committed Aug 4, 2021
1 parent 4c57ae9 commit 295f004
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
17 changes: 16 additions & 1 deletion htmltest/check-link_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package htmltest

import (
"github.com/wjdp/htmltest/issues"
"testing"

"github.com/wjdp/htmltest/issues"
)

// Spec tests
Expand Down Expand Up @@ -492,6 +493,20 @@ func TestAnchorInternalHashWeird(t *testing.T) {
tExpectIssueCount(t, hT, 0)
}

func TestAnchorInternalUrl(t *testing.T) {
// fails for internal linking writen not in IgnoreInternalURLs (#168)
hT := tTestFile("fixtures/links/link_directory_internal_invalid.html")
tExpectIssueCount(t, hT, 1)
tExpectIssue(t, hT, "target is an internal URL not writen in IgnoreInternalURLs option", 1)
}

func TestAnchorInternalUrlOption(t *testing.T) {
// passes for internal linking writen in IgnoreInternalURLs option (#168)
hT := tTestFileOpts("fixtures/links/link_directory_internal_valid.html",
map[string]interface{}{"IgnoreInternalURLs": "/misc/js/script.js"})
tExpectIssueCount(t, hT, 0)
}

func TestAnchorMultipleProblems(t *testing.T) {
// finds a mix of broken and unbroken links
t.Skip("Only single problem, and an hash which is not yet supported.")
Expand Down
9 changes: 9 additions & 0 deletions htmltest/fixtures/links/link_directory_internal_invalid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>

<body>

<p>Blah blah blah. <a href="misc/js/script.js">Unknown internal URL</a> </p>

</body>

</html>
9 changes: 9 additions & 0 deletions htmltest/fixtures/links/link_directory_internal_valid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>

<body>

<p>Blah blah blah. <a href="/misc/js/script.js">Known internal URL</a> </p>

</body>

</html>

0 comments on commit 295f004

Please sign in to comment.