-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtests.coffee
62 lines (42 loc) · 1.27 KB
/
tests.coffee
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
class BasicTestCase extends ClassyTestCase
@testName: 'reactive-field - basic'
testBasic: ->
foo = new ReactiveField 42, true
@assertEqual foo.previous(), undefined
@assertEqual foo(), 42
@assertInstanceOf foo, ReactiveField
@assertEqual foo.constructor, ReactiveField
@assertTrue _.isFunction foo
@assertEqual foo(43), 43
@assertEqual foo(), 43
@assertEqual foo.previous(), 42
@assertEqual foo.apply(), 43
@assertEqual foo.apply(null, [42]), 42
@assertEqual foo.apply(), 42
@assertEqual foo.previous(), 43
@assertEqual foo.call(), 42
@assertEqual foo.call(null, 43), 43
@assertEqual foo.call(), 43
@assertEqual foo.previous(), 42
@assertEqual "#{foo}", 'ReactiveField{43}'
@assertEqual foo(), 43
@assertEqual foo.previous(), 42
@assertEqual foo(44), 44
@assertEqual foo(44), 44
@assertEqual foo.previous(), 43
testReactive: ->
foo = new ReactiveField 42
changes = []
handle = Tracker.autorun (computation) =>
changes.push foo()
foo(43)
Tracker.flush()
foo(44)
Tracker.flush()
foo(44)
Tracker.flush()
foo(43)
Tracker.flush()
@assertEqual changes, [42, 43, 44, 43]
handle.stop()
ClassyTestCase.addTest new BasicTestCase()