MatchElemAttr func implementation
This commit is contained in:
26
match_test.go
Normal file
26
match_test.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package scraper
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/net/html"
|
||||
)
|
||||
|
||||
const fragment = `<div id="main-copy"></div>`
|
||||
|
||||
func TestMatchElemAttr(t *testing.T) {
|
||||
n, err := html.ParseFragment(strings.NewReader(fragment), body)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
n1 := n[0]
|
||||
|
||||
result, err := MatchElemAttr(fragment, n1)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if !result {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user