-
Notifications
You must be signed in to change notification settings - Fork 3
/
jasmine-spec.go
108 lines (89 loc) · 1.89 KB
/
jasmine-spec.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package jasmine
// +testing
func caller(f func()) {
f()
}
func RunJasmineTests() {
Describe("testig basic jasmine functions", func() {
Describe("nesed siute", func() {
XIt("schould not be called", func() {
Expect(1).ToBe(2)
})
})
XDescribe("this suite should not be called", func() {
It("should not be called", func() {
Expect(1).ToBe(2)
})
})
})
Describe("testing basic expectations", func() {
It("test spec ToBe", func() {
Expect(true).ToBe(true)
Expect(true).Not.ToBe(false)
})
It("test spec ToEqual", func() {
Expect(1).ToEqual(1)
Expect(1).Not.ToEqual(2)
})
It("test spec ToMatch", func() {
Expect("foo").ToMatch("foo")
Expect("foo").Not.ToMatch("bar")
})
It("test spec ToBeDefined", func() {
Expect(1).ToBeDefined()
})
It("test spec ToBeNull", func() {
Expect(nil).ToBeNull()
})
It("test spec ToBeTruthy", func() {
Expect(true).ToBeTruthy()
Expect(false).Not.ToBeTruthy()
})
It("test spec ToBeFalsy", func() {
Expect(false).ToBeFalsy()
Expect(true).Not.ToBeFalsy()
})
It("test spec ToContain", func() {
array := []int{1, 2, 3}
exp := Expect(array)
exp.ToContain(2)
exp.Not.ToContain(5)
})
It("test spec ToBeLessThan", func() {
Expect(1).ToBeLessThan(4)
})
It("test spec ToBeGreaterThan", func() {
Expect(4).ToBeGreaterThan(1)
})
})
Describe("testing setup and teardown methods", func() {
var a = 0
BeforeEach(func() {
a = 1
})
AfterEach(func() {
a = 2
})
It("test setup and teardown", func() {
Expect(a).ToBe(1)
})
})
Describe("testing spy like functinallity with ItAsync", func() {
var ch chan bool
BeforeEach(func() {
ch = make(chan bool)
})
ItAsync("test toHaveBeenCalled", func(done func()) {
caller(func() {
go func() {
ch <- true
}()
})
go func() {
b := <-ch
Expect(b).ToBeTruthy()
done()
}()
})
})
}