-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathreal_test.go
More file actions
34 lines (26 loc) · 793 Bytes
/
real_test.go
File metadata and controls
34 lines (26 loc) · 793 Bytes
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
package clock
import . "github.com/101loops/bdd"
var _ = Describe("Real Clock", func() {
var clock = New()
It("Now()", func() {
clockNow := clock.Now()
Check(clockNow.Sub(now()), IsLessThan, delay)
})
It("Sleep()", func() {
slept := durationOf(func() { clock.Sleep(delay) })
Check(slept, IsRoughly, delay, threshold)
})
It("After()", func() {
elapsed := durationOf(func() { <-clock.After(delay) })
Check(elapsed, IsRoughly, delay, threshold)
})
It("Ticker()", func() {
ticker := clock.Ticker(delay).C
elapsed := durationOf(func() { <-ticker; <-ticker })
Check(elapsed, IsRoughly, 2*delay, threshold)
})
It("Tick()", func() {
elapsed := durationOf(func() { <-clock.Tick(delay); <-clock.Tick(delay) })
Check(elapsed, IsRoughly, 2*delay, threshold)
})
})