-
Notifications
You must be signed in to change notification settings - Fork 0
/
reference_test.go
51 lines (40 loc) · 1.13 KB
/
reference_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
package gorgeous
import "testing"
func TestCreateRef(t *testing.T) {
ref := CreateRef("test")
if ref.name != "test" {
t.Errorf("CreateRef(\"test\") did not set name to \"test\", got: \"%s\"", ref.name)
}
}
func TestReferenceGet(t *testing.T) {
ref := CreateRef("test")
el := Div(EB{})
ref.Get(el)
if ref.element.Id != el.Id {
t.Errorf("Get(el) did not set elementId to el.Id, got: \"%s\"", ref.element.Id)
}
}
func TestReferenceJavascript(t *testing.T) {
ref := CreateRef("test")
el := Div(EB{})
ref.Get(el)
if ref.Javascript().String() != "referenceCacheGet(\""+el.Id+"\")" {
t.Errorf("Element() did not return \"referenceCacheGet(\"+el.Id+\")\", got: \"%s\"", ref.Javascript())
}
}
func TestReferenceCacheServiceAdded(t *testing.T) {
ref := CreateRef("test")
el := Div(EB{})
ref.Get(el)
if services[ReferenceCacheServiceName] != ReferenceCacheService {
t.Errorf("ReferenceCacheService was not added to services map")
}
}
func TestReferenceElement(t *testing.T) {
ref := CreateRef("test")
el := Div(EB{})
ref.Get(el)
if ref.Element() != el {
t.Errorf("Element() did not return el, got: \"%v\"", ref.Element())
}
}