2011-09-10 22:17:08 +02:00
|
|
|
$(function () {
|
|
|
|
|
2013-05-16 20:06:30 +02:00
|
|
|
module("popover")
|
2011-09-10 22:17:08 +02:00
|
|
|
|
2012-12-07 23:06:01 +01:00
|
|
|
test("should provide no conflict", function () {
|
|
|
|
var popover = $.fn.popover.noConflict()
|
|
|
|
ok(!$.fn.popover, 'popover was set back to undefined (org value)')
|
|
|
|
$.fn.popover = popover
|
|
|
|
})
|
|
|
|
|
2011-09-10 22:17:08 +02:00
|
|
|
test("should be defined on jquery object", function () {
|
|
|
|
var div = $('<div></div>')
|
|
|
|
ok(div.popover, 'popover method is defined')
|
|
|
|
})
|
|
|
|
|
|
|
|
test("should return element", function () {
|
|
|
|
var div = $('<div></div>')
|
|
|
|
ok(div.popover() == div, 'document.body returned')
|
|
|
|
})
|
|
|
|
|
|
|
|
test("should render popover element", function () {
|
|
|
|
$.support.transition = false
|
2011-09-12 07:58:51 +02:00
|
|
|
var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
|
2011-12-21 03:02:47 +01:00
|
|
|
.appendTo('#qunit-fixture')
|
2011-09-12 07:58:51 +02:00
|
|
|
.popover('show')
|
2011-09-10 22:17:08 +02:00
|
|
|
|
|
|
|
ok($('.popover').length, 'popover was inserted')
|
2011-09-12 07:58:51 +02:00
|
|
|
popover.popover('hide')
|
2011-09-10 22:17:08 +02:00
|
|
|
ok(!$(".popover").length, 'popover removed')
|
|
|
|
})
|
|
|
|
|
|
|
|
test("should store popover instance in popover data object", function () {
|
|
|
|
$.support.transition = false
|
2011-09-12 07:58:51 +02:00
|
|
|
var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
|
2011-09-10 22:17:08 +02:00
|
|
|
.popover()
|
|
|
|
|
2013-05-17 05:19:51 +02:00
|
|
|
ok(!!popover.data('bs.popover'), 'popover instance exists')
|
2011-09-10 22:17:08 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
test("should get title and content from options", function () {
|
|
|
|
$.support.transition = false
|
|
|
|
var popover = $('<a href="#">@fat</a>')
|
2011-12-21 03:02:47 +01:00
|
|
|
.appendTo('#qunit-fixture')
|
2011-09-10 22:17:08 +02:00
|
|
|
.popover({
|
2011-09-12 07:58:51 +02:00
|
|
|
title: function () {
|
|
|
|
return '@fat'
|
|
|
|
}
|
|
|
|
, content: function () {
|
|
|
|
return 'loves writing tests (╯°□°)╯︵ ┻━┻'
|
|
|
|
}
|
2011-09-10 22:17:08 +02:00
|
|
|
})
|
2011-09-12 07:58:51 +02:00
|
|
|
|
|
|
|
popover.popover('show')
|
2011-09-10 22:17:08 +02:00
|
|
|
|
|
|
|
ok($('.popover').length, 'popover was inserted')
|
2013-10-25 23:14:30 +02:00
|
|
|
equal($('.popover .popover-title').text(), '@fat', 'title correctly inserted')
|
|
|
|
equal($('.popover .popover-content').text(), 'loves writing tests (╯°□°)╯︵ ┻━┻', 'content correctly inserted')
|
2011-09-10 22:17:08 +02:00
|
|
|
|
2011-09-12 07:58:51 +02:00
|
|
|
popover.popover('hide')
|
2011-09-10 22:17:08 +02:00
|
|
|
ok(!$('.popover').length, 'popover was removed')
|
2011-12-21 03:02:47 +01:00
|
|
|
$('#qunit-fixture').empty()
|
2011-09-10 22:17:08 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
test("should get title and content from attributes", function () {
|
|
|
|
$.support.transition = false
|
2011-09-12 07:58:51 +02:00
|
|
|
var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
|
2011-12-21 03:02:47 +01:00
|
|
|
.appendTo('#qunit-fixture')
|
2011-09-10 22:17:08 +02:00
|
|
|
.popover()
|
2011-09-12 07:58:51 +02:00
|
|
|
.popover('show')
|
2013-07-18 08:25:26 +02:00
|
|
|
|
|
|
|
ok($('.popover').length, 'popover was inserted')
|
2013-10-25 23:14:30 +02:00
|
|
|
equal($('.popover .popover-title').text(), '@mdo', 'title correctly inserted')
|
|
|
|
equal($('.popover .popover-content').text(), "loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻", 'content correctly inserted')
|
2013-07-18 08:25:26 +02:00
|
|
|
|
|
|
|
popover.popover('hide')
|
|
|
|
ok(!$('.popover').length, 'popover was removed')
|
|
|
|
$('#qunit-fixture').empty()
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
test("should get title and content from attributes #2", function () {
|
|
|
|
$.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')
|
2011-09-10 22:17:08 +02:00
|
|
|
|
|
|
|
ok($('.popover').length, 'popover was inserted')
|
2013-10-25 23:14:30 +02:00
|
|
|
equal($('.popover .popover-title').text(), '@mdo', 'title correctly inserted')
|
|
|
|
equal($('.popover .popover-content').text(), "loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻", 'content correctly inserted')
|
2011-09-10 22:17:08 +02:00
|
|
|
|
2011-09-12 07:58:51 +02:00
|
|
|
popover.popover('hide')
|
2011-09-10 22:17:08 +02:00
|
|
|
ok(!$('.popover').length, 'popover was removed')
|
2011-12-21 03:02:47 +01:00
|
|
|
$('#qunit-fixture').empty()
|
2011-09-10 22:17:08 +02:00
|
|
|
})
|
2012-12-07 23:06:01 +01:00
|
|
|
|
2013-12-06 11:20:59 +01:00
|
|
|
test("should respect custom classes", function () {
|
2012-01-22 12:32:37 +01:00
|
|
|
$.support.transition = false
|
|
|
|
var popover = $('<a href="#">@fat</a>')
|
|
|
|
.appendTo('#qunit-fixture')
|
|
|
|
.popover({
|
|
|
|
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>'
|
|
|
|
})
|
2012-12-07 23:06:01 +01:00
|
|
|
|
2012-01-22 12:32:37 +01:00
|
|
|
popover.popover('show')
|
2012-01-28 10:35:13 +01:00
|
|
|
|
2012-01-22 12:32:37 +01:00
|
|
|
ok($('.popover').length, 'popover was inserted')
|
|
|
|
ok($('.popover').hasClass('foobar'), 'custom class is present')
|
2011-09-10 22:17:08 +02:00
|
|
|
|
2012-01-22 12:32:37 +01:00
|
|
|
popover.popover('hide')
|
|
|
|
ok(!$('.popover').length, 'popover was removed')
|
|
|
|
$('#qunit-fixture').empty()
|
|
|
|
})
|
2012-06-19 04:51:49 +02:00
|
|
|
|
|
|
|
test("should destroy popover", function () {
|
2013-12-06 11:20:59 +01:00
|
|
|
var popover = $('<div/>').popover({trigger: 'hover'}).on('click.foo', function (){})
|
2013-05-17 05:19:51 +02:00
|
|
|
ok(popover.data('bs.popover'), 'popover has data')
|
2012-09-21 01:23:54 +02:00
|
|
|
ok($._data(popover[0], 'events').mouseover && $._data(popover[0], 'events').mouseout, 'popover has hover event')
|
2012-09-21 01:26:00 +02:00
|
|
|
ok($._data(popover[0], 'events').click[0].namespace == 'foo', 'popover has extra click.foo event')
|
2012-07-20 18:47:12 +02:00
|
|
|
popover.popover('show')
|
2012-06-19 04:51:49 +02:00
|
|
|
popover.popover('destroy')
|
2012-07-20 18:47:12 +02:00
|
|
|
ok(!popover.hasClass('in'), 'popover is hidden')
|
2012-06-19 04:51:49 +02:00
|
|
|
ok(!popover.data('popover'), 'popover does not have data')
|
2012-09-21 01:23:54 +02:00
|
|
|
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')
|
2012-06-19 04:51:49 +02:00
|
|
|
})
|
2012-12-07 23:06:01 +01:00
|
|
|
|
2013-04-23 09:34:27 +02:00
|
|
|
})
|