summaryrefslogtreecommitdiff
path: root/js_test.go
diff options
context:
space:
mode:
authorPhilipp Tanlak <philipp.tanlak@gmail.com>2023-09-24 23:36:00 +0200
committerPhilipp Tanlak <philipp.tanlak@gmail.com>2023-09-24 23:36:00 +0200
commitbd9e7f7acfd855d4685aa4544169c0e29cdbf205 (patch)
treec5218c65359c0c2dee5a8db2670f30db677f068a /js_test.go
parent08df9258a532b653c243e077e82491dbe62ad854 (diff)
clean up modules
Diffstat (limited to 'js_test.go')
-rw-r--r--js_test.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/js_test.go b/js_test.go
index 7496c68..9366a15 100644
--- a/js_test.go
+++ b/js_test.go
@@ -25,7 +25,7 @@ var html = `
var script = `
import { parse } from "flyscrape";
-export const options = {
+export const config = {
url: "https://localhost/",
}
@@ -41,9 +41,9 @@ export default function({ html, url }) {
`
func TestJSScrape(t *testing.T) {
- opts, run, err := flyscrape.Compile(script)
+ cfg, run, err := flyscrape.Compile(script)
require.NoError(t, err)
- require.NotNil(t, opts)
+ require.NotNil(t, cfg)
require.NotNil(t, run)
result, err := run(flyscrape.ScrapeParams{
@@ -61,9 +61,9 @@ func TestJSScrape(t *testing.T) {
}
func TestJSCompileError(t *testing.T) {
- opts, run, err := flyscrape.Compile("import foo;")
+ cfg, run, err := flyscrape.Compile("import foo;")
require.Error(t, err)
- require.Empty(t, opts)
+ require.Empty(t, cfg)
require.Nil(t, run)
var terr flyscrape.TransformError
@@ -76,31 +76,31 @@ func TestJSCompileError(t *testing.T) {
})
}
-func TestJSOptions(t *testing.T) {
+func TestJSConfig(t *testing.T) {
js := `
- export const options = {
+ export const config = {
url: 'http://localhost/',
depth: 5,
allowedDomains: ['example.com'],
}
export default function() {}
`
- rawOpts, _, err := flyscrape.Compile(js)
+ rawCfg, _, err := flyscrape.Compile(js)
require.NoError(t, err)
- type options struct {
+ type config struct {
URL string `json:"url"`
Depth int `json:"depth"`
AllowedDomains []string `json:"allowedDomains"`
}
- var opts options
- err = json.Unmarshal(rawOpts, &opts)
+ var cfg config
+ err = json.Unmarshal(rawCfg, &cfg)
require.NoError(t, err)
- require.Equal(t, options{
+ require.Equal(t, config{
URL: "http://localhost/",
Depth: 5,
AllowedDomains: []string{"example.com"},
- }, opts)
+ }, cfg)
}