summaryrefslogtreecommitdiff
path: root/js_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'js_test.go')
-rw-r--r--js_test.go23
1 files changed, 18 insertions, 5 deletions
diff --git a/js_test.go b/js_test.go
index 34c4183..bf7bc46 100644
--- a/js_test.go
+++ b/js_test.go
@@ -1,7 +1,6 @@
package flyscrape_test
import (
- "os"
"testing"
"flyscrape"
@@ -19,11 +18,25 @@ var html = `
</body>
</html>`
-func TestV8(t *testing.T) {
- data, err := os.ReadFile("examples/esbuild.github.io.js")
- require.NoError(t, err)
+var script = `
+import { parse } from "flyscrape";
+
+export const options = {
+ url: "https://localhost/",
+}
- opts, run, err := flyscrape.Compile(string(data))
+export default function({ html, url }) {
+ const $ = parse(html);
+
+ return {
+ headline: $("h1").text(),
+ body: $("p").text()
+ }
+}
+`
+
+func TestV8(t *testing.T) {
+ opts, run, err := flyscrape.Compile(script)
require.NoError(t, err)
require.NotNil(t, opts)
require.NotNil(t, run)