summaryrefslogtreecommitdiff
path: root/scrape/query_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'scrape/query_test.go')
-rw-r--r--scrape/query_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/scrape/query_test.go b/scrape/query_test.go
new file mode 100644
index 0000000..0e8423d
--- /dev/null
+++ b/scrape/query_test.go
@@ -0,0 +1,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")
+}