Skip to content

Commit 197d7d9

Browse files
committed
test: Cleanup remnants of code depending on ginko
Removes almost dead code in scripttests, and convert some old usages
1 parent 1a677cd commit 197d7d9

File tree

5 files changed

+14
-103
lines changed

5 files changed

+14
-103
lines changed

internal/test/scripttests/script_test_suite.go

-79
This file was deleted.

scripting/gojahost/gojahost_suite_test.go

-7
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,15 @@ import (
44
"log/slog"
55
"testing"
66

7-
"github.com/gost-dom/browser/html"
87
"github.com/gost-dom/browser/internal/test"
9-
. "github.com/gost-dom/browser/internal/test/scripttests"
108
"github.com/gost-dom/browser/logger"
11-
. "github.com/gost-dom/browser/scripting/gojahost"
129

1310
"github.com/dop251/goja"
1411
. "github.com/onsi/ginkgo/v2"
1512
. "github.com/onsi/gomega"
1613
"github.com/onsi/gomega/format"
1714
)
1815

19-
var testSuite = NewScriptTestSuite(New(), "goja", SkipDOM)
20-
21-
func newCtx() html.ScriptContext { return testSuite.NewContext() }
22-
2316
func FormatException(value any) (result string, ok bool) {
2417
var exception *goja.Exception
2518
if exception, ok = value.(*goja.Exception); ok {
+9-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
package gojahost_test
22

33
import (
4+
"github.com/gost-dom/browser/html"
5+
"github.com/gost-dom/browser/scripting/gojahost"
46
. "github.com/onsi/ginkgo/v2"
57
. "github.com/onsi/gomega"
68
)
79

810
var _ = Describe("goja: Node", func() {
911
Describe("Prototype", func() {
1012
It("Should have function installed", func() {
11-
ctx := newCtx()
12-
Expect(ctx.Run("const proto = Node.prototype")).To(Succeed())
13-
Expect(ctx.Eval("typeof proto.contains")).To(Equal("function"), "contains")
14-
Expect(ctx.Eval("typeof proto.insertBefore")).To(Equal("function"), "insertBefore")
15-
Expect(ctx.Eval("typeof proto.appendChild")).To(Equal("function"), "appendChild")
16-
Expect(ctx.Eval("typeof proto.removeChild")).To(Equal("function"), "removeChild")
13+
engine := gojahost.New()
14+
window := html.NewWindow(html.WindowOptions{ScriptHost: engine})
15+
Expect(window.Run("const proto = Node.prototype")).To(Succeed())
16+
Expect(window.Eval("typeof proto.contains")).To(Equal("function"), "contains")
17+
Expect(window.Eval("typeof proto.insertBefore")).To(Equal("function"), "insertBefore")
18+
Expect(window.Eval("typeof proto.appendChild")).To(Equal("function"), "appendChild")
19+
Expect(window.Eval("typeof proto.removeChild")).To(Equal("function"), "removeChild")
1720
})
1821
})
1922
})

scripting/v8host/html_test.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package v8host_test
22

33
import (
4+
"github.com/gost-dom/browser/html"
45
. "github.com/onsi/ginkgo/v2"
56
. "github.com/onsi/gomega"
67
)
78

89
var _ = Describe("V8 Append (element, document, document fragment)", func() {
910
It("Should accept multiple values", func() {
10-
ctx := scriptTestSuite.NewContext()
11-
Expect(ctx.Eval(`
11+
win := html.NewWindow(html.WindowOptions{ScriptHost: host})
12+
Expect(win.Eval(`
1213
const d = document.createElement("div")
1314
d.append(
1415
document.createElement("p"),
@@ -18,8 +19,8 @@ var _ = Describe("V8 Append (element, document, document fragment)", func() {
1819
})
1920

2021
It("Should accept text values", func() {
21-
ctx := scriptTestSuite.NewContext()
22-
Expect(ctx.Eval(`
22+
win := html.NewWindow(html.WindowOptions{ScriptHost: host})
23+
Expect(win.Eval(`
2324
const d = document.createElement("div")
2425
d.append(
2526
document.createElement("p"),

scripting/v8host/scripting_suite_test.go

-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/gost-dom/browser/html"
99
"github.com/gost-dom/browser/internal/gosthttp"
1010
"github.com/gost-dom/browser/internal/test"
11-
"github.com/gost-dom/browser/internal/test/scripttests"
1211
"github.com/gost-dom/browser/logger"
1312
. "github.com/gost-dom/browser/scripting/v8host"
1413
. "github.com/onsi/ginkgo/v2"
@@ -22,8 +21,6 @@ func TestScripting(t *testing.T) {
2221

2322
var host *V8ScriptHost
2423

25-
var scriptTestSuite *scripttests.ScriptTestSuite
26-
2724
func OpenTestWindowFromHandler(location string, handler http.Handler) (html.Window, error) {
2825
win, err := html.OpenWindowFromLocation(location, html.WindowOptions{
2926
ScriptHost: host,
@@ -41,10 +38,6 @@ func init() {
4138
logger.SetDefault(test.CreateTestLogger(slog.LevelWarn))
4239

4340
host = New()
44-
scriptTestSuite = scripttests.NewScriptTestSuite(host, "v8")
45-
46-
BeforeSuite(func() {
47-
})
4841

4942
AfterSuite(func() {
5043
host.Close()

0 commit comments

Comments
 (0)