From 062b36fe5725d1267c66db2e506b4131d78ce772 Mon Sep 17 00:00:00 2001 From: Philipp Tanlak Date: Fri, 11 Aug 2023 18:31:20 +0200 Subject: simplify project structure --- js_test.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 js_test.go (limited to 'js_test.go') diff --git a/js_test.go b/js_test.go new file mode 100644 index 0000000..34c4183 --- /dev/null +++ b/js_test.go @@ -0,0 +1,38 @@ +package flyscrape_test + +import ( + "os" + "testing" + + "flyscrape" + + "github.com/stretchr/testify/require" +) + +var html = ` + + +
+

Plugins

+

The plugin API allows you to inject code into various parts of the build process.

+
+ +` + +func TestV8(t *testing.T) { + data, err := os.ReadFile("examples/esbuild.github.io.js") + require.NoError(t, err) + + opts, run, err := flyscrape.Compile(string(data)) + require.NoError(t, err) + require.NotNil(t, opts) + require.NotNil(t, run) + + extract, err := run(flyscrape.ScrapeParams{ + HTML: html, + }) + + require.NoError(t, err) + require.Equal(t, "Plugins", extract.(map[string]any)["headline"]) + require.Equal(t, "The plugin API allows you to inject code into various parts of the build process.", extract.(map[string]any)["body"]) +} -- cgit v1.2.3