-
Notifications
You must be signed in to change notification settings - Fork 2
/
tests.coffee
76 lines (58 loc) · 1.68 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
trim = (html) =>
html = html.replace />\s+/g, '>'
html = html.replace /\s+</g, '<'
html.trim()
class LevelOneMixin extends CommonMixin
mixins: ->
[LevelTwoMixin]
# This one should be resolved in the template.
hasValue: ->
42
class LevelTwoMixin extends CommonMixin
# This one should not be resolved in the template.
hasNoValue: ->
43
class LevelOneComponent extends CommonComponent
@register 'LevelOneComponent'
mixins: ->
[LevelOneMixin]
topValue: ->
41
class LevelTwoComponent extends CommonComponent
@register 'LevelTwoComponent'
class MainComponent extends CommonComponent
@register 'MainComponent'
topValue: ->
@callAncestorWith 'topValue'
hasValue: ->
@callAncestorWith 'hasValue'
hasNoValue: ->
@callAncestorWith 'hasNoValue'
class CommonComponentTestCase extends ClassyTestCase
@testName: 'CommonComponent'
testConstructDatetime: ->
component = new CommonComponent()
@assertEqual component.constructDatetime('2015-01-03', '14:04'), new Date(2015, 0, 3, 14, 4, 0)
testClientAncestors: [
->
@renderedComponent = Blaze.render Template.testLevelOneComponent, $('body').get(0)
Tracker.afterFlush @expect()
,
->
@assertEqual trim($('.testLevelOneComponent').html()), trim """
<span>41</span>
<span>42</span>
<span></span>
"""
,
->
Blaze.remove @renderedComponent
]
testAncestors: ->
output = CommonComponent.getComponent('LevelOneComponent').renderComponentToHTML null, null
@assertEqual trim(output), trim """
<span>41</span>
<span>42</span>
<span></span>
"""
ClassyTestCase.addTest new CommonComponentTestCase()