-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Htmx_test.go
37 lines (30 loc) · 1009 Bytes
/
Htmx_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
package hb
import (
"strings"
"testing"
)
func TestHx(t *testing.T) {
input := NewButton().
Hx("post", "http://test.com").
Hx("include", "#DivID").
Hx("target", "#PageID").
Hx("swap", "outerHTML").
HTML("Submit").
ToHTML()
if strings.Contains(input, ` hx-post="http://test.com"`) == false {
t.Error(`Does not contain ' hx-post="http://test.com"', Output:` + input)
}
if strings.Contains(input, ` hx-include="#DivID"`) == false {
t.Error(`Does not contain ' hx-include="#DivID"', Output:` + input)
}
if strings.Contains(input, ` hx-target="#PageID"`) == false {
t.Error(`Does not contain ' hx-target="#PageID"', Output:` + input)
}
if strings.Contains(input, ` hx-swap="outerHTML"`) == false {
t.Error(`Does not contain ' hx-swap="outerHTML"', Output:` + input)
}
expected := `<button hx-include="#DivID" hx-post="http://test.com" hx-swap="outerHTML" hx-target="#PageID">Submit</button>`
if input != expected {
t.Error(`Expected: `, expected, `, Output:`, input)
}
}