-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathswap_test.go
46 lines (43 loc) · 1.04 KB
/
swap_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
package htmx
import (
"testing"
"time"
)
func TestSwapStrategy_SwapString(t *testing.T) {
testCases := []struct {
name string
swapStrategy SwapStrategy
result string
}{
{
name: "no modifier",
swapStrategy: SwapInnerHTML,
result: "innerHTML",
},
{
name: "one modifier",
swapStrategy: SwapInnerHTML.Transition(true),
result: "innerHTML transition:true",
},
{
name: "many modifiers",
swapStrategy: SwapInnerHTML.Transition(true).
IgnoreTitle(true).
FocusScroll(true).
After(5*time.Second).
SettleAfter(5*time.Second).
Scroll(Top).
ScrollOn("#another-div", Top).
ScrollWindow(Top).
Show(Top).
ShowOn("#another-div", Top).ShowWindow(Top).
ShowNone(),
result: "innerHTML transition:true ignoreTitle:true focusScroll:true swap:5s settle:5s scroll:window:top show:none",
},
}
for _, tc := range testCases {
if result := tc.swapStrategy.swapString(); result != tc.result {
t.Errorf(`got: "%v", want: "%v"`, result, tc.result)
}
}
}