-
Notifications
You must be signed in to change notification settings - Fork 1
/
uia_test.go
63 lines (58 loc) · 1.16 KB
/
uia_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package jaws
import (
"html/template"
"reflect"
"testing"
)
type testHTMLGetter string
func (g testHTMLGetter) JawsGetHTML(e *Element) template.HTML {
return template.HTML(g)
}
var _ HTMLGetter = testHTMLGetter("foo")
func TestRequest_A(t *testing.T) {
type args struct {
innerHTML any
params []any
}
tests := []struct {
name string
args args
want template.HTML
}{
{
name: "string",
args: args{
innerHTML: "string",
params: []any{},
},
want: `<a id="Jid.1">string</a>`,
},
{
name: "template.HTML",
args: args{
innerHTML: template.HTML("<div></div>"),
params: []any{`href="#"`},
},
want: `<a id="Jid.1" href="#"><div></div></a>`,
},
{
name: "HTMLGetter",
args: args{
innerHTML: testHTMLGetter("<div></div>"),
params: []any{},
},
want: `<a id="Jid.1"><div></div></a>`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
nextJid = 0
rq := newTestRequest()
defer rq.Close()
rq.A(tt.args.innerHTML, tt.args.params...)
if got := rq.BodyHTML(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Request.A() = %v, want %v", got, tt.want)
}
})
}
}