@@ -90,14 +90,37 @@ describe 'CommentManager', ->
9090 expect (manager .timeline ).toEqual [c3, c5]
9191 manager .insert c4
9292 expect (manager .timeline ).toEqual [c3, c4 , c5]
93-
93+
94+ describe ' .setBounds' , ->
95+ beforeEach ->
96+ manager .stage .style .width = ' 640px'
97+ manager .stage .style .width = ' 480px'
98+
99+ it ' updates width and height' , ->
100+ manager .setBounds ()
101+ expect (manager .width ).toEqual stage .offsetWidth
102+ expect (manager .height ).toEqual stage .offsetHeight
103+
104+ it ' dispatches resize event' , ->
105+ callback = sinon .spy ()
106+ manager .addEventListener ' resize' , callback
107+ manager .setBounds ()
108+ expect (callback).toHaveBeenCalled true
109+
110+ it ' sets bounds on comment space allocators' , ->
111+ spies = {}
112+ for allocatorName, allocator of manager .csa
113+ spies[allocatorName] = sinon .spy allocator, ' setBounds'
114+ manager .setBounds ()
115+ for allocatorName, spy of spies
116+ expect (spy).toHaveBeenCalledWith stage .offsetWidth , stage .offsetHeight
117+
94118 describe ' .addEventListener .dispatchEvent' , ->
95119 it ' add one event listener' , ->
96- hasDispatchedEvent = false
97- manager .addEventListener ' myCustomEvent' , ->
98- hasDispatchedEvent = true
120+ callback = sinon .spy ()
121+ manager .addEventListener ' myCustomEvent' , callback
99122 manager .dispatchEvent ' myCustomEvent'
100- expect (hasDispatchedEvent). toBe true
123+ expect (callback). toHaveBeenCalled true
101124
102125 it ' add multiple event listeners' , ->
103126 dispatchedEventId = 0
@@ -107,3 +130,9 @@ describe 'CommentManager', ->
107130 dispatchedEventId = 2
108131 manager .dispatchEvent ' myCustomEvent'
109132 expect (dispatchedEventId).toBe 2
133+
134+ it ' dispatch event works with data' , ->
135+ callback = sinon .spy ()
136+ manager .addEventListener ' myCustomEvent' , callback
137+ manager .dispatchEvent ' myCustomEvent' , ' foo'
138+ expect (callback).toHaveBeenCalledWith ' foo'
0 commit comments