27 lines
385 B
Go
27 lines
385 B
Go
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()
|
|
}
|
|
}
|