diff options
| author | Philipp Tanlak <philipp.tanlak@gmail.com> | 2023-07-27 19:03:41 +0200 |
|---|---|---|
| committer | Philipp Tanlak <philipp.tanlak@gmail.com> | 2023-07-27 19:03:41 +0200 |
| commit | a9b61f84070cc7ca0d6e26f187c745619a91422a (patch) | |
| tree | d69b67142b6de860d7da23bd5ff8c62af0aaca1e /js/js_test.go | |
init
Diffstat (limited to 'js/js_test.go')
| -rw-r--r-- | js/js_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/js/js_test.go b/js/js_test.go new file mode 100644 index 0000000..877ac8b --- /dev/null +++ b/js/js_test.go @@ -0,0 +1,36 @@ +package js_test + +import ( + "io" + "net/http" + "testing" + + "flyscrape/js" + + "github.com/stretchr/testify/require" +) + +func TestV8(t *testing.T) { + opts, run, err := js.Compile("../examples/esbuild.github.io.js") + require.NoError(t, err) + + html := fetch(opts.URL) + json := run(js.RunOptions{ + HTML: html, + }) + + t.Log(json) +} + +func fetch(url string) string { + resp, err := http.Get(url) + if err != nil { + return "" + } + defer resp.Body.Close() + b, err := io.ReadAll(resp.Body) + if err != nil { + return "" + } + return string(b) +} |