summaryrefslogtreecommitdiff
path: root/js_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'js_test.go')
-rw-r--r--js_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/js_test.go b/js_test.go
index 4b08720..1141f9c 100644
--- a/js_test.go
+++ b/js_test.go
@@ -260,6 +260,27 @@ func TestJSScrapeParamScrapeDeep(t *testing.T) {
}, result)
}
+func TestJSScrapeParamFollow(t *testing.T) {
+ js := `
+ export default function({ follow }) {
+ follow("/foo")
+ }
+ `
+ exports, err := flyscrape.Compile(js, nil)
+ require.NoError(t, err)
+
+ var followedURL string
+ _, err = exports.Scrape(flyscrape.ScrapeParams{
+ HTML: html,
+ URL: "http://localhost/",
+ Follow: func(url string) {
+ followedURL = url
+ },
+ })
+ require.NoError(t, err)
+ require.Equal(t, "http://localhost/foo", followedURL)
+}
+
func TestJSCompileError(t *testing.T) {
exports, err := flyscrape.Compile("import foo;", nil)
require.Error(t, err)