| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  | $(function () { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-17 21:36:17 +03:00
										 |  |  |     module('popover') | 
					
						
							| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-17 21:36:17 +03:00
										 |  |  |       test('should provide no conflict', function () { | 
					
						
							| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  |         var popover = $.fn.popover.noConflict() | 
					
						
							|  |  |  |         ok(!$.fn.popover, 'popover was set back to undefined (org value)') | 
					
						
							|  |  |  |         $.fn.popover = popover | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-17 21:36:17 +03:00
										 |  |  |       test('should be defined on jquery object', function () { | 
					
						
							| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  |         var div = $('<div></div>') | 
					
						
							|  |  |  |         ok(div.popover, 'popover method is defined') | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-17 21:36:17 +03:00
										 |  |  |       test('should return element', function () { | 
					
						
							| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  |         var div = $('<div></div>') | 
					
						
							|  |  |  |         ok(div.popover() == div, 'document.body returned') | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-17 21:36:17 +03:00
										 |  |  |       test('should render popover element', function () { | 
					
						
							| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  |         $.support.transition = false | 
					
						
							|  |  |  |         var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>') | 
					
						
							|  |  |  |           .appendTo('#qunit-fixture') | 
					
						
							|  |  |  |           .popover('show') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ok($('.popover').length, 'popover was inserted') | 
					
						
							|  |  |  |         popover.popover('hide') | 
					
						
							| 
									
										
										
										
											2014-04-17 21:36:17 +03:00
										 |  |  |         ok(!$('.popover').length, 'popover removed') | 
					
						
							| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  |       }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-17 21:36:17 +03:00
										 |  |  |       test('should store popover instance in popover data object', function () { | 
					
						
							| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  |         $.support.transition = false | 
					
						
							|  |  |  |         var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>') | 
					
						
							|  |  |  |           .popover() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ok(!!popover.data('bs.popover'), 'popover instance exists') | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-17 21:36:17 +03:00
										 |  |  |       test('should get title and content from options', function () { | 
					
						
							| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  |         $.support.transition = false | 
					
						
							|  |  |  |         var popover = $('<a href="#">@fat</a>') | 
					
						
							|  |  |  |           .appendTo('#qunit-fixture') | 
					
						
							|  |  |  |           .popover({ | 
					
						
							|  |  |  |             title: function () { | 
					
						
							|  |  |  |               return '@fat' | 
					
						
							| 
									
										
										
										
											2014-04-17 21:36:17 +03:00
										 |  |  |             }, | 
					
						
							|  |  |  |             content: function () { | 
					
						
							| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  |               return 'loves writing tests (╯°□°)╯︵ ┻━┻' | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         popover.popover('show') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ok($('.popover').length, 'popover was inserted') | 
					
						
							|  |  |  |         equal($('.popover .popover-title').text(), '@fat', 'title correctly inserted') | 
					
						
							|  |  |  |         equal($('.popover .popover-content').text(), 'loves writing tests (╯°□°)╯︵ ┻━┻', 'content correctly inserted') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         popover.popover('hide') | 
					
						
							|  |  |  |         ok(!$('.popover').length, 'popover was removed') | 
					
						
							|  |  |  |         $('#qunit-fixture').empty() | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-17 21:36:17 +03:00
										 |  |  |       test('should get title and content from attributes', function () { | 
					
						
							| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  |         $.support.transition = false | 
					
						
							|  |  |  |         var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>') | 
					
						
							|  |  |  |           .appendTo('#qunit-fixture') | 
					
						
							|  |  |  |           .popover() | 
					
						
							|  |  |  |           .popover('show') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ok($('.popover').length, 'popover was inserted') | 
					
						
							|  |  |  |         equal($('.popover .popover-title').text(), '@mdo', 'title correctly inserted') | 
					
						
							| 
									
										
										
										
											2014-04-17 21:36:17 +03:00
										 |  |  |         equal($('.popover .popover-content').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted') | 
					
						
							| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         popover.popover('hide') | 
					
						
							|  |  |  |         ok(!$('.popover').length, 'popover was removed') | 
					
						
							|  |  |  |         $('#qunit-fixture').empty() | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-17 21:36:17 +03:00
										 |  |  |       test('should get title and content from attributes #2', function () { | 
					
						
							| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  |         $.support.transition = false | 
					
						
							|  |  |  |         var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>') | 
					
						
							|  |  |  |           .appendTo('#qunit-fixture') | 
					
						
							|  |  |  |           .popover({ | 
					
						
							|  |  |  |               title: 'ignored title option', | 
					
						
							|  |  |  |               content: 'ignored content option' | 
					
						
							|  |  |  |           }) | 
					
						
							|  |  |  |           .popover('show') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ok($('.popover').length, 'popover was inserted') | 
					
						
							|  |  |  |         equal($('.popover .popover-title').text(), '@mdo', 'title correctly inserted') | 
					
						
							| 
									
										
										
										
											2014-04-17 21:36:17 +03:00
										 |  |  |         equal($('.popover .popover-content').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted') | 
					
						
							| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         popover.popover('hide') | 
					
						
							|  |  |  |         ok(!$('.popover').length, 'popover was removed') | 
					
						
							|  |  |  |         $('#qunit-fixture').empty() | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-17 21:36:17 +03:00
										 |  |  |       test('should respect custom classes', function () { | 
					
						
							| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  |         $.support.transition = false | 
					
						
							|  |  |  |         var popover = $('<a href="#">@fat</a>') | 
					
						
							|  |  |  |           .appendTo('#qunit-fixture') | 
					
						
							|  |  |  |           .popover({ | 
					
						
							| 
									
										
										
										
											2014-04-17 21:36:17 +03:00
										 |  |  |             title: 'Test', | 
					
						
							|  |  |  |             content: 'Test', | 
					
						
							|  |  |  |             template: '<div class="popover foobar"><div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div></div>' | 
					
						
							| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  |           }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         popover.popover('show') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ok($('.popover').length, 'popover was inserted') | 
					
						
							|  |  |  |         ok($('.popover').hasClass('foobar'), 'custom class is present') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         popover.popover('hide') | 
					
						
							|  |  |  |         ok(!$('.popover').length, 'popover was removed') | 
					
						
							|  |  |  |         $('#qunit-fixture').empty() | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-17 21:36:17 +03:00
										 |  |  |       test('should destroy popover', function () { | 
					
						
							|  |  |  |         var popover = $('<div/>').popover({trigger: 'hover'}).on('click.foo', function () {}) | 
					
						
							| 
									
										
										
										
											2014-01-24 11:24:23 +02:00
										 |  |  |         ok(popover.data('bs.popover'), 'popover has data') | 
					
						
							|  |  |  |         ok($._data(popover[0], 'events').mouseover && $._data(popover[0], 'events').mouseout, 'popover has hover event') | 
					
						
							|  |  |  |         ok($._data(popover[0], 'events').click[0].namespace == 'foo', 'popover has extra click.foo event') | 
					
						
							|  |  |  |         popover.popover('show') | 
					
						
							|  |  |  |         popover.popover('destroy') | 
					
						
							|  |  |  |         ok(!popover.hasClass('in'), 'popover is hidden') | 
					
						
							|  |  |  |         ok(!popover.data('popover'), 'popover does not have data') | 
					
						
							|  |  |  |         ok($._data(popover[0],'events').click[0].namespace == 'foo', 'popover still has click.foo') | 
					
						
							|  |  |  |         ok(!$._data(popover[0], 'events').mouseover && !$._data(popover[0], 'events').mouseout, 'popover does not have any events') | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }) |