summaryrefslogtreecommitdiff
path: root/scrape/query_test.go
blob: 0e8423d06cb4170c3a287fc938be763159b42ed2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package scrape

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestQuery(t *testing.T) {
	html := `<html>
<body>
	<h1 id="title">Page Title</h1>
	<div id="posts">
		<div class="post">First post</div>
		<div class="post">Second post</div>
		<div class="post">Third post</div>
	</div>
</body>
</html>`

	title := Query(Doc(html), "#title")
	require.Equal(t, title, "Page Title")
}