', { id: 'modal-test', 'data-backdrop': false })
+ div
+ .on('shown.bs.modal', function () {
+ ok($('#modal-test').is(':visible'), 'modal visible')
+ div.modal('hide')
+ })
+ .on('hidden.bs.modal', function () {
+ ok(!$('#modal-test').is(':visible'), 'modal hidden')
+ div.remove()
+ start()
+ })
+ .modal('show')
+ })
+
+ test('should close modal when clicking outside of modal-content', function () {
+ stop()
+ $.support.transition = false
+ var div = $('
')
+ div
+ .bind('shown.bs.modal', function () {
+ ok($('#modal-test').length, 'modal insterted into dom')
+ $('.contents').click()
+ ok($('#modal-test').is(':visible'), 'modal visible')
+ $('#modal-test').click()
+ })
+ .bind('hidden.bs.modal', function () {
+ ok(!$('#modal-test').is(':visible'), 'modal hidden')
+ div.remove()
+ start()
+ })
+ .modal('show')
+ })
+
+ test('should trigger hide event once when clicking outside of modal-content', function () {
+ stop()
+ $.support.transition = false
+
+ var triggered
+ var div = $('
')
+
+ div
+ .bind('shown.bs.modal', function () {
+ triggered = 0
+ $('#modal-test').click()
+ })
+ .bind('hide.bs.modal', function () {
+ triggered += 1
+ ok(triggered === 1, 'modal hide triggered once')
+ start()
+ })
+ .modal('show')
+ })
+
+ test('should close reopened modal with [data-dismiss=modal] click', function () {
+ stop()
+ $.support.transition = false
+ var div = $('
')
+ div
+ .bind('shown.bs.modal', function () {
+ $('#close').click()
+ ok(!$('#modal-test').is(':visible'), 'modal hidden')
+ })
+ .one('hidden.bs.modal', function () {
+ div.one('hidden.bs.modal', function () {
start()
- })
- .modal('show')
- })
+ }).modal('show')
+ })
+ .modal('show')
- test('should fire show event', function () {
- stop()
- $.support.transition = false
- $('
')
- .on('show.bs.modal', function () {
- ok(true, 'show was called')
- })
- .on('shown.bs.modal', function () {
- $(this).remove()
- start()
- })
- .modal('show')
- })
-
- test('should not fire shown when default prevented', function () {
- stop()
- $.support.transition = false
- $('
')
- .on('show.bs.modal', function (e) {
- e.preventDefault()
- ok(true, 'show was called')
- start()
- })
- .on('shown.bs.modal', function () {
- ok(false, 'shown was called')
- })
- .modal('show')
- })
-
- test('should hide modal when hide is called', function () {
- stop()
- $.support.transition = false
-
- $('
')
- .on('shown.bs.modal', function () {
- ok($('#modal-test').is(':visible'), 'modal visible')
- ok($('#modal-test').length, 'modal inserted into dom')
- $(this).modal('hide')
- })
- .on('hidden.bs.modal', function () {
- ok(!$('#modal-test').is(':visible'), 'modal hidden')
- $('#modal-test').remove()
- start()
- })
- .modal('show')
- })
-
- test('should toggle when toggle is called', function () {
- stop()
- $.support.transition = false
- var div = $('
')
- div
- .on('shown.bs.modal', function () {
- ok($('#modal-test').is(':visible'), 'modal visible')
- ok($('#modal-test').length, 'modal inserted into dom')
- div.modal('toggle')
- })
- .on('hidden.bs.modal', function () {
- ok(!$('#modal-test').is(':visible'), 'modal hidden')
- div.remove()
- start()
- })
- .modal('toggle')
- })
-
- test('should remove from dom when click [data-dismiss=modal]', function () {
- stop()
- $.support.transition = false
- var div = $('
')
- div
- .on('shown.bs.modal', function () {
- ok($('#modal-test').is(':visible'), 'modal visible')
- ok($('#modal-test').length, 'modal inserted into dom')
- div.find('.close').click()
- })
- .on('hidden.bs.modal', function () {
- ok(!$('#modal-test').is(':visible'), 'modal hidden')
- div.remove()
- start()
- })
- .modal('toggle')
- })
-
- test('should allow modal close with "backdrop:false"', function () {
- stop()
- $.support.transition = false
- var div = $('
', { id: 'modal-test', 'data-backdrop': false })
- div
- .on('shown.bs.modal', function () {
- ok($('#modal-test').is(':visible'), 'modal visible')
- div.modal('hide')
- })
- .on('hidden.bs.modal', function () {
- ok(!$('#modal-test').is(':visible'), 'modal hidden')
- div.remove()
- start()
- })
- .modal('show')
- })
-
- test('should close modal when clicking outside of modal-content', function () {
- stop()
- $.support.transition = false
- var div = $('
')
- div
- .bind('shown.bs.modal', function () {
- ok($('#modal-test').length, 'modal insterted into dom')
- $('.contents').click()
- ok($('#modal-test').is(':visible'), 'modal visible')
- $('#modal-test').click()
- })
- .bind('hidden.bs.modal', function () {
- ok(!$('#modal-test').is(':visible'), 'modal hidden')
- div.remove()
- start()
- })
- .modal('show')
- })
-
- test('should trigger hide event once when clicking outside of modal-content', function () {
- stop()
- $.support.transition = false
-
- var triggered
- var div = $('
')
-
- div
- .bind('shown.bs.modal', function () {
- triggered = 0
- $('#modal-test').click()
- })
- .bind('hide.bs.modal', function () {
- triggered += 1
- ok(triggered === 1, 'modal hide triggered once')
- start()
- })
- .modal('show')
- })
-
- test('should close reopened modal with [data-dismiss=modal] click', function () {
- stop()
- $.support.transition = false
- var div = $('
')
- div
- .bind('shown.bs.modal', function () {
- $('#close').click()
- ok(!$('#modal-test').is(':visible'), 'modal hidden')
- })
- .one('hidden.bs.modal', function () {
- div.one('hidden.bs.modal', function () {
- start()
- }).modal('show')
- })
- .modal('show')
-
- div.remove()
- })
+ div.remove()
+ })
})
diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js
index ecab948c7d..c08b6d8ef2 100644
--- a/js/tests/unit/popover.js
+++ b/js/tests/unit/popover.js
@@ -1,133 +1,133 @@
$(function () {
- module('popover')
+ module('popover')
- 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
+ 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
+ })
+
+ test('should be defined on jquery object', function () {
+ var div = $('
')
+ ok(div.popover, 'popover method is defined')
+ })
+
+ test('should return element', function () {
+ var div = $('
')
+ ok(div.popover() == div, 'document.body returned')
+ })
+
+ test('should render popover element', function () {
+ $.support.transition = false
+ var popover = $('
@mdo')
+ .appendTo('#qunit-fixture')
+ .popover('show')
+
+ ok($('.popover').length, 'popover was inserted')
+ popover.popover('hide')
+ ok(!$('.popover').length, 'popover removed')
+ })
+
+ test('should store popover instance in popover data object', function () {
+ $.support.transition = false
+ var popover = $('
@mdo')
+ .popover()
+
+ ok(!!popover.data('bs.popover'), 'popover instance exists')
+ })
+
+ test('should get title and content from options', function () {
+ $.support.transition = false
+ var popover = $('
@fat')
+ .appendTo('#qunit-fixture')
+ .popover({
+ title: function () {
+ return '@fat'
+ },
+ content: function () {
+ return 'loves writing tests (╯°□°)╯︵ ┻━┻'
+ }
})
- test('should be defined on jquery object', function () {
- var div = $('
')
- ok(div.popover, 'popover method is defined')
+ 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()
+ })
+
+ test('should get title and content from attributes', function () {
+ $.support.transition = false
+ var popover = $('
@mdo')
+ .appendTo('#qunit-fixture')
+ .popover()
+ .popover('show')
+
+ ok($('.popover').length, 'popover was inserted')
+ equal($('.popover .popover-title').text(), '@mdo', 'title correctly inserted')
+ equal($('.popover .popover-content').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted')
+
+ 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 = $('
@mdo')
+ .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')
+ equal($('.popover .popover-content').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted')
+
+ popover.popover('hide')
+ ok(!$('.popover').length, 'popover was removed')
+ $('#qunit-fixture').empty()
+ })
+
+ test('should respect custom classes', function () {
+ $.support.transition = false
+ var popover = $('
@fat')
+ .appendTo('#qunit-fixture')
+ .popover({
+ title: 'Test',
+ content: 'Test',
+ template: '
'
})
- test('should return element', function () {
- var div = $('
')
- ok(div.popover() == div, 'document.body returned')
- })
+ popover.popover('show')
- test('should render popover element', function () {
- $.support.transition = false
- var popover = $('
@mdo')
- .appendTo('#qunit-fixture')
- .popover('show')
+ ok($('.popover').length, 'popover was inserted')
+ ok($('.popover').hasClass('foobar'), 'custom class is present')
- ok($('.popover').length, 'popover was inserted')
- popover.popover('hide')
- ok(!$('.popover').length, 'popover removed')
- })
+ popover.popover('hide')
+ ok(!$('.popover').length, 'popover was removed')
+ $('#qunit-fixture').empty()
+ })
- test('should store popover instance in popover data object', function () {
- $.support.transition = false
- var popover = $('
@mdo')
- .popover()
-
- ok(!!popover.data('bs.popover'), 'popover instance exists')
- })
-
- test('should get title and content from options', function () {
- $.support.transition = false
- var popover = $('
@fat')
- .appendTo('#qunit-fixture')
- .popover({
- title: function () {
- return '@fat'
- },
- content: function () {
- 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()
- })
-
- test('should get title and content from attributes', function () {
- $.support.transition = false
- var popover = $('
@mdo')
- .appendTo('#qunit-fixture')
- .popover()
- .popover('show')
-
- ok($('.popover').length, 'popover was inserted')
- equal($('.popover .popover-title').text(), '@mdo', 'title correctly inserted')
- equal($('.popover .popover-content').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted')
-
- 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 = $('
@mdo')
- .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')
- equal($('.popover .popover-content').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted')
-
- popover.popover('hide')
- ok(!$('.popover').length, 'popover was removed')
- $('#qunit-fixture').empty()
- })
-
- test('should respect custom classes', function () {
- $.support.transition = false
- var popover = $('
@fat')
- .appendTo('#qunit-fixture')
- .popover({
- title: 'Test',
- content: 'Test',
- template: '
'
- })
-
- 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()
- })
-
- test('should destroy popover', function () {
- var popover = $('
').popover({trigger: 'hover'}).on('click.foo', function () {})
- 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')
- })
+ test('should destroy popover', function () {
+ var popover = $('
').popover({trigger: 'hover'}).on('click.foo', function () {})
+ 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')
+ })
})
diff --git a/js/tests/unit/scrollspy.js b/js/tests/unit/scrollspy.js
index cf7b50dc43..694af95c62 100644
--- a/js/tests/unit/scrollspy.js
+++ b/js/tests/unit/scrollspy.js
@@ -1,36 +1,36 @@
$(function () {
- module('scrollspy')
+ module('scrollspy')
- test('should provide no conflict', function () {
- var scrollspy = $.fn.scrollspy.noConflict()
- ok(!$.fn.scrollspy, 'scrollspy was set back to undefined (org value)')
- $.fn.scrollspy = scrollspy
- })
+ test('should provide no conflict', function () {
+ var scrollspy = $.fn.scrollspy.noConflict()
+ ok(!$.fn.scrollspy, 'scrollspy was set back to undefined (org value)')
+ $.fn.scrollspy = scrollspy
+ })
- test('should be defined on jquery object', function () {
- ok($(document.body).scrollspy, 'scrollspy method is defined')
- })
+ test('should be defined on jquery object', function () {
+ ok($(document.body).scrollspy, 'scrollspy method is defined')
+ })
- test('should return element', function () {
- ok($(document.body).scrollspy()[0] == document.body, 'document.body returned')
- })
+ test('should return element', function () {
+ ok($(document.body).scrollspy()[0] == document.body, 'document.body returned')
+ })
- test('should switch active class on scroll', function () {
- var sectionHTML = '
'
- $section = $(sectionHTML).append('#qunit-fixture'),
- topbarHTML = '
',
- $topbar = $(topbarHTML).scrollspy()
+ test('should switch active class on scroll', function () {
+ var sectionHTML = '
',
+ $section = $(sectionHTML).append('#qunit-fixture'),
+ topbarHTML = '
',
+ $topbar = $(topbarHTML).scrollspy()
- ok($topbar.find('.active', true))
- })
+ ok($topbar.find('.active', true))
+ })
})
diff --git a/js/tests/unit/tab.js b/js/tests/unit/tab.js
index b8dbf2c18e..60e46364dc 100644
--- a/js/tests/unit/tab.js
+++ b/js/tests/unit/tab.js
@@ -1,86 +1,86 @@
$(function () {
- module('tabs')
+ module('tabs')
- test('should provide no conflict', function () {
- var tab = $.fn.tab.noConflict()
- ok(!$.fn.tab, 'tab was set back to undefined (org value)')
- $.fn.tab = tab
+ test('should provide no conflict', function () {
+ var tab = $.fn.tab.noConflict()
+ ok(!$.fn.tab, 'tab was set back to undefined (org value)')
+ $.fn.tab = tab
+ })
+
+ test('should be defined on jquery object', function () {
+ ok($(document.body).tab, 'tabs method is defined')
+ })
+
+ test('should return element', function () {
+ ok($(document.body).tab()[0] == document.body, 'document.body returned')
+ })
+
+ test('should activate element by tab id', function () {
+ var tabsHTML = '
'
+
+ $('
').appendTo('#qunit-fixture')
+
+ $(tabsHTML).find('li:last a').tab('show')
+ equal($('#qunit-fixture').find('.active').attr('id'), 'profile')
+
+ $(tabsHTML).find('li:first a').tab('show')
+ equal($('#qunit-fixture').find('.active').attr('id'), 'home')
+ })
+
+ test('should activate element by tab id', function () {
+ var pillsHTML = '
'
+
+ $('
').appendTo('#qunit-fixture')
+
+ $(pillsHTML).find('li:last a').tab('show')
+ equal($('#qunit-fixture').find('.active').attr('id'), 'profile')
+
+ $(pillsHTML).find('li:first a').tab('show')
+ equal($('#qunit-fixture').find('.active').attr('id'), 'home')
+ })
+
+
+ test('should not fire closed when close is prevented', function () {
+ $.support.transition = false
+ stop();
+ $('
')
+ .on('show.bs.tab', function (e) {
+ e.preventDefault();
+ ok(true);
+ start();
})
-
- test('should be defined on jquery object', function () {
- ok($(document.body).tab, 'tabs method is defined')
+ .on('shown.bs.tab', function () {
+ ok(false);
})
+ .tab('show')
+ })
- test('should return element', function () {
- ok($(document.body).tab()[0] == document.body, 'document.body returned')
+ test('show and shown events should reference correct relatedTarget', function () {
+ var dropHTML = '
' +
+ '- 1' +
+ '' +
+ '
' +
+ '
'
+
+ $(dropHTML).find('ul>li:first a').tab('show').end()
+ .find('ul>li:last a')
+ .on('show.bs.tab', function (event) {
+ equal(event.relatedTarget.hash, '#1-1')
})
-
- test('should activate element by tab id', function () {
- var tabsHTML = '
'
-
- $('
').appendTo('#qunit-fixture')
-
- $(tabsHTML).find('li:last a').tab('show')
- equal($('#qunit-fixture').find('.active').attr('id'), 'profile')
-
- $(tabsHTML).find('li:first a').tab('show')
- equal($('#qunit-fixture').find('.active').attr('id'), 'home')
- })
-
- test('should activate element by tab id', function () {
- var pillsHTML = '
'
-
- $('
').appendTo('#qunit-fixture')
-
- $(pillsHTML).find('li:last a').tab('show')
- equal($('#qunit-fixture').find('.active').attr('id'), 'profile')
-
- $(pillsHTML).find('li:first a').tab('show')
- equal($('#qunit-fixture').find('.active').attr('id'), 'home')
- })
-
-
- test('should not fire closed when close is prevented', function () {
- $.support.transition = false
- stop();
- $('
')
- .on('show.bs.tab', function (e) {
- e.preventDefault();
- ok(true);
- start();
- })
- .on('shown.bs.tab', function () {
- ok(false);
- })
- .tab('show')
- })
-
- test('show and shown events should reference correct relatedTarget', function () {
- var dropHTML = '
' +
- '- 1' +
- '' +
- '
' +
- '
'
-
- $(dropHTML).find('ul>li:first a').tab('show').end()
- .find('ul>li:last a')
- .on('show.bs.tab', function (event) {
- equal(event.relatedTarget.hash, '#1-1')
- })
- .on('show.bs.tab', function (event) {
- equal(event.relatedTarget.hash, '#1-1')
- })
- .tab('show')
+ .on('show.bs.tab', function (event) {
+ equal(event.relatedTarget.hash, '#1-1')
})
+ .tab('show')
+ })
})
diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js
index b9b003dd1d..c3af7d82e0 100644
--- a/js/tests/unit/tooltip.js
+++ b/js/tests/unit/tooltip.js
@@ -1,432 +1,432 @@
$(function () {
- module('tooltip')
+ module('tooltip')
- test('should provide no conflict', function () {
- var tooltip = $.fn.tooltip.noConflict()
- ok(!$.fn.tooltip, 'tooltip was set back to undefined (org value)')
- $.fn.tooltip = tooltip
+ test('should provide no conflict', function () {
+ var tooltip = $.fn.tooltip.noConflict()
+ ok(!$.fn.tooltip, 'tooltip was set back to undefined (org value)')
+ $.fn.tooltip = tooltip
+ })
+
+ test('should be defined on jquery object', function () {
+ var div = $('
')
+ ok(div.tooltip, 'popover method is defined')
+ })
+
+ test('should return element', function () {
+ var div = $('
')
+ ok(div.tooltip() == div, 'document.body returned')
+ })
+
+ test('should expose default settings', function () {
+ ok(!!$.fn.tooltip.Constructor.DEFAULTS, 'defaults is defined')
+ })
+
+ test('should empty title attribute', function () {
+ var tooltip = $('
').tooltip()
+ ok(tooltip.attr('title') === '', 'title attribute was emptied')
+ })
+
+ test('should add data attribute for referencing original title', function () {
+ var tooltip = $('
').tooltip()
+ equal(tooltip.attr('data-original-title'), 'Another tooltip', 'original title preserved in data attribute')
+ })
+
+ test('should place tooltips relative to placement option', function () {
+ $.support.transition = false
+ var tooltip = $('
')
+ .appendTo('#qunit-fixture')
+ .tooltip({placement: 'bottom'})
+ .tooltip('show')
+
+ ok($('.tooltip').is('.fade.bottom.in'), 'has correct classes applied')
+ tooltip.tooltip('hide')
+ })
+
+ test('should allow html entities', function () {
+ $.support.transition = false
+ var tooltip = $('
')
+ .appendTo('#qunit-fixture')
+ .tooltip({html: true})
+ .tooltip('show')
+
+ ok($('.tooltip b').length, 'b tag was inserted')
+ tooltip.tooltip('hide')
+ ok(!$('.tooltip').length, 'tooltip removed')
+ })
+
+ test('should respect custom classes', function () {
+ var tooltip = $('
')
+ .appendTo('#qunit-fixture')
+ .tooltip({ template: '
'})
+ .tooltip('show')
+
+ ok($('.tooltip').hasClass('some-class'), 'custom class is present')
+ tooltip.tooltip('hide')
+ ok(!$('.tooltip').length, 'tooltip removed')
+ })
+
+ test('should fire show event', function () {
+ stop()
+ var tooltip = $('
')
+ .on('show.bs.tooltip', function () {
+ ok(true, 'show was called')
+ start()
})
+ .tooltip('show')
+ })
- test('should be defined on jquery object', function () {
- var div = $('
')
- ok(div.tooltip, 'popover method is defined')
+ test('should fire shown event', function () {
+ stop()
+ var tooltip = $('
')
+ .on('shown.bs.tooltip', function () {
+ ok(true, 'shown was called')
+ start()
})
+ .tooltip('show')
+ })
- test('should return element', function () {
- var div = $('
')
- ok(div.tooltip() == div, 'document.body returned')
+ test('should not fire shown event when default prevented', function () {
+ stop()
+ var tooltip = $('
')
+ .on('show.bs.tooltip', function (e) {
+ e.preventDefault()
+ ok(true, 'show was called')
+ start()
})
-
- test('should expose default settings', function () {
- ok(!!$.fn.tooltip.Constructor.DEFAULTS, 'defaults is defined')
+ .on('shown.bs.tooltip', function () {
+ ok(false, 'shown was called')
})
+ .tooltip('show')
+ })
- test('should empty title attribute', function () {
- var tooltip = $('
').tooltip()
- ok(tooltip.attr('title') === '', 'title attribute was emptied')
+ test('should fire hide event', function () {
+ stop()
+ var tooltip = $('
')
+ .on('shown.bs.tooltip', function () {
+ $(this).tooltip('hide')
})
-
- test('should add data attribute for referencing original title', function () {
- var tooltip = $('
').tooltip()
- equal(tooltip.attr('data-original-title'), 'Another tooltip', 'original title preserved in data attribute')
+ .on('hide.bs.tooltip', function () {
+ ok(true, 'hide was called')
+ start()
})
+ .tooltip('show')
+ })
- test('should place tooltips relative to placement option', function () {
- $.support.transition = false
- var tooltip = $('
')
- .appendTo('#qunit-fixture')
- .tooltip({placement: 'bottom'})
- .tooltip('show')
-
- ok($('.tooltip').is('.fade.bottom.in'), 'has correct classes applied')
- tooltip.tooltip('hide')
+ test('should fire hidden event', function () {
+ stop()
+ var tooltip = $('
')
+ .on('shown.bs.tooltip', function () {
+ $(this).tooltip('hide')
})
-
- test('should allow html entities', function () {
- $.support.transition = false
- var tooltip = $('
')
- .appendTo('#qunit-fixture')
- .tooltip({html: true})
- .tooltip('show')
-
- ok($('.tooltip b').length, 'b tag was inserted')
- tooltip.tooltip('hide')
- ok(!$('.tooltip').length, 'tooltip removed')
+ .on('hidden.bs.tooltip', function () {
+ ok(true, 'hidden was called')
+ start()
})
+ .tooltip('show')
+ })
- test('should respect custom classes', function () {
- var tooltip = $('
')
- .appendTo('#qunit-fixture')
- .tooltip({ template: '
'})
- .tooltip('show')
-
- ok($('.tooltip').hasClass('some-class'), 'custom class is present')
- tooltip.tooltip('hide')
- ok(!$('.tooltip').length, 'tooltip removed')
+ test('should not fire hidden event when default prevented', function () {
+ stop()
+ var tooltip = $('
')
+ .on('shown.bs.tooltip', function () {
+ $(this).tooltip('hide')
})
-
- test('should fire show event', function () {
- stop()
- var tooltip = $('
')
- .on('show.bs.tooltip', function () {
- ok(true, 'show was called')
- start()
- })
- .tooltip('show')
+ .on('hide.bs.tooltip', function (e) {
+ e.preventDefault()
+ ok(true, 'hide was called')
+ start()
})
-
- test('should fire shown event', function () {
- stop()
- var tooltip = $('
')
- .on('shown.bs.tooltip', function () {
- ok(true, 'shown was called')
- start()
- })
- .tooltip('show')
+ .on('hidden.bs.tooltip', function () {
+ ok(false, 'hidden was called')
})
+ .tooltip('show')
+ })
- test('should not fire shown event when default prevented', function () {
- stop()
- var tooltip = $('
')
- .on('show.bs.tooltip', function (e) {
- e.preventDefault()
- ok(true, 'show was called')
- start()
- })
- .on('shown.bs.tooltip', function () {
- ok(false, 'shown was called')
- })
- .tooltip('show')
- })
+ test('should not show tooltip if leave event occurs before delay expires', function () {
+ var tooltip = $('
')
+ .appendTo('#qunit-fixture')
+ .tooltip({ delay: 200 })
- test('should fire hide event', function () {
- stop()
- var tooltip = $('
')
- .on('shown.bs.tooltip', function () {
- $(this).tooltip('hide')
- })
- .on('hide.bs.tooltip', function () {
- ok(true, 'hide was called')
- start()
- })
- .tooltip('show')
- })
+ stop()
- test('should fire hidden event', function () {
- stop()
- var tooltip = $('
')
- .on('shown.bs.tooltip', function () {
- $(this).tooltip('hide')
- })
- .on('hidden.bs.tooltip', function () {
- ok(true, 'hidden was called')
- start()
- })
- .tooltip('show')
- })
+ tooltip.trigger('mouseenter')
- test('should not fire hidden event when default prevented', function () {
- stop()
- var tooltip = $('
')
- .on('shown.bs.tooltip', function () {
- $(this).tooltip('hide')
- })
- .on('hide.bs.tooltip', function (e) {
- e.preventDefault()
- ok(true, 'hide was called')
- start()
- })
- .on('hidden.bs.tooltip', function () {
- ok(false, 'hidden was called')
- })
- .tooltip('show')
- })
+ setTimeout(function () {
+ ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
+ tooltip.trigger('mouseout')
+ setTimeout(function () {
+ ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
+ start()
+ }, 200)
+ }, 100)
+ })
- test('should not show tooltip if leave event occurs before delay expires', function () {
- var tooltip = $('
')
- .appendTo('#qunit-fixture')
- .tooltip({ delay: 200 })
+ test('should not show tooltip if leave event occurs before delay expires, even if hide delay is 0', function () {
+ var tooltip = $('
')
+ .appendTo('#qunit-fixture')
+ .tooltip({ delay: { show: 200, hide: 0} })
- stop()
+ stop()
- tooltip.trigger('mouseenter')
+ tooltip.trigger('mouseenter')
+ setTimeout(function () {
+ ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
+ tooltip.trigger('mouseout')
+ setTimeout(function () {
+ ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
+ start()
+ }, 200)
+ }, 100)
+ })
+
+ test('should wait 200 ms before hiding the tooltip', 3, function () {
+ var tooltip = $('
')
+ .appendTo('#qunit-fixture')
+ .tooltip({ delay: { show: 0, hide: 200} })
+
+ stop()
+
+ tooltip.trigger('mouseenter')
+
+ setTimeout(function () {
+ ok($('.tooltip').is('.fade.in'), 'tooltip is faded in')
+ tooltip.trigger('mouseout')
+ setTimeout(function () {
+ ok($('.tooltip').is('.fade.in'), '100ms:tooltip is still faded in')
setTimeout(function () {
- ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
- tooltip.trigger('mouseout')
- setTimeout(function () {
- ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
- start()
- }, 200)
- }, 100)
- })
-
- test('should not show tooltip if leave event occurs before delay expires, even if hide delay is 0', function () {
- var tooltip = $('
')
- .appendTo('#qunit-fixture')
- .tooltip({ delay: { show: 200, hide: 0} })
-
- stop()
-
- tooltip.trigger('mouseenter')
-
- setTimeout(function () {
- ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
- tooltip.trigger('mouseout')
- setTimeout(function () {
- ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
- start()
- }, 200)
- }, 100)
- })
-
- test('should wait 200 ms before hiding the tooltip', 3, function () {
- var tooltip = $('
')
- .appendTo('#qunit-fixture')
- .tooltip({ delay: { show: 0, hide: 200} })
-
- stop()
-
- tooltip.trigger('mouseenter')
-
- setTimeout(function () {
- ok($('.tooltip').is('.fade.in'), 'tooltip is faded in')
- tooltip.trigger('mouseout')
- setTimeout(function () {
- ok($('.tooltip').is('.fade.in'), '100ms:tooltip is still faded in')
- setTimeout(function () {
- ok(!$('.tooltip').is('.in'), 'tooltip removed')
- start()
- }, 150)
- }, 100)
- }, 1)
- })
-
- test('should not hide tooltip if leave event occurs, then tooltip is show immediately again', function () {
- var tooltip = $('
')
- .appendTo('#qunit-fixture')
- .tooltip({ delay: { show: 0, hide: 200} })
-
- stop()
-
- tooltip.trigger('mouseenter')
-
- setTimeout(function () {
- ok($('.tooltip').is('.fade.in'), 'tooltip is faded in')
- tooltip.trigger('mouseout')
- setTimeout(function () {
- ok($('.tooltip').is('.fade.in'), '100ms:tooltip is still faded in')
- tooltip.trigger('mouseenter')
- setTimeout(function () {
- ok($('.tooltip').is('.in'), 'tooltip removed')
- start()
- }, 150)
- }, 100)
- }, 1)
- })
-
- test('should not show tooltip if leave event occurs before delay expires', function () {
- var tooltip = $('
')
- .appendTo('#qunit-fixture')
- .tooltip({ delay: 100 })
- stop()
- tooltip.trigger('mouseenter')
- setTimeout(function () {
- ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
- tooltip.trigger('mouseout')
- setTimeout(function () {
- ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
- start()
- }, 100)
- }, 50)
- })
-
- test('should show tooltip if leave event hasn\'t occured before delay expires', function () {
- var tooltip = $('
')
- .appendTo('#qunit-fixture')
- .tooltip({ delay: 150 })
- stop()
- tooltip.trigger('mouseenter')
- setTimeout(function () {
- ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
- }, 100)
- setTimeout(function () {
- ok($('.tooltip').is('.fade.in'), 'tooltip has faded in')
+ ok(!$('.tooltip').is('.in'), 'tooltip removed')
start()
- }, 200)
- })
+ }, 150)
+ }, 100)
+ }, 1)
+ })
- test('should destroy tooltip', function () {
- var tooltip = $('
').tooltip().on('click.foo', function () {})
- ok(tooltip.data('bs.tooltip'), 'tooltip has data')
- ok($._data(tooltip[0], 'events').mouseover && $._data(tooltip[0], 'events').mouseout, 'tooltip has hover event')
- ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip has extra click.foo event')
- tooltip.tooltip('show')
- tooltip.tooltip('destroy')
- ok(!tooltip.hasClass('in'), 'tooltip is hidden')
- ok(!$._data(tooltip[0], 'bs.tooltip'), 'tooltip does not have data')
- ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip still has click.foo')
- ok(!$._data(tooltip[0], 'events').mouseover && !$._data(tooltip[0], 'events').mouseout, 'tooltip does not have any events')
- })
+ test('should not hide tooltip if leave event occurs, then tooltip is show immediately again', function () {
+ var tooltip = $('
')
+ .appendTo('#qunit-fixture')
+ .tooltip({ delay: { show: 0, hide: 200} })
- test('should show tooltip with delegate selector on click', function () {
- var div = $('
')
- var tooltip = div.appendTo('#qunit-fixture')
- .tooltip({ selector: 'a[rel=tooltip]',
- trigger: 'click' })
- div.find('a').trigger('click')
- ok($('.tooltip').is('.fade.in'), 'tooltip is faded in')
- })
+ stop()
- test('should show tooltip when toggle is called', function () {
- var tooltip = $('
')
- .appendTo('#qunit-fixture')
- .tooltip({trigger: 'manual'})
- .tooltip('toggle')
- ok($('.tooltip').is('.fade.in'), 'tooltip should be toggled in')
- })
+ tooltip.trigger('mouseenter')
- test('should place tooltips inside the body', function () {
- var tooltip = $('
')
- .appendTo('#qunit-fixture')
- .tooltip({container: 'body'})
- .tooltip('show')
- ok($('body > .tooltip').length, 'inside the body')
- ok(!$('#qunit-fixture > .tooltip').length, 'not found in parent')
- tooltip.tooltip('hide')
- })
+ setTimeout(function () {
+ ok($('.tooltip').is('.fade.in'), 'tooltip is faded in')
+ tooltip.trigger('mouseout')
+ setTimeout(function () {
+ ok($('.tooltip').is('.fade.in'), '100ms:tooltip is still faded in')
+ tooltip.trigger('mouseenter')
+ setTimeout(function () {
+ ok($('.tooltip').is('.in'), 'tooltip removed')
+ start()
+ }, 150)
+ }, 100)
+ }, 1)
+ })
- test('should place tooltip inside window', function () {
- var container = $('
').appendTo('body')
- .css({position: 'absolute', width: 200, height: 200, bottom: 0, left: 0}),
- tooltip = $('
Hover me')
- .css({position: 'absolute', top: 0, left: 0})
+ test('should not show tooltip if leave event occurs before delay expires', function () {
+ var tooltip = $('
')
+ .appendTo('#qunit-fixture')
+ .tooltip({ delay: 100 })
+ stop()
+ tooltip.trigger('mouseenter')
+ setTimeout(function () {
+ ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
+ tooltip.trigger('mouseout')
+ setTimeout(function () {
+ ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
+ start()
+ }, 100)
+ }, 50)
+ })
+
+ test('should show tooltip if leave event hasn\'t occured before delay expires', function () {
+ var tooltip = $('
')
+ .appendTo('#qunit-fixture')
+ .tooltip({ delay: 150 })
+ stop()
+ tooltip.trigger('mouseenter')
+ setTimeout(function () {
+ ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
+ }, 100)
+ setTimeout(function () {
+ ok($('.tooltip').is('.fade.in'), 'tooltip has faded in')
+ start()
+ }, 200)
+ })
+
+ test('should destroy tooltip', function () {
+ var tooltip = $('
').tooltip().on('click.foo', function () {})
+ ok(tooltip.data('bs.tooltip'), 'tooltip has data')
+ ok($._data(tooltip[0], 'events').mouseover && $._data(tooltip[0], 'events').mouseout, 'tooltip has hover event')
+ ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip has extra click.foo event')
+ tooltip.tooltip('show')
+ tooltip.tooltip('destroy')
+ ok(!tooltip.hasClass('in'), 'tooltip is hidden')
+ ok(!$._data(tooltip[0], 'bs.tooltip'), 'tooltip does not have data')
+ ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip still has click.foo')
+ ok(!$._data(tooltip[0], 'events').mouseover && !$._data(tooltip[0], 'events').mouseout, 'tooltip does not have any events')
+ })
+
+ test('should show tooltip with delegate selector on click', function () {
+ var div = $('
')
+ var tooltip = div.appendTo('#qunit-fixture')
+ .tooltip({ selector: 'a[rel=tooltip]',
+ trigger: 'click' })
+ div.find('a').trigger('click')
+ ok($('.tooltip').is('.fade.in'), 'tooltip is faded in')
+ })
+
+ test('should show tooltip when toggle is called', function () {
+ var tooltip = $('
')
+ .appendTo('#qunit-fixture')
+ .tooltip({trigger: 'manual'})
+ .tooltip('toggle')
+ ok($('.tooltip').is('.fade.in'), 'tooltip should be toggled in')
+ })
+
+ test('should place tooltips inside the body', function () {
+ var tooltip = $('
')
+ .appendTo('#qunit-fixture')
+ .tooltip({container: 'body'})
+ .tooltip('show')
+ ok($('body > .tooltip').length, 'inside the body')
+ ok(!$('#qunit-fixture > .tooltip').length, 'not found in parent')
+ tooltip.tooltip('hide')
+ })
+
+ test('should place tooltip inside window', function () {
+ var container = $('
').appendTo('body')
+ .css({position: 'absolute', width: 200, height: 200, bottom: 0, left: 0}),
+ tooltip = $('
Hover me')
+ .css({position: 'absolute', top: 0, left: 0})
+ .appendTo(container)
+ .tooltip({placement: 'top', animate: false})
+ .tooltip('show')
+
+ stop()
+
+ setTimeout(function () {
+ ok($('.tooltip').offset().left >= 0)
+
+ start()
+ container.remove()
+ }, 100)
+ })
+
+ test('should place tooltip on top of element', function () {
+ var container = $('
').appendTo('body')
+ .css({position: 'absolute', bottom: 0, left: 0, textAlign: 'right', width: 300, height: 300}),
+ p = $('
').appendTo(container),
+ tooltiped = $('
Hover me')
+ .css({marginTop: 200})
+ .appendTo(p)
+ .tooltip({placement: 'top', animate: false})
+ .tooltip('show')
+
+ stop()
+
+ setTimeout(function () {
+ var tooltip = container.find('.tooltip')
+
+ start()
+ ok(Math.round(tooltip.offset().top + tooltip.outerHeight()) <= Math.round(tooltiped.offset().top))
+ container.remove()
+ }, 100)
+ })
+
+ test('should add position class before positioning so that position-specific styles are taken into account', function () {
+ $('head').append('')
+
+ var container = $('
').appendTo('body'),
+ target = $('
')
.appendTo(container)
- .tooltip({placement: 'top', animate: false})
- .tooltip('show')
+ .tooltip({placement: 'right'})
+ .tooltip('show'),
+ tooltip = container.find('.tooltip')
- stop()
+ // this is some dumb hack shit because sub pixels in firefox
+ var top = Math.round(target.offset().top + (target[0].offsetHeight / 2) - (tooltip[0].offsetHeight / 2))
+ var top2 = Math.round(tooltip.offset().top)
+ var topDiff = top - top2
+ ok(topDiff <= 1 && topDiff >= -1)
+ target.tooltip('hide')
+ })
- setTimeout(function () {
- ok($('.tooltip').offset().left >= 0)
+ test('tooltip title test #1', function () {
+ var tooltip = $('
')
+ .appendTo('#qunit-fixture')
+ .tooltip({})
+ .tooltip('show')
+ equal($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title from title attribute is set')
+ tooltip.tooltip('hide')
+ ok(!$('.tooltip').length, 'tooltip removed')
+ })
- start()
- container.remove()
- }, 100)
+ test('tooltip title test #2', function () {
+ var tooltip = $('
')
+ .appendTo('#qunit-fixture')
+ .tooltip({
+ title: 'This is a tooltip with some content'
})
+ .tooltip('show')
+ equal($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title is set from title attribute while prefered over title option')
+ tooltip.tooltip('hide')
+ ok(!$('.tooltip').length, 'tooltip removed')
+ })
- test('should place tooltip on top of element', function () {
- var container = $('
').appendTo('body')
- .css({position: 'absolute', bottom: 0, left: 0, textAlign: 'right', width: 300, height: 300}),
- p = $('
').appendTo(container),
- tooltiped = $('
Hover me')
- .css({marginTop: 200})
- .appendTo(p)
- .tooltip({placement: 'top', animate: false})
- .tooltip('show')
-
- stop()
-
- setTimeout(function () {
- var tooltip = container.find('.tooltip')
-
- start()
- ok(Math.round(tooltip.offset().top + tooltip.outerHeight()) <= Math.round(tooltiped.offset().top))
- container.remove()
- }, 100)
+ test('tooltip title test #3', function () {
+ var tooltip = $('
')
+ .appendTo('#qunit-fixture')
+ .tooltip({
+ title: 'This is a tooltip with some content'
})
+ .tooltip('show')
+ equal($('.tooltip').children('.tooltip-inner').text(), 'This is a tooltip with some content', 'title from title option is set')
+ tooltip.tooltip('hide')
+ ok(!$('.tooltip').length, 'tooltip removed')
+ })
- test('should add position class before positioning so that position-specific styles are taken into account', function () {
- $('head').append('')
-
- var container = $('
').appendTo('body'),
- target = $('
')
- .appendTo(container)
- .tooltip({placement: 'right'})
- .tooltip('show'),
- tooltip = container.find('.tooltip')
-
- // this is some dumb hack shit because sub pixels in firefox
- var top = Math.round(target.offset().top + (target[0].offsetHeight / 2) - (tooltip[0].offsetHeight / 2))
- var top2 = Math.round(tooltip.offset().top)
- var topDiff = top - top2
- ok(topDiff <= 1 && topDiff >= -1)
- target.tooltip('hide')
+ test('tooltips should be placed dynamically, with the dynamic placement option', function () {
+ $.support.transition = false
+ var ttContainer = $('
').css({
+ 'height' : 400,
+ 'overflow' : 'hidden',
+ 'position' : 'absolute',
+ 'top' : 0,
+ 'left' : 0,
+ 'width' : 600
})
+ .appendTo('body')
- test('tooltip title test #1', function () {
- var tooltip = $('
')
- .appendTo('#qunit-fixture')
- .tooltip({
- })
- .tooltip('show')
- equal($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title from title attribute is set')
- tooltip.tooltip('hide')
- ok(!$('.tooltip').length, 'tooltip removed')
- })
+ var topTooltip = $('
Top Dynamic Tooltip
')
+ .appendTo('#dynamic-tt-test')
+ .tooltip({placement: 'auto'})
+ .tooltip('show')
- test('tooltip title test #2', function () {
- var tooltip = $('
')
- .appendTo('#qunit-fixture')
- .tooltip({
- title: 'This is a tooltip with some content'
- })
- .tooltip('show')
- equal($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title is set from title attribute while prefered over title option')
- tooltip.tooltip('hide')
- ok(!$('.tooltip').length, 'tooltip removed')
- })
+ ok($('.tooltip').is('.bottom'), 'top positioned tooltip is dynamically positioned bottom')
- test('tooltip title test #3', function () {
- var tooltip = $('
')
- .appendTo('#qunit-fixture')
- .tooltip({
- title: 'This is a tooltip with some content'
- })
- .tooltip('show')
- equal($('.tooltip').children('.tooltip-inner').text(), 'This is a tooltip with some content', 'title from title option is set')
- tooltip.tooltip('hide')
- ok(!$('.tooltip').length, 'tooltip removed')
- })
+ topTooltip.tooltip('hide')
- test('tooltips should be placed dynamically, with the dynamic placement option', function () {
- $.support.transition = false
- var ttContainer = $('
').css({
- 'height' : 400,
- 'overflow' : 'hidden',
- 'position' : 'absolute',
- 'top' : 0,
- 'left' : 0,
- 'width' : 600})
- .appendTo('body')
+ var rightTooltip = $('
Right Dynamic Tooltip
')
+ .appendTo('#dynamic-tt-test')
+ .tooltip({placement: 'right auto'})
+ .tooltip('show')
- var topTooltip = $('
Top Dynamic Tooltip
')
- .appendTo('#dynamic-tt-test')
- .tooltip({placement: 'auto'})
- .tooltip('show')
+ ok($('.tooltip').is('.left'), 'right positioned tooltip is dynamically positioned left')
+ rightTooltip.tooltip('hide')
- ok($('.tooltip').is('.bottom'), 'top positioned tooltip is dynamically positioned bottom')
+ var leftTooltip = $('
Left Dynamic Tooltip
')
+ .appendTo('#dynamic-tt-test')
+ .tooltip({placement: 'auto left'})
+ .tooltip('show')
- topTooltip.tooltip('hide')
+ ok($('.tooltip').is('.right'), 'left positioned tooltip is dynamically positioned right')
+ leftTooltip.tooltip('hide')
- var rightTooltip = $('
Right Dynamic Tooltip
')
- .appendTo('#dynamic-tt-test')
- .tooltip({placement: 'right auto'})
- .tooltip('show')
-
- ok($('.tooltip').is('.left'), 'right positioned tooltip is dynamically positioned left')
- rightTooltip.tooltip('hide')
-
- var leftTooltip = $('
Left Dynamic Tooltip
')
- .appendTo('#dynamic-tt-test')
- .tooltip({placement: 'auto left'})
- .tooltip('show')
-
- ok($('.tooltip').is('.right'), 'left positioned tooltip is dynamically positioned right')
- leftTooltip.tooltip('hide')
-
- ttContainer.remove()
- })
+ ttContainer.remove()
+ })
})