@@ -11,61 +11,37 @@ import (
11
11
"github.com/gost-dom/browser/html"
12
12
"github.com/gost-dom/browser/internal/gosthttp"
13
13
"github.com/gost-dom/browser/internal/testing/eventtest"
14
+ "github.com/gost-dom/browser/internal/testing/fixtures"
14
15
. "github.com/gost-dom/browser/internal/testing/gomega-matchers"
15
16
"github.com/gost-dom/browser/internal/testing/htmltest"
16
17
. "github.com/gost-dom/browser/testing/gomega-matchers"
17
18
"github.com/gost-dom/fixture"
18
- "github.com/onsi/gomega"
19
- "github.com/onsi/gomega/types"
20
- "github.com/stretchr/testify/assert"
21
19
)
22
20
23
- type AssertFixture struct {
24
- fixture.Fixture
25
- assert * assert.Assertions
26
- gomega gomega.Gomega
27
- }
28
-
29
- func (f * AssertFixture ) Assert () * assert.Assertions {
30
- if f .assert == nil {
31
- f .assert = assert .New (f .TB )
32
- }
33
- return f .assert
34
- }
35
-
36
- func (f * AssertFixture ) Expect (actual interface {}, extra ... interface {}) types.Assertion {
37
- if f .gomega == nil {
38
- f .gomega = gomega .NewWithT (f .TB )
39
- }
40
- return f .gomega .Expect (actual , extra ... )
41
- }
42
-
43
- type HTTPHandlerFixture struct {
44
- * http.ServeMux
45
- }
21
+ type HTTPHandlerFixture struct { * http.ServeMux }
46
22
47
23
func (f * HTTPHandlerFixture ) Setup () {
48
- f .ServeMux = http .NewServeMux ()
24
+ if f .ServeMux == nil {
25
+ f .ServeMux = http .NewServeMux ()
26
+ }
49
27
}
50
28
51
29
type WindowFixture struct {
52
- AssertFixture
53
- BaseLocation string
30
+ fixtures.AssertFixture
54
31
* HTTPHandlerFixture
55
- Window htmltest.WindowHelper
56
32
57
- form html.HTMLFormElement
33
+ Window htmltest.WindowHelper
34
+ BaseLocation string
58
35
}
59
36
60
37
func (f * WindowFixture ) Setup () {
61
38
if f .Window .Window != nil {
62
39
return
63
40
}
64
- opts := html.WindowOptions {
41
+ win := html . NewWindow ( html.WindowOptions {
65
42
BaseLocation : f .BaseLocation ,
66
43
HttpClient : gosthttp .NewHttpClientFromHandler (f .HTTPHandlerFixture ),
67
- }
68
- win := html .NewWindow (opts )
44
+ })
69
45
f .Window = htmltest .NewWindowHelper (f .TB , win )
70
46
71
47
f .Helper ()
@@ -129,9 +105,7 @@ type HTMLFormFixture struct {
129
105
}
130
106
131
107
func TestSubmitForm (t * testing.T ) {
132
- w , setup := fixture .Init (t , & struct {
133
- DefaultWindowFixture
134
- }{})
108
+ w , setup := fixture .Init (t , & DefaultWindowFixture {})
135
109
w .BaseLocation = "http://example.com/forms/example-form.html?original-query=original-value"
136
110
setup .Setup ()
137
111
0 commit comments