OLD | NEW |
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 describe('overlay indicator', function() { | 3 describe('overlay indicator', function() { |
4 var container, indicator, Y; | 4 var container, indicator, widget, Y; |
5 | 5 |
6 before(function(done) { | 6 before(function(done) { |
7 Y = YUI(GlobalConfig).use(['browser-overlay-indicator', 'node'], | 7 Y = YUI(GlobalConfig).use(['browser-overlay-indicator', 'node'], |
8 function(Y) { | 8 function(Y) { |
| 9 widget = Y.juju.widgets.browser; |
9 done(); | 10 done(); |
10 }); | 11 }); |
11 }); | 12 }); |
12 | 13 |
13 beforeEach(function() { | 14 beforeEach(function() { |
14 container = Y.Node.create('<div id="container"></div>'); | 15 container = Y.Node.create('<div id="container"></div>'); |
15 Y.one('body').prepend(container); | 16 Y.one('body').prepend(container); |
16 }); | 17 }); |
17 | 18 |
18 afterEach(function() { | 19 afterEach(function() { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 indicator = new Y.juju.widgets.browser.OverlayIndicator({ | 158 indicator = new Y.juju.widgets.browser.OverlayIndicator({ |
158 target: container, | 159 target: container, |
159 error_action: function() { | 160 error_action: function() { |
160 called = true; | 161 called = true; |
161 } | 162 } |
162 }); | 163 }); |
163 indicator.render(); | 164 indicator.render(); |
164 indicator.error(); | 165 indicator.error(); |
165 assert.isTrue(called); | 166 assert.isTrue(called); |
166 }); | 167 }); |
| 168 |
| 169 it('indicator manager wires into an object properly', function() { |
| 170 var TestClass = Y.Base.create( |
| 171 'testclass', |
| 172 Y.Base, |
| 173 [widget.IndicatorManager]); |
| 174 var test_instance = new TestClass(); |
| 175 test_instance._indicators.should.eql({}); |
| 176 assert(typeof(test_instance.showIndicator) === 'function'); |
| 177 assert(typeof(test_instance.hideIndicator) === 'function'); |
| 178 }); |
| 179 |
| 180 it('indicator manager only creates one indicator per node id', function() { |
| 181 var TestClass = Y.Base.create( |
| 182 'testclass', |
| 183 Y.Base, |
| 184 [widget.IndicatorManager]); |
| 185 var test_instance = new TestClass(); |
| 186 test_instance.showIndicator(container); |
| 187 test_instance.showIndicator(container); |
| 188 |
| 189 assert(Y.Object.keys(test_instance._indicators).length === 1); |
| 190 |
| 191 test_instance.destroy(); |
| 192 }); |
| 193 |
| 194 it('indicator manager handles cleanup', function(done) { |
| 195 var TestClass = Y.Base.create( |
| 196 'testclass', |
| 197 Y.Base, |
| 198 [widget.IndicatorManager], { |
| 199 _destroyIndicators: function() { |
| 200 // override the cleanup method to check it's called. |
| 201 Y.Object.each(this._indicators, function(ind, key) { |
| 202 ind.destroy(); |
| 203 }); |
| 204 done(); |
| 205 } |
| 206 }); |
| 207 |
| 208 var test_instance = new TestClass(); |
| 209 test_instance.showIndicator(container); |
| 210 test_instance.destroy(); |
| 211 }); |
| 212 |
| 213 |
167 }); | 214 }); |
OLD | NEW |