blob: 1365b341731c5e2b0f8f15af760640bfaa55dd4d (
plain)
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
|
package dom
import "testing"
func TestClassList(t *testing.T) {
cl := NewClassList()
if cl.Has("foo") {
t.Errorf("class foo was never added")
}
cl.Add("foo")
if !cl.Has("foo") {
t.Errorf("class foo was added")
}
cl.Add("bar")
if !cl.Has("bar") {
t.Errorf("class bar was added")
}
if !cl.Has("foo") {
t.Errorf("class foo was not removed")
}
cl.Remove("foo")
if cl.Has("foo") {
t.Errorf("class foo was removed")
}
if !cl.Has("bar") {
t.Errorf("class bar was not removed")
}
cl.Toggle("foo")
if !cl.Has("foo") {
t.Errorf("class foo was toggled (added)")
}
cl.Toggle("foo")
if cl.Has("foo") {
t.Errorf("class foo was toggled (removed)")
}
}
|