mirror of
https://github.com/Dvorinka/Devour.git
synced 2026-06-03 20:13:03 +00:00
34 lines
772 B
Go
34 lines
772 B
Go
package scraper
|
|
|
|
import "testing"
|
|
|
|
func TestNormalizeDocument_TitleCleanup(t *testing.T) {
|
|
doc := &Document{
|
|
Title: "http.type CloseNotifier ¶ deprecated added in go1.1",
|
|
Content: "line 1 \n\n\nline 2",
|
|
URL: "https://pkg.go.dev/net/http#CloseNotifier",
|
|
}
|
|
|
|
NormalizeDocument(doc)
|
|
|
|
if doc.Title != "http.type CloseNotifier" {
|
|
t.Fatalf("unexpected normalized title: %q", doc.Title)
|
|
}
|
|
if doc.Content != "line 1\n\nline 2" {
|
|
t.Fatalf("unexpected normalized content: %q", doc.Content)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeDocument_InferTitle(t *testing.T) {
|
|
doc := &Document{
|
|
Title: "",
|
|
URL: "https://kotlinlang.org/docs/regex.html",
|
|
}
|
|
|
|
NormalizeDocument(doc)
|
|
|
|
if doc.Title != "regex" {
|
|
t.Fatalf("expected inferred title 'regex', got %q", doc.Title)
|
|
}
|
|
}
|