2011-09-10 21:49:21 +02:00
|
|
|
$(function () {
|
|
|
|
|
|
|
|
module("bootstrap-twipsy")
|
|
|
|
|
|
|
|
test("should be defined on jquery object", function () {
|
|
|
|
var div = $("<div></div>")
|
|
|
|
ok(div.twipsy, 'popover method is defined')
|
|
|
|
})
|
|
|
|
|
|
|
|
test("should return element", function () {
|
|
|
|
var div = $("<div></div>")
|
|
|
|
ok(div.twipsy() == div, 'document.body returned')
|
|
|
|
})
|
|
|
|
|
|
|
|
test("should expose default settings", function () {
|
|
|
|
ok(!!$.fn.twipsy.defaults, 'defaults is defined')
|
|
|
|
})
|
|
|
|
|
|
|
|
test("should remove title attribute", function () {
|
|
|
|
var twipsy = $('<a href="#" rel="twipsy" title="Another twipsy"></a>').twipsy()
|
|
|
|
ok(!twipsy.attr('title'), 'title tag was removed')
|
|
|
|
})
|
|
|
|
|
|
|
|
test("should add data attribute for referencing original title", function () {
|
|
|
|
var twipsy = $('<a href="#" rel="twipsy" title="Another twipsy"></a>').twipsy()
|
|
|
|
equals(twipsy.attr('data-original-title'), 'Another twipsy', 'original title preserved in data attribute')
|
|
|
|
})
|
|
|
|
|
|
|
|
test("should place tooltips relative to placement option", function () {
|
|
|
|
$.support.transition = false
|
|
|
|
var twipsy = $('<a href="#" rel="twipsy" title="Another twipsy"></a>')
|
2011-12-21 03:02:47 +01:00
|
|
|
.appendTo('#qunit-fixture')
|
2011-12-23 04:28:58 +01:00
|
|
|
.twipsy({placement: 'bottom'})
|
2011-09-12 07:58:51 +02:00
|
|
|
.twipsy('show')
|
2011-09-10 21:49:21 +02:00
|
|
|
|
2011-12-23 04:28:58 +01:00
|
|
|
ok($(".twipsy").hasClass('fade bottom in'), 'has correct classes applied')
|
2011-09-12 07:58:51 +02:00
|
|
|
twipsy.twipsy('hide')
|
2011-09-10 21:49:21 +02:00
|
|
|
})
|
|
|
|
|
2011-12-21 03:02:47 +01:00
|
|
|
test("should always allow html entities", function () {
|
2011-09-10 21:49:21 +02:00
|
|
|
$.support.transition = false
|
|
|
|
var twipsy = $('<a href="#" rel="twipsy" title="<b>@fat</b>"></a>')
|
2011-12-21 03:02:47 +01:00
|
|
|
.appendTo('#qunit-fixture')
|
2011-09-12 07:58:51 +02:00
|
|
|
.twipsy('show')
|
2011-09-10 21:49:21 +02:00
|
|
|
|
|
|
|
ok($('.twipsy b').length, 'b tag was inserted')
|
2011-09-12 07:58:51 +02:00
|
|
|
twipsy.twipsy('hide')
|
2011-09-10 21:49:21 +02:00
|
|
|
ok(!$(".twipsy").length, 'twipsy removed')
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|