ok(!$affix.hasClass('affix'), 'affix class was not added')
})
- test('should trigger affixed event after affix', function () {
- stop()
+ test('should trigger affixed event after affix', function (assert) {
+ var done = assert.async()
var templateHTML = '<div id="affixTarget">'
+ '<ul>'
}).on('affixed.bs.affix', function () {
ok(true, 'affixed event fired')
$('#affixTarget, #affixAfter').remove()
- start()
+ done()
})
setTimeout(function () {
}, 0)
})
- test('should affix-top when scrolling up to offset when parent has padding', function () {
- stop()
+ test('should affix-top when scrolling up to offset when parent has padding', function (assert) {
+ var done = assert.async()
var templateHTML = '<div id="padding-offset" style="padding-top: 20px;">'
+ '<div id="affixTopTarget">'
.on('affixed-top.bs.affix', function () {
ok($('#affixTopTarget').hasClass('affix-top'), 'affix-top class applied')
$('#padding-offset').remove()
- start()
+ done()
})
setTimeout(function () {
equal($('#qunit-fixture').find('.alert').length, 0, 'element removed from dom')
})
- test('should not fire closed when close is prevented', function () {
- stop()
+ test('should not fire closed when close is prevented', function (assert) {
+ var done = assert.async()
$('<div class="alert"/>')
.on('close.bs.alert', function (e) {
e.preventDefault()
ok(true, 'close event fired')
- start()
+ done()
})
.on('closed.bs.alert', function () {
ok(false, 'closed event fired')
strictEqual($button[0], $el[0], 'collection contains element')
})
- test('should return set state to loading', function () {
+ test('should return set state to loading', function (assert) {
var $btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
equal($btn.html(), 'mdo', 'btn text equals mdo')
$btn.bootstrapButton('loading')
- stop()
+ var done = assert.async()
setTimeout(function () {
equal($btn.html(), 'fat', 'btn text equals fat')
ok($btn[0].hasAttribute('disabled'), 'btn is disabled')
ok($btn.hasClass('disabled'), 'btn has disabled class')
- start()
+ done()
}, 0)
})
- test('should return reset state', function () {
+ test('should return reset state', function (assert) {
var $btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
equal($btn.html(), 'mdo', 'btn text equals mdo')
$btn.bootstrapButton('loading')
- stop()
+ var doneOne = assert.async()
setTimeout(function () {
equal($btn.html(), 'fat', 'btn text equals fat')
ok($btn[0].hasAttribute('disabled'), 'btn is disabled')
ok($btn.hasClass('disabled'), 'btn has disabled class')
- start()
- stop()
+ doneOne()
+ var doneTwo = assert.async()
$btn.bootstrapButton('reset')
setTimeout(function () {
equal($btn.html(), 'mdo', 'btn text equals mdo')
ok(!$btn[0].hasAttribute('disabled'), 'btn is not disabled')
ok(!$btn.hasClass('disabled'), 'btn does not have disabled class')
- start()
+ doneTwo()
}, 0)
}, 0)
})
- test('should work with an empty string as reset state', function () {
+ test('should work with an empty string as reset state', function (assert) {
var $btn = $('<button class="btn" data-loading-text="fat"/>')
equal($btn.html(), '', 'btn text equals ""')
$btn.bootstrapButton('loading')
- stop()
+ var doneOne = assert.async()
setTimeout(function () {
equal($btn.html(), 'fat', 'btn text equals fat')
ok($btn[0].hasAttribute('disabled'), 'btn is disabled')
ok($btn.hasClass('disabled'), 'btn has disabled class')
- start()
- stop()
+ doneOne()
+ var doneTwo = assert.async()
$btn.bootstrapButton('reset')
setTimeout(function () {
equal($btn.html(), '', 'btn text equals ""')
ok(!$btn[0].hasAttribute('disabled'), 'btn is not disabled')
ok(!$btn.hasClass('disabled'), 'btn does not have disabled class')
- start()
+ doneTwo()
}, 0)
}, 0)
})
strictEqual($carousel[0], $el[0], 'collection contains element')
})
- test('should not fire slid when slide is prevented', function () {
- stop()
+ test('should not fire slid when slide is prevented', function (assert) {
+ var done = assert.async()
$('<div class="carousel"/>')
.on('slide.bs.carousel', function (e) {
e.preventDefault()
ok(true, 'slide event fired')
- start()
+ done()
})
.on('slid.bs.carousel', function () {
ok(false, 'slid event fired')
.bootstrapCarousel('next')
})
- test('should reset when slide is prevented', function () {
+ test('should reset when slide is prevented', function (assert) {
var carouselHTML = '<div id="carousel-example-generic" class="carousel slide">'
+ '<ol class="carousel-indicators">'
+ '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>'
+ '</div>'
var $carousel = $(carouselHTML)
- stop()
+ var done = assert.async()
$carousel
.one('slide.bs.carousel', function (e) {
e.preventDefault()
ok(!$carousel.find('.carousel-indicators li:eq(0)').is('.active'), 'first indicator still active')
ok($carousel.find('.item:eq(1)').is('.active'), 'second item active')
ok($carousel.find('.carousel-indicators li:eq(1)').is('.active'), 'second indicator active')
- start()
+ done()
}, 0)
})
.bootstrapCarousel('next')
})
- test('should fire slide event with direction', function () {
+ test('should fire slide event with direction', function (assert) {
var carouselHTML = '<div id="myCarousel" class="carousel slide">'
+ '<div class="carousel-inner">'
+ '<div class="item active">'
+ '</div>'
var $carousel = $(carouselHTML)
- stop()
+ var done = assert.async()
$carousel
.one('slide.bs.carousel', function (e) {
.one('slide.bs.carousel', function (e) {
ok(e.direction, 'direction present on prev')
strictEqual(e.direction, 'right', 'direction is right on prev')
- start()
+ done()
})
.bootstrapCarousel('prev')
})
.bootstrapCarousel('next')
})
- test('should fire slid event with direction', function () {
+ test('should fire slid event with direction', function (assert) {
var carouselHTML = '<div id="myCarousel" class="carousel slide">'
+ '<div class="carousel-inner">'
+ '<div class="item active">'
+ '</div>'
var $carousel = $(carouselHTML)
- stop()
+ var done = assert.async()
$carousel
.one('slid.bs.carousel', function (e) {
.one('slid.bs.carousel', function (e) {
ok(e.direction, 'direction present on prev')
strictEqual(e.direction, 'right', 'direction is right on prev')
- start()
+ done()
})
.bootstrapCarousel('prev')
})
.bootstrapCarousel('next')
})
- test('should fire slide event with relatedTarget', function () {
+ test('should fire slide event with relatedTarget', function (assert) {
var template = '<div id="myCarousel" class="carousel slide">'
+ '<div class="carousel-inner">'
+ '<div class="item active">'
+ '<a class="right carousel-control" href="#myCarousel" data-slide="next">›</a>'
+ '</div>'
- stop()
+ var done = assert.async()
$(template)
.on('slide.bs.carousel', function (e) {
ok(e.relatedTarget, 'relatedTarget present')
ok($(e.relatedTarget).hasClass('item'), 'relatedTarget has class "item"')
- start()
+ done()
})
.bootstrapCarousel('next')
})
- test('should fire slid event with relatedTarget', function () {
+ test('should fire slid event with relatedTarget', function (assert) {
var template = '<div id="myCarousel" class="carousel slide">'
+ '<div class="carousel-inner">'
+ '<div class="item active">'
+ '<a class="right carousel-control" href="#myCarousel" data-slide="next">›</a>'
+ '</div>'
- stop()
+ var done = assert.async()
$(template)
.on('slid.bs.carousel', function (e) {
ok(e.relatedTarget, 'relatedTarget present')
ok($(e.relatedTarget).hasClass('item'), 'relatedTarget has class "item"')
- start()
+ done()
})
.bootstrapCarousel('next')
})
})
})
- test('should wrap around from end to start when wrap option is true', function () {
+ test('should wrap around from end to start when wrap option is true', function (assert) {
var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="true">'
+ '<ol class="carousel-indicators">'
+ '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>'
var $carousel = $(carouselHTML)
var getActiveId = function () { return $carousel.find('.item.active').attr('id') }
- stop()
+ var done = assert.async()
$carousel
.one('slid.bs.carousel', function () {
$carousel
.one('slid.bs.carousel', function () {
strictEqual(getActiveId(), 'one', 'carousel wrapped around and slid from 3rd to 1st slide')
- start()
+ done()
})
.bootstrapCarousel('next')
})
.bootstrapCarousel('next')
})
- test('should wrap around from start to end when wrap option is true', function () {
+ test('should wrap around from start to end when wrap option is true', function (assert) {
var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="true">'
+ '<ol class="carousel-indicators">'
+ '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>'
+ '</div>'
var $carousel = $(carouselHTML)
- stop()
+ var done = assert.async()
$carousel
.on('slid.bs.carousel', function () {
strictEqual($carousel.find('.item.active').attr('id'), 'three', 'carousel wrapped around and slid from 1st to 3rd slide')
- start()
+ done()
})
.bootstrapCarousel('prev')
})
- test('should stay at the end when the next method is called and wrap is false', function () {
+ test('should stay at the end when the next method is called and wrap is false', function (assert) {
var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="false">'
+ '<ol class="carousel-indicators">'
+ '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>'
var $carousel = $(carouselHTML)
var getActiveId = function () { return $carousel.find('.item.active').attr('id') }
- stop()
+ var done = assert.async()
$carousel
.one('slid.bs.carousel', function () {
})
.bootstrapCarousel('next')
strictEqual(getActiveId(), 'three', 'carousel did not wrap around and stayed on 3rd slide')
- start()
+ done()
})
.bootstrapCarousel('next')
})
ok(/height/i.test($el.attr('style')), 'has height set')
})
- test('should not fire shown when show is prevented', function () {
- stop()
+ test('should not fire shown when show is prevented', function (assert) {
+ var done = assert.async()
$('<div class="collapse"/>')
.on('show.bs.collapse', function (e) {
e.preventDefault()
ok(true, 'show event fired')
- start()
+ done()
})
.on('shown.bs.collapse', function () {
ok(false, 'shown event fired')
.bootstrapCollapse('show')
})
- test('should reset style to auto after finishing opening collapse', function () {
- stop()
+ test('should reset style to auto after finishing opening collapse', function (assert) {
+ var done = assert.async()
$('<div class="collapse" style="height: 0px"/>')
.on('show.bs.collapse', function () {
})
.on('shown.bs.collapse', function () {
strictEqual(this.style.height, '', 'height is auto')
- start()
+ done()
})
.bootstrapCollapse('show')
})
- test('should remove "collapsed" class from target when collapse is shown', function () {
- stop()
+ test('should remove "collapsed" class from target when collapse is shown', function (assert) {
+ var done = assert.async()
var $target = $('<a data-toggle="collapse" class="collapsed" href="#test1"/>').appendTo('#qunit-fixture')
.appendTo('#qunit-fixture')
.on('shown.bs.collapse', function () {
ok(!$target.hasClass('collapsed'))
- start()
+ done()
})
$target.click()
})
- test('should add "collapsed" class to target when collapse is hidden', function () {
- stop()
+ test('should add "collapsed" class to target when collapse is hidden', function (assert) {
+ var done = assert.async()
var $target = $('<a data-toggle="collapse" href="#test1"/>').appendTo('#qunit-fixture')
.appendTo('#qunit-fixture')
.on('hidden.bs.collapse', function () {
ok($target.hasClass('collapsed'))
- start()
+ done()
})
$target.click()
})
- test('should not close a collapse when initialized with "show" if already shown', function () {
- stop()
+ test('should not close a collapse when initialized with "show" if already shown', function (assert) {
+ var done = assert.async()
expect(0)
$test.bootstrapCollapse('show')
- setTimeout(start, 0)
+ setTimeout(done, 0)
})
- test('should open a collapse when initialized with "show" if not already shown', function () {
- stop()
+ test('should open a collapse when initialized with "show" if not already shown', function (assert) {
+ var done = assert.async()
expect(1)
$test.bootstrapCollapse('show')
- setTimeout(start, 0)
+ setTimeout(done, 0)
})
- test('should remove "collapsed" class from active accordion target', function () {
- stop()
+ test('should remove "collapsed" class from active accordion target', function (assert) {
+ var done = assert.async()
var accordionHTML = '<div class="panel-group" id="accordion">'
+ '<div class="panel"/>'
ok($target2.hasClass('collapsed'), 'inactive target 2 does have class "collapsed"')
ok(!$target3.hasClass('collapsed'), 'active target 3 does not have class "collapsed"')
- start()
+ done()
})
$target3.click()
})
- test('should allow dots in data-parent', function () {
- stop()
+ test('should allow dots in data-parent', function (assert) {
+ var done = assert.async()
var accordionHTML = '<div class="panel-group accordion">'
+ '<div class="panel"/>'
ok($target2.hasClass('collapsed'), 'inactive target 2 does have class "collapsed"')
ok(!$target3.hasClass('collapsed'), 'active target 3 does not have class "collapsed"')
- start()
+ done()
})
$target3.click()
})
- test('should set aria-expanded="true" on target when collapse is shown', function () {
- stop()
+ test('should set aria-expanded="true" on target when collapse is shown', function (assert) {
+ var done = assert.async()
var $target = $('<a data-toggle="collapse" class="collapsed" href="#test1" aria-expanded="false"/>').appendTo('#qunit-fixture')
.appendTo('#qunit-fixture')
.on('shown.bs.collapse', function () {
equal($target.attr('aria-expanded'), 'true', 'aria-expanded on target is "true"')
- start()
+ done()
})
$target.click()
})
- test('should set aria-expanded="false" on target when collapse is hidden', function () {
- stop()
+ test('should set aria-expanded="false" on target when collapse is hidden', function (assert) {
+ var done = assert.async()
var $target = $('<a data-toggle="collapse" href="#test1" aria-expanded="true"/>').appendTo('#qunit-fixture')
.appendTo('#qunit-fixture')
.on('hidden.bs.collapse', function () {
equal($target.attr('aria-expanded'), 'false', 'aria-expanded on target is "false"')
- start()
+ done()
})
$target.click()
})
- test('should change aria-expanded from active accordion target to "false" and set the newly active one to "true"', function () {
- stop()
+ test('should change aria-expanded from active accordion target to "false" and set the newly active one to "true"', function (assert) {
+ var done = assert.async()
var accordionHTML = '<div class="panel-group" id="accordion">'
+ '<div class="panel"/>'
equal($target2.attr('aria-expanded'), 'false', 'inactive target 2 has aria-expanded="false"')
equal($target3.attr('aria-expanded'), 'true', 'active target 3 has aria-expanded="false"')
- start()
+ done()
})
$target3.click()
})
- test('should not fire show event if show is prevented because other element is still transitioning', function () {
- stop()
+ test('should not fire show event if show is prevented because other element is still transitioning', function (assert) {
+ var done = assert.async()
var accordionHTML = '<div id="accordion">'
+ '<div class="panel"/>'
setTimeout(function () {
ok(!showFired, 'show event didn\'t fire')
- start()
+ done()
}, 1)
})
- test('should add "collapsed" class to target when collapse is hidden via manual invocation', function () {
- stop()
+ test('should add "collapsed" class to target when collapse is hidden via manual invocation', function (assert) {
+ var done = assert.async()
var $target = $('<a data-toggle="collapse" href="#test1"/>').appendTo('#qunit-fixture')
.appendTo('#qunit-fixture')
.on('hidden.bs.collapse', function () {
ok($target.hasClass('collapsed'))
- start()
+ done()
})
.bootstrapCollapse('hide')
})
- test('should remove "collapsed" class from target when collapse is shown via manual invocation', function () {
- stop()
+ test('should remove "collapsed" class from target when collapse is shown via manual invocation', function (assert) {
+ var done = assert.async()
var $target = $('<a data-toggle="collapse" class="collapsed" href="#test1"/>').appendTo('#qunit-fixture')
.appendTo('#qunit-fixture')
.on('shown.bs.collapse', function () {
ok(!$target.hasClass('collapsed'))
- start()
+ done()
})
.bootstrapCollapse('show')
})
strictEqual($('#qunit-fixture .open').length, 0, '"open" class removed')
})
- test('should fire show and hide event', function () {
+ test('should fire show and hide event', function (assert) {
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
.find('[data-toggle="dropdown"]')
.bootstrapDropdown()
- stop()
+ var done = assert.async()
$dropdown
.parent('.dropdown')
})
.on('hide.bs.dropdown', function () {
ok(true, 'hide was fired')
- start()
+ done()
})
$dropdown.click()
})
- test('should fire shown and hidden event', function () {
+ test('should fire shown and hidden event', function (assert) {
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
.find('[data-toggle="dropdown"]')
.bootstrapDropdown()
- stop()
+ var done = assert.async()
$dropdown
.parent('.dropdown')
})
.on('hidden.bs.dropdown', function () {
ok(true, 'hidden was fired')
- start()
+ done()
})
$dropdown.click()
$(document.body).click()
})
- test('should ignore keyboard events within <input>s and <textarea>s', function () {
- stop()
+ test('should ignore keyboard events within <input>s and <textarea>s', function (assert) {
+ var done = assert.async()
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
$textarea.focus().trigger($.Event('keydown', { which: 38 }))
ok($(document.activeElement).is($textarea), 'textarea still focused')
- start()
+ done()
})
$dropdown.click()
ok($.fn.bootstrapModal.Constructor.DEFAULTS, 'default object exposed')
})
- test('should insert into dom when show method is called', function () {
- stop()
+ test('should insert into dom when show method is called', function (assert) {
+ var done = assert.async()
$('<div id="modal-test"/>')
.on('shown.bs.modal', function () {
notEqual($('#modal-test').length, 0, 'modal inserted into dom')
- start()
+ done()
})
.bootstrapModal('show')
})
- test('should fire show event', function () {
- stop()
+ test('should fire show event', function (assert) {
+ var done = assert.async()
$('<div id="modal-test"/>')
.on('show.bs.modal', function () {
ok(true, 'show event fired')
- start()
+ done()
})
.bootstrapModal('show')
})
- test('should not fire shown when show was prevented', function () {
- stop()
+ test('should not fire shown when show was prevented', function (assert) {
+ var done = assert.async()
$('<div id="modal-test"/>')
.on('show.bs.modal', function (e) {
e.preventDefault()
ok(true, 'show event fired')
- start()
+ done()
})
.on('shown.bs.modal', function () {
ok(false, 'shown event fired')
.bootstrapModal('show')
})
- test('should hide modal when hide is called', function () {
- stop()
+ test('should hide modal when hide is called', function (assert) {
+ var done = assert.async()
$('<div id="modal-test"/>')
.on('shown.bs.modal', function () {
})
.on('hidden.bs.modal', function () {
ok(!$('#modal-test').is(':visible'), 'modal hidden')
- start()
+ done()
})
.bootstrapModal('show')
})
- test('should toggle when toggle is called', function () {
- stop()
+ test('should toggle when toggle is called', function (assert) {
+ var done = assert.async()
$('<div id="modal-test"/>')
.on('shown.bs.modal', function () {
})
.on('hidden.bs.modal', function () {
ok(!$('#modal-test').is(':visible'), 'modal hidden')
- start()
+ done()
})
.bootstrapModal('toggle')
})
- test('should remove from dom when click [data-dismiss="modal"]', function () {
- stop()
+ test('should remove from dom when click [data-dismiss="modal"]', function (assert) {
+ var done = assert.async()
$('<div id="modal-test"><span class="close" data-dismiss="modal"/></div>')
.on('shown.bs.modal', function () {
})
.on('hidden.bs.modal', function () {
ok(!$('#modal-test').is(':visible'), 'modal hidden')
- start()
+ done()
})
.bootstrapModal('toggle')
})
- test('should allow modal close with "backdrop:false"', function () {
- stop()
+ test('should allow modal close with "backdrop:false"', function (assert) {
+ var done = assert.async()
$('<div id="modal-test" data-backdrop="false"/>')
.on('shown.bs.modal', function () {
})
.on('hidden.bs.modal', function () {
ok(!$('#modal-test').is(':visible'), 'modal hidden')
- start()
+ done()
})
.bootstrapModal('show')
})
- test('should close modal when clicking outside of modal-content', function () {
- stop()
+ test('should close modal when clicking outside of modal-content', function (assert) {
+ var done = assert.async()
$('<div id="modal-test"><div class="contents"/></div>')
.on('shown.bs.modal', function () {
})
.on('hidden.bs.modal', function () {
ok(!$('#modal-test').is(':visible'), 'modal hidden')
- start()
+ done()
})
.bootstrapModal('show')
})
- test('should close modal when escape key is pressed via keydown', function () {
- stop()
+ test('should close modal when escape key is pressed via keydown', function (assert) {
+ var done = assert.async()
var div = $('<div id="modal-test"/>')
div
setTimeout(function () {
ok(!$('#modal-test').is(':visible'), 'modal hidden')
div.remove()
- start()
+ done()
}, 0)
})
.bootstrapModal('show')
})
- test('should not close modal when escape key is pressed via keyup', function () {
- stop()
+ test('should not close modal when escape key is pressed via keyup', function (assert) {
+ var done = assert.async()
var div = $('<div id="modal-test"/>')
div
setTimeout(function () {
ok($('#modal-test').is(':visible'), 'modal still visible')
div.remove()
- start()
+ done()
}, 0)
})
.bootstrapModal('show')
})
- test('should trigger hide event once when clicking outside of modal-content', function () {
- stop()
+ test('should trigger hide event once when clicking outside of modal-content', function (assert) {
+ var done = assert.async()
var triggered
.on('hide.bs.modal', function () {
triggered += 1
strictEqual(triggered, 1, 'modal hide triggered once')
- start()
+ done()
})
.bootstrapModal('show')
})
- test('should close reopened modal with [data-dismiss="modal"] click', function () {
- stop()
+ test('should close reopened modal with [data-dismiss="modal"] click', function (assert) {
+ var done = assert.async()
$('<div id="modal-test"><div class="contents"><div id="close" data-dismiss="modal"/></div></div>')
.on('shown.bs.modal', function () {
.one('hidden.bs.modal', function () {
$(this)
.one('hidden.bs.modal', function () {
- start()
+ done()
})
.bootstrapModal('show')
})
.bootstrapModal('show')
})
- test('should restore focus to toggling element when modal is hidden after having been opened via data-api', function () {
- stop()
+ test('should restore focus to toggling element when modal is hidden after having been opened via data-api', function (assert) {
+ var done = assert.async()
var $toggleBtn = $('<button data-toggle="modal" data-target="#modal-test"/>').appendTo('#qunit-fixture')
.on('hidden.bs.modal', function () {
setTimeout(function () {
ok($(document.activeElement).is($toggleBtn), 'toggling element is once again focused')
- start()
+ done()
}, 0)
})
.on('shown.bs.modal', function () {
$toggleBtn.click()
})
- test('should not restore focus to toggling element if the associated show event gets prevented', function () {
- stop()
+ test('should not restore focus to toggling element if the associated show event gets prevented', function (assert) {
+ var done = assert.async()
var $toggleBtn = $('<button data-toggle="modal" data-target="#modal-test"/>').appendTo('#qunit-fixture')
var $otherBtn = $('<button id="other-btn"/>').appendTo('#qunit-fixture')
.on('hidden.bs.modal', function () {
setTimeout(function () {
ok($(document.activeElement).is($otherBtn), 'focus returned to toggling element')
- start()
+ done()
}, 0)
})
.on('shown.bs.modal', function () {
equal($('.popover').length, 0, 'popover was removed')
})
- test('should detach popover content rather than removing it so that event handlers are left intact', function () {
+ test('should detach popover content rather than removing it so that event handlers are left intact', function (assert) {
var $content = $('<div class="content-with-handler"><a class="btn btn-warning">Button with event handler</a></div>').appendTo('#qunit-fixture')
var handlerCalled = false
}
})
- stop()
+ var done = assert.async()
$div
.one('shown.bs.popover', function () {
$div
$('.content-with-handler .btn').click()
$div.bootstrapPopover('destroy')
ok(handlerCalled, 'content\'s event handler still present')
- start()
+ done()
})
.bootstrapPopover('show')
})
strictEqual($scrollspy[0], $el[0], 'collection contains element')
})
- test('should only switch "active" class on current target', function () {
- stop()
+ test('should only switch "active" class on current target', function (assert) {
+ var done = assert.async()
var sectionHTML = '<div id="root" class="active">'
+ '<div class="topbar">'
$scrollspy.on('scroll.bs.scrollspy', function () {
ok($section.hasClass('active'), '"active" class still on root node')
- start()
+ done()
})
$scrollspy.scrollTop(350)
})
- test('should correctly select middle navigation option when large offset is used', function () {
- stop()
+ test('should correctly select middle navigation option when large offset is used', function (assert) {
+ var done = assert.async()
var sectionHTML = '<div id="header" style="height: 500px;"></div>'
+ '<nav id="navigation" class="navbar">'
ok(!$section.find('#one-link').parent().hasClass('active'), '"active" class removed from first section')
ok($section.find('#two-link').parent().hasClass('active'), '"active" class on middle section')
ok(!$section.find('#three-link').parent().hasClass('active'), '"active" class not on last section')
- start()
+ done()
})
$scrollspy.scrollTop(550)
})
- test('should add the active class to the correct element', function () {
+ test('should add the active class to the correct element', function (assert) {
var navbarHtml =
'<nav class="navbar">'
+ '<ul class="nav">'
var testElementIsActiveAfterScroll = function (element, target) {
var deferred = $.Deferred()
var scrollHeight = Math.ceil($content.scrollTop() + $(target).position().top)
- stop()
+ var done = assert.async()
$content.one('scroll', function () {
ok($(element).hasClass('active'), 'target:' + target + ', element' + element)
- start()
+ done()
deferred.resolve()
})
$content.scrollTop(scrollHeight)
.then(function () { return testElementIsActiveAfterScroll('#li-2', '#div-2') })
})
- test('should clear selection if above the first section', function () {
- stop()
+ test('should clear selection if above the first section', function (assert) {
+ var done = assert.async()
var sectionHTML = '<div id="header" style="height: 500px;"></div>'
+ '<nav id="navigation" class="navbar">'
$scrollspy
.one('scroll.bs.scrollspy', function () {
strictEqual($('.active').length, 0, 'selection cleared')
- start()
+ done()
})
.scrollTop(0)
})
equal($('#qunit-fixture').find('.active').attr('id'), 'home')
})
- test('should not fire shown when show is prevented', function () {
- stop()
+ test('should not fire shown when show is prevented', function (assert) {
+ var done = assert.async()
$('<div class="tab"/>')
.on('show.bs.tab', function (e) {
e.preventDefault()
ok(true, 'show event fired')
- start()
+ done()
})
.on('shown.bs.tab', function () {
ok(false, 'shown event fired')
.bootstrapTab('show')
})
- test('show and shown events should reference correct relatedTarget', function () {
- stop()
+ test('show and shown events should reference correct relatedTarget', function (assert) {
+ var done = assert.async()
var dropHTML = '<ul class="drop">'
+ '<li class="dropdown"><a data-toggle="dropdown" href="#">1</a>'
.find('ul > li:last a')
.on('show.bs.tab', function (e) {
equal(e.relatedTarget.hash, '#1-1', 'references correct element as relatedTarget')
- start()
+ done()
})
.on('shown.bs.tab', function (e) {
equal(e.relatedTarget.hash, '#1-1', 'references correct element as relatedTarget')
.bootstrapTab('show')
})
- test('should fire hide and hidden events', function () {
- stop()
+ test('should fire hide and hidden events', function (assert) {
+ var done = assert.async()
var tabsHTML = '<ul class="tabs">'
+ '<li><a href="#home">Home</a></li>'
.find('li:first a')
.on('hidden.bs.tab', function () {
ok(true, 'hidden event fired')
- start()
+ done()
})
.bootstrapTab('show')
.end()
.bootstrapTab('show')
})
- test('should not fire hidden when hide is prevented', function () {
- stop()
+ test('should not fire hidden when hide is prevented', function (assert) {
+ var done = assert.async()
var tabsHTML = '<ul class="tabs">'
+ '<li><a href="#home">Home</a></li>'
.on('hide.bs.tab', function (e) {
e.preventDefault()
ok(true, 'hide event fired')
- start()
+ done()
})
.on('hidden.bs.tab', function () {
ok(false, 'hidden event fired')
.bootstrapTab('show')
})
- test('hide and hidden events contain correct relatedTarget', function () {
- stop()
+ test('hide and hidden events contain correct relatedTarget', function (assert) {
+ var done = assert.async()
var tabsHTML = '<ul class="tabs">'
+ '<li><a href="#home">Home</a></li>'
})
.on('hidden.bs.tab', function (e) {
equal(e.relatedTarget.hash, '#profile', 'references correct element as relatedTarget')
- start()
+ done()
})
.bootstrapTab('show')
.end()
equal($('.tooltip').length, 0, 'tooltip removed')
})
- test('should fire show event', function () {
- stop()
+ test('should fire show event', function (assert) {
+ var done = assert.async()
$('<div title="tooltip title"/>')
.on('show.bs.tooltip', function () {
ok(true, 'show event fired')
- start()
+ done()
})
.bootstrapTooltip('show')
})
- test('should fire shown event', function () {
- stop()
+ test('should fire shown event', function (assert) {
+ var done = assert.async()
$('<div title="tooltip title"></div>')
.appendTo('#qunit-fixture')
.on('shown.bs.tooltip', function () {
ok(true, 'shown was called')
- start()
+ done()
})
.bootstrapTooltip('show')
})
- test('should not fire shown event when show was prevented', function () {
- stop()
+ test('should not fire shown event when show was prevented', function (assert) {
+ var done = assert.async()
$('<div title="tooltip title"/>')
.on('show.bs.tooltip', function (e) {
e.preventDefault()
ok(true, 'show event fired')
- start()
+ done()
})
.on('shown.bs.tooltip', function () {
ok(false, 'shown event fired')
.bootstrapTooltip('show')
})
- test('should fire hide event', function () {
- stop()
+ test('should fire hide event', function (assert) {
+ var done = assert.async()
$('<div title="tooltip title"/>')
.appendTo('#qunit-fixture')
})
.on('hide.bs.tooltip', function () {
ok(true, 'hide event fired')
- start()
+ done()
})
.bootstrapTooltip('show')
})
- test('should fire hidden event', function () {
- stop()
+ test('should fire hidden event', function (assert) {
+ var done = assert.async()
$('<div title="tooltip title"/>')
.appendTo('#qunit-fixture')
})
.on('hidden.bs.tooltip', function () {
ok(true, 'hidden event fired')
- start()
+ done()
})
.bootstrapTooltip('show')
})
- test('should not fire hidden event when hide was prevented', function () {
- stop()
+ test('should not fire hidden event when hide was prevented', function (assert) {
+ var done = assert.async()
$('<div title="tooltip title"/>')
.appendTo('#qunit-fixture')
.on('hide.bs.tooltip', function (e) {
e.preventDefault()
ok(true, 'hide event fired')
- start()
+ done()
})
.on('hidden.bs.tooltip', function () {
ok(false, 'hidden event fired')
ok(passed, '.tooltip(\'show\') should not throw an error if element no longer is in dom')
})
- test('should place tooltip on top of element', function () {
- stop()
+ test('should place tooltip on top of element', function (assert) {
+ var done = assert.async()
var containerHTML = '<div>'
+ '<p style="margin-top: 200px">'
setTimeout(function () {
ok(Math.round($tooltip.offset().top + $tooltip.outerHeight()) <= Math.round($trigger.offset().top))
- start()
+ done()
}, 0)
})
- test('should place tooltip inside viewport', function () {
- stop()
+ test('should place tooltip inside viewport', function (assert) {
+ var done = assert.async()
var $container = $('<div/>')
.css({
setTimeout(function () {
ok($('.tooltip').offset().left >= 0)
- start()
+ done()
}, 0)
})
- test('should show tooltip if leave event hasn\'t occurred before delay expires', function () {
- stop()
+ test('should show tooltip if leave event hasn\'t occurred before delay expires', function (assert) {
+ var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
setTimeout(function () {
ok($('.tooltip').is('.fade.in'), '200ms: tooltip is faded in')
- start()
+ done()
}, 200)
$tooltip.trigger('mouseenter')
})
- test('should not show tooltip if leave event occurs before delay expires', function () {
- stop()
+ test('should not show tooltip if leave event occurs before delay expires', function (assert) {
+ var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
setTimeout(function () {
ok(!$('.tooltip').is('.fade.in'), '200ms: tooltip not faded in')
- start()
+ done()
}, 200)
$tooltip.trigger('mouseenter')
})
- test('should not hide tooltip if leave event occurs and enter event occurs within the hide delay', function () {
- stop()
+ test('should not hide tooltip if leave event occurs and enter event occurs within the hide delay', function (assert) {
+ var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
setTimeout(function () {
ok($('.tooltip').is('.fade.in'), '200ms: tooltip still faded in')
- start()
+ done()
}, 200)
}, 0)
$tooltip.trigger('mouseenter')
})
- test('should not show tooltip if leave event occurs before delay expires', function () {
- stop()
+ test('should not show tooltip if leave event occurs before delay expires', function (assert) {
+ var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
setTimeout(function () {
ok(!$('.tooltip').is('.fade.in'), '200ms: tooltip not faded in')
- start()
+ done()
}, 200)
$tooltip.trigger('mouseenter')
})
- test('should not show tooltip if leave event occurs before delay expires, even if hide delay is 0', function () {
- stop()
+ test('should not show tooltip if leave event occurs before delay expires, even if hide delay is 0', function (assert) {
+ var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
setTimeout(function () {
ok(!$('.tooltip').is('.fade.in'), '250ms: tooltip not faded in')
- start()
+ done()
}, 250)
$tooltip.trigger('mouseenter')
})
- test('should wait 200ms before hiding the tooltip', function () {
- stop()
+ test('should wait 200ms before hiding the tooltip', function (assert) {
+ var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
setTimeout(function () {
ok(!$tooltip.data('bs.tooltip').$tip.is('.in'), '200ms: tooltip removed')
- start()
+ done()
}, 200)
}, 0)
$tooltip.trigger('mouseenter')
})
- test('should correctly position tooltips on SVG elements', function () {
+ test('should correctly position tooltips on SVG elements', function (assert) {
if (!window.SVGElement) {
// Skip IE8 since it doesn't support SVG
expect(0)
return
}
- stop()
+ var done = assert.async()
var styles = '<style>'
+ '.tooltip, .tooltip *, .tooltip *:before, .tooltip *:after { box-sizing: border-box; }'
ok(Math.abs(offset.left - 88) <= 1, 'tooltip has correct horizontal location')
$circle.bootstrapTooltip('hide')
equal($('.tooltip').length, 0, 'tooltip removed from dom')
- start()
+ done()
})
.bootstrapTooltip({ container: 'body', placement: 'top', trigger: 'manual' })
$circle.bootstrapTooltip('show')
})
- test('should correctly determine auto placement based on container rather than parent', function () {
- stop()
+ test('should correctly determine auto placement based on container rather than parent', function (assert) {
+ var done = assert.async()
var styles = '<style>'
+ '.tooltip, .tooltip *, .tooltip *:before, .tooltip *:after { box-sizing: border-box; }'
$styles.remove()
$(this).remove()
equal($('.tooltip').length, 0, 'tooltip removed from dom')
- start()
+ done()
})
.bootstrapTooltip({
container: 'body',
equal(currentUid, $('#tt-content').text())
})
- test('should position arrow correctly when tooltip is moved to not appear offscreen', function () {
- stop()
+ test('should position arrow correctly when tooltip is moved to not appear offscreen', function (assert) {
+ var done = assert.async()
var styles = '<style>'
+ '.tooltip, .tooltip *, .tooltip *:before, .tooltip *:after { box-sizing: border-box; }'
$styles.remove()
$(this).remove()
equal($('.tooltip').length, 0, 'tooltip removed from dom')
- start()
+ done()
})
.bootstrapTooltip({
container: 'body',
.bootstrapTooltip('show')
})
- test('should correctly position tooltips on transformed elements', function () {
+ test('should correctly position tooltips on transformed elements', function (assert) {
var styleProps = document.documentElement.style
if (!('transform' in styleProps) && !('webkitTransform' in styleProps) && !('msTransform' in styleProps)) {
expect(0)
return
}
- stop()
+ var done = assert.async()
var styles = '<style>'
+ '#qunit-fixture { top: 0; left: 0; }'
ok(Math.abs(offset.left - 88) <= 1, 'tooltip has correct horizontal location')
ok(Math.abs(offset.top - 126) <= 1, 'tooltip has correct vertical location')
$element.bootstrapTooltip('hide')
- start()
+ done()
})
.bootstrapTooltip({
container: 'body',