@@ -163,42 +163,79 @@ describe('tooltip', function() {
163
163
164
164
} ) ;
165
165
166
- describe ( 'tooltip with popup delay configured through provider' , function ( ) {
166
+ describe ( '$tooltipProvider' , function ( ) {
167
167
168
- var elm ,
169
- elmBody ,
170
- scope ,
171
- elmScope ;
168
+ describe ( 'popupDelay' , function ( ) {
169
+ var elm ,
170
+ elmBody ,
171
+ scope ,
172
+ elmScope ;
172
173
173
- beforeEach ( module ( 'ui.bootstrap.tooltip' , function ( $tooltipProvider ) {
174
- $tooltipProvider . options ( { popupDelay : 1000 } ) ;
175
- } ) ) ;
174
+ beforeEach ( module ( 'ui.bootstrap.tooltip' , function ( $tooltipProvider ) {
175
+ $tooltipProvider . options ( { popupDelay : 1000 } ) ;
176
+ } ) ) ;
176
177
177
- // load the template
178
- beforeEach ( module ( 'template/tooltip/tooltip-popup.html' ) ) ;
178
+ // load the template
179
+ beforeEach ( module ( 'template/tooltip/tooltip-popup.html' ) ) ;
179
180
180
- beforeEach ( inject ( function ( $rootScope , $compile ) {
181
- elmBody = angular . element (
182
- '<div><span tooltip="tooltip text">Selector Text</span></div>'
183
- ) ;
181
+ beforeEach ( inject ( function ( $rootScope , $compile ) {
182
+ elmBody = angular . element (
183
+ '<div><span tooltip="tooltip text">Selector Text</span></div>'
184
+ ) ;
184
185
185
- scope = $rootScope ;
186
- $compile ( elmBody ) ( scope ) ;
187
- scope . $digest ( ) ;
188
- elm = elmBody . find ( 'span' ) ;
189
- elmScope = elm . scope ( ) ;
190
- } ) ) ;
186
+ scope = $rootScope ;
187
+ $compile ( elmBody ) ( scope ) ;
188
+ scope . $digest ( ) ;
189
+ elm = elmBody . find ( 'span' ) ;
190
+ elmScope = elm . scope ( ) ;
191
+ } ) ) ;
191
192
192
- it ( 'should open after timeout' , inject ( function ( $timeout ) {
193
+ it ( 'should open after timeout' , inject ( function ( $timeout ) {
193
194
194
- elm . trigger ( 'mouseenter' ) ;
195
- expect ( elmScope . tt_isOpen ) . toBe ( false ) ;
195
+ elm . trigger ( 'mouseenter' ) ;
196
+ expect ( elmScope . tt_isOpen ) . toBe ( false ) ;
196
197
197
- $timeout . flush ( ) ;
198
- expect ( elmScope . tt_isOpen ) . toBe ( true ) ;
198
+ $timeout . flush ( ) ;
199
+ expect ( elmScope . tt_isOpen ) . toBe ( true ) ;
199
200
200
- } ) ) ;
201
+ } ) ) ;
202
+
203
+ } ) ;
204
+
205
+ describe ( 'appendToBody' , function ( ) {
206
+ var elm ,
207
+ elmBody ,
208
+ scope ,
209
+ elmScope ,
210
+ body ;
211
+
212
+ // load the tooltip code
213
+ beforeEach ( module ( 'ui.bootstrap.tooltip' , function ( $tooltipProvider ) {
214
+ $tooltipProvider . options ( { appendToBody : true } ) ;
215
+ } ) ) ;
216
+
217
+ // load the template
218
+ beforeEach ( module ( 'template/tooltip/tooltip-popup.html' ) ) ;
219
+
220
+ it ( 'should append to the body' , inject ( function ( $rootScope , $compile , $document ) {
221
+ $body = $document . find ( 'body' ) ;
222
+ elmBody = angular . element (
223
+ '<div><span tooltip="tooltip text">Selector Text</span></div>'
224
+ ) ;
201
225
226
+ scope = $rootScope ;
227
+ $compile ( elmBody ) ( scope ) ;
228
+ scope . $digest ( ) ;
229
+ elm = elmBody . find ( 'span' ) ;
230
+ elmScope = elm . scope ( ) ;
231
+
232
+ var bodyLength = $body . children ( ) . length ;
233
+ elm . trigger ( 'mouseenter' ) ;
234
+
235
+ expect ( elmScope . tt_isOpen ) . toBe ( true ) ;
236
+ expect ( elmBody . children ( ) . length ) . toBe ( 1 ) ;
237
+ expect ( $body . children ( ) . length ) . toEqual ( bodyLength + 1 ) ;
238
+ } ) ) ;
239
+ } ) ;
202
240
} ) ;
203
241
204
-
0 commit comments