diff options
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) +} |