_removeElement(element) {
$(element).removeClass(ClassName.SHOW)
- if (!Util.supportsTransitionEnd() ||
- !$(element).hasClass(ClassName.FADE)) {
+ if (!$(element).hasClass(ClassName.FADE)) {
this._destroyElement(element)
return
}
this._isPaused = true
}
- if ($(this._element).find(Selector.NEXT_PREV)[0] &&
- Util.supportsTransitionEnd()) {
+ if ($(this._element).find(Selector.NEXT_PREV)[0]) {
Util.triggerTransitionEnd(this._element)
this.cycle(true)
}
to: nextElementIndex
})
- if (Util.supportsTransitionEnd() &&
- $(this._element).hasClass(ClassName.SLIDE)) {
+ if ($(this._element).hasClass(ClassName.SLIDE)) {
$(nextElement).addClass(orderClassName)
Util.reflow(nextElement)
$(this._element).trigger(Event.SHOWN)
}
- if (!Util.supportsTransitionEnd()) {
- complete()
- return
- }
-
const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1)
const scrollSize = `scroll${capitalizedDimension}`
const transitionDuration = Util.getTransitionDurationFromElement(this._element)
}
this._element.style[dimension] = ''
-
- if (!Util.supportsTransitionEnd()) {
- complete()
- return
- }
-
const transitionDuration = Util.getTransitionDurationFromElement(this._element)
$(this._element)
return
}
- if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) {
+ if ($(this._element).hasClass(ClassName.FADE)) {
this._isTransitioning = true
}
}
this._isShown = false
-
- const transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)
+ const transition = $(this._element).hasClass(ClassName.FADE)
if (transition) {
this._isTransitioning = true
}
_showElement(relatedTarget) {
- const transition = Util.supportsTransitionEnd() &&
- $(this._element).hasClass(ClassName.FADE)
+ const transition = $(this._element).hasClass(ClassName.FADE)
if (!this._element.parentNode ||
this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
? ClassName.FADE : ''
if (this._isShown && this._config.backdrop) {
- const doAnimate = Util.supportsTransitionEnd() && animate
-
this._backdrop = document.createElement('div')
this._backdrop.className = ClassName.BACKDROP
}
})
- if (doAnimate) {
+ if (animate) {
Util.reflow(this._backdrop)
}
return
}
- if (!doAnimate) {
+ if (!animate) {
callback()
return
}
}
}
- if (Util.supportsTransitionEnd() &&
- $(this._element).hasClass(ClassName.FADE)) {
+ if ($(this._element).hasClass(ClassName.FADE)) {
const backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop)
$(this._backdrop)
const active = activeElements[0]
const isTransitioning = callback &&
- Util.supportsTransitionEnd() &&
(active && $(active).hasClass(ClassName.FADE))
const complete = () => this._transitionComplete(
}
}
- if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
+ if ($(this.tip).hasClass(ClassName.FADE)) {
const transitionDuration = Util.getTransitionDurationFromElement(this.tip)
$(this.tip)
this._activeTrigger[Trigger.FOCUS] = false
this._activeTrigger[Trigger.HOVER] = false
- if (Util.supportsTransitionEnd() &&
- $(this.tip).hasClass(ClassName.FADE)) {
+ if ($(this.tip).hasClass(ClassName.FADE)) {
const transitionDuration = Util.getTransitionDurationFromElement(tip)
$(tip)
* ------------------------------------------------------------------------
*/
- let transition = false
-
+ const TRANSITION_END = 'transitionend'
const MAX_UID = 1000000
const MILLISECONDS_MULTIPLIER = 1000
function getSpecialTransitionEndEvent() {
return {
- bindType: transition.end,
- delegateType: transition.end,
+ bindType: TRANSITION_END,
+ delegateType: TRANSITION_END,
handle(event) {
if ($(event.target).is(this)) {
return event.handleObj.handler.apply(this, arguments) // eslint-disable-line prefer-rest-params
}
}
- function transitionEndTest() {
- if (typeof window !== 'undefined' && window.QUnit) {
- return false
- }
-
- return {
- end: 'transitionend'
- }
- }
-
function transitionEndEmulator(duration) {
let called = false
}
function setTransitionEndSupport() {
- transition = transitionEndTest()
-
$.fn.emulateTransitionEnd = transitionEndEmulator
-
- if (Util.supportsTransitionEnd()) {
- $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent()
- }
+ $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent()
}
/**
},
triggerTransitionEnd(element) {
- $(element).trigger(transition.end)
+ $(element).trigger(TRANSITION_END)
},
+ // TODO: Remove in v5
supportsTransitionEnd() {
- return Boolean(transition)
+ return Boolean(TRANSITION_END)
},
isElement(obj) {
QUnit.test('should remove element when clicking .close', function (assert) {
assert.expect(2)
+ var done = assert.async()
var alertHTML = '<div class="alert alert-danger fade show">' +
'<a class="close" href="#" data-dismiss="alert">×</a>' +
'<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>' +
assert.notEqual($('#qunit-fixture').find('.alert').length, 0, 'element added to dom')
- $alert.find('.close').trigger('click')
-
- assert.strictEqual($('#qunit-fixture').find('.alert').length, 0, 'element removed from dom')
+ $alert
+ .one('closed.bs.alert', function () {
+ assert.strictEqual($('#qunit-fixture').find('.alert').length, 0, 'element removed from dom')
+ done()
+ })
+ .find('.close')
+ .trigger('click')
})
QUnit.test('should not fire closed when close is prevented', function (assert) {
QUnit.test('should show a collapsed element', function (assert) {
assert.expect(2)
- var $el = $('<div class="collapse"/>').bootstrapCollapse('show')
+ var done = assert.async()
+ var $el = $('<div class="collapse"/>')
- assert.ok($el.hasClass('show'), 'has class "show"')
- assert.ok(!/height/i.test($el.attr('style')), 'has height reset')
+ $el.one('shown.bs.collapse', function () {
+ assert.ok($el.hasClass('show'), 'has class "show"')
+ assert.ok(!/height/i.test($el.attr('style')), 'has height reset')
+ done()
+ }).bootstrapCollapse('show')
})
QUnit.test('should show multiple collapsed elements', function (assert) {
QUnit.test('should get title and content from options', function (assert) {
assert.expect(4)
+ var done = assert.async()
var $popover = $('<a href="#">@fat</a>')
.appendTo('#qunit-fixture')
.bootstrapPopover({
}
})
- $popover.bootstrapPopover('show')
-
- assert.notEqual($('.popover').length, 0, 'popover was inserted')
- assert.strictEqual($('.popover .popover-header').text(), '@fat', 'title correctly inserted')
- assert.strictEqual($('.popover .popover-body').text(), 'loves writing tests (╯°□°)╯︵ ┻━┻', 'content correctly inserted')
-
- $popover.bootstrapPopover('hide')
-
- assert.strictEqual($('.popover').length, 0, 'popover was removed')
+ $popover
+ .one('shown.bs.popover', function () {
+ assert.notEqual($('.popover').length, 0, 'popover was inserted')
+ assert.strictEqual($('.popover .popover-header').text(), '@fat', 'title correctly inserted')
+ assert.strictEqual($('.popover .popover-body').text(), 'loves writing tests (╯°□°)╯︵ ┻━┻', 'content correctly inserted')
+ $popover.bootstrapPopover('hide')
+ })
+ .one('hidden.bs.popover', function () {
+ assert.strictEqual($('.popover').length, 0, 'popover was removed')
+ done()
+ })
+ .bootstrapPopover('show')
})
QUnit.test('should allow DOMElement title and content (html: true)', function (assert) {
QUnit.test('should not duplicate HTML object', function (assert) {
assert.expect(6)
+ var done = assert.async()
var $div = $('<div/>').html('loves writing tests (╯°□°)╯︵ ┻━┻')
var $popover = $('<a href="#">@fat</a>')
}
})
- $popover.bootstrapPopover('show')
- assert.notEqual($('.popover').length, 0, 'popover was inserted')
- assert.equal($('.popover .popover-body').html(), $div[0].outerHTML, 'content correctly inserted')
+ function popoverInserted() {
+ assert.notEqual($('.popover').length, 0, 'popover was inserted')
+ assert.equal($('.popover .popover-body').html(), $div[0].outerHTML, 'content correctly inserted')
+ }
- $popover.bootstrapPopover('hide')
- assert.strictEqual($('.popover').length, 0, 'popover was removed')
+ $popover
+ .one('shown.bs.popover', function () {
+ popoverInserted()
- $popover.bootstrapPopover('show')
- assert.notEqual($('.popover').length, 0, 'popover was inserted')
- assert.equal($('.popover .popover-body').html(), $div[0].outerHTML, 'content correctly inserted')
+ $popover.one('hidden.bs.popover', function () {
+ assert.strictEqual($('.popover').length, 0, 'popover was removed')
- $popover.bootstrapPopover('hide')
- assert.strictEqual($('.popover').length, 0, 'popover was removed')
+ $popover.one('shown.bs.popover', function () {
+ popoverInserted()
+
+ $popover.one('hidden.bs.popover', function () {
+ assert.strictEqual($('.popover').length, 0, 'popover was removed')
+ done()
+ }).bootstrapPopover('hide')
+ }).bootstrapPopover('show')
+ }).bootstrapPopover('hide')
+ })
+ .bootstrapPopover('show')
})
QUnit.test('should get title and content from attributes', function (assert) {
assert.expect(4)
+ var done = assert.async()
var $popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
.appendTo('#qunit-fixture')
.bootstrapPopover()
+ .one('shown.bs.popover', function () {
+ assert.notEqual($('.popover').length, 0, 'popover was inserted')
+ assert.strictEqual($('.popover .popover-header').text(), '@mdo', 'title correctly inserted')
+ assert.strictEqual($('.popover .popover-body').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted')
+ $popover.bootstrapPopover('hide')
+ })
+ .one('hidden.bs.popover', function () {
+ assert.strictEqual($('.popover').length, 0, 'popover was removed')
+ done()
+ })
.bootstrapPopover('show')
-
- assert.notEqual($('.popover').length, 0, 'popover was inserted')
- assert.strictEqual($('.popover .popover-header').text(), '@mdo', 'title correctly inserted')
- assert.strictEqual($('.popover .popover-body').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted')
-
- $popover.bootstrapPopover('hide')
- assert.strictEqual($('.popover').length, 0, 'popover was removed')
})
QUnit.test('should get title and content from attributes ignoring options passed via js', function (assert) {
assert.expect(4)
+ var done = assert.async()
var $popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
.appendTo('#qunit-fixture')
.bootstrapPopover({
title: 'ignored title option',
content: 'ignored content option'
})
+ .one('shown.bs.popover', function () {
+ assert.notEqual($('.popover').length, 0, 'popover was inserted')
+ assert.strictEqual($('.popover .popover-header').text(), '@mdo', 'title correctly inserted')
+ assert.strictEqual($('.popover .popover-body').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted')
+ $popover.bootstrapPopover('hide')
+ })
+ .one('hidden.bs.popover', function () {
+ assert.strictEqual($('.popover').length, 0, 'popover was removed')
+ done()
+ })
.bootstrapPopover('show')
-
- assert.notEqual($('.popover').length, 0, 'popover was inserted')
- assert.strictEqual($('.popover .popover-header').text(), '@mdo', 'title correctly inserted')
- assert.strictEqual($('.popover .popover-body').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted')
-
- $popover.bootstrapPopover('hide')
- assert.strictEqual($('.popover').length, 0, 'popover was removed')
})
QUnit.test('should respect custom template', function (assert) {
assert.expect(3)
+ var done = assert.async()
var $popover = $('<a href="#">@fat</a>')
.appendTo('#qunit-fixture')
.bootstrapPopover({
content: 'Test',
template: '<div class="popover foobar"><div class="arrow"></div><div class="inner"><h3 class="title"/><div class="content"><p/></div></div></div>'
})
-
- $popover.bootstrapPopover('show')
-
- assert.notEqual($('.popover').length, 0, 'popover was inserted')
- assert.ok($('.popover').hasClass('foobar'), 'custom class is present')
-
- $popover.bootstrapPopover('hide')
- assert.strictEqual($('.popover').length, 0, 'popover was removed')
+ .one('shown.bs.popover', function () {
+ assert.notEqual($('.popover').length, 0, 'popover was inserted')
+ assert.ok($('.popover').hasClass('foobar'), 'custom class is present')
+ $popover.bootstrapPopover('hide')
+ })
+ .one('hidden.bs.popover', function () {
+ assert.strictEqual($('.popover').length, 0, 'popover was removed')
+ done()
+ })
+ .bootstrapPopover('show')
})
QUnit.test('should destroy popover', function (assert) {
QUnit.test('should render popover element using delegated selector', function (assert) {
assert.expect(2)
+ var done = assert.async()
var $div = $('<div><a href="#" title="mdo" data-content="https://twitter.com/mdo">@mdo</a></div>')
.appendTo('#qunit-fixture')
.bootstrapPopover({
selector: 'a',
trigger: 'click'
})
+ .one('shown.bs.popover', function () {
+ assert.notEqual($('.popover').length, 0, 'popover was inserted')
+ $div.find('a').trigger('click')
+ })
+ .one('hidden.bs.popover', function () {
+ assert.strictEqual($('.popover').length, 0, 'popover was removed')
+ done()
+ })
$div.find('a').trigger('click')
- assert.notEqual($('.popover').length, 0, 'popover was inserted')
-
- $div.find('a').trigger('click')
- assert.strictEqual($('.popover').length, 0, 'popover was removed')
})
QUnit.test('should detach popover content rather than removing it so that event handlers are left intact', function (assert) {
html: true,
trigger: 'manual',
container: 'body',
+ animation: false,
content: function () {
return $content
}
$div
.one('shown.bs.popover', function () {
$('.content-with-handler .btn').trigger('click')
- $div.bootstrapPopover('dispose')
assert.ok(handlerCalled, 'content\'s event handler still present')
+ $div.bootstrapPopover('dispose')
done()
})
.bootstrapPopover('show')
QUnit.test('should remove aria-describedby from trigger on hide', function (assert) {
assert.expect(2)
+ var done = assert.async()
var $trigger = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.bootstrapTooltip()
.appendTo('#qunit-fixture')
- $trigger.bootstrapTooltip('show')
- assert.ok($trigger[0].hasAttribute('aria-describedby'), 'trigger has aria-describedby')
-
- $trigger.bootstrapTooltip('hide')
- assert.ok(!$trigger[0].hasAttribute('aria-describedby'), 'trigger does not have aria-describedby')
+ $trigger
+ .one('shown.bs.tooltip', function () {
+ assert.ok($trigger[0].hasAttribute('aria-describedby'), 'trigger has aria-describedby')
+ $trigger.bootstrapTooltip('hide')
+ })
+ .one('hidden.bs.tooltip', function () {
+ assert.ok(!$trigger[0].hasAttribute('aria-describedby'), 'trigger does not have aria-describedby')
+ done()
+ })
+ .bootstrapTooltip('show')
})
QUnit.test('should assign a unique id tooltip element', function (assert) {
QUnit.test('should place tooltips relative to placement option', function (assert) {
assert.expect(2)
+ var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip({
placement: 'bottom'
})
- $tooltip.bootstrapTooltip('show')
-
- assert
- .ok($('.tooltip')
- .is('.fade.bs-tooltip-bottom.show'), 'has correct classes applied')
-
- $tooltip.bootstrapTooltip('hide')
+ $tooltip
+ .one('shown.bs.tooltip', function () {
+ assert.ok($('.tooltip')
+ .is('.fade.bs-tooltip-bottom.show'), 'has correct classes applied')
- assert.strictEqual($tooltip.data('bs.tooltip').tip.parentNode, null, 'tooltip removed')
+ $tooltip.bootstrapTooltip('hide')
+ })
+ .one('hidden.bs.tooltip', function () {
+ assert.strictEqual($tooltip.data('bs.tooltip').tip.parentNode, null, 'tooltip removed')
+ done()
+ })
+ .bootstrapTooltip('show')
})
QUnit.test('should allow html entities', function (assert) {
assert.expect(2)
+ var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="<b>@fat</b>"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip({
html: true
})
- $tooltip.bootstrapTooltip('show')
- assert.notEqual($('.tooltip b').length, 0, 'b tag was inserted')
-
- $tooltip.bootstrapTooltip('hide')
- assert.strictEqual($tooltip.data('bs.tooltip').tip.parentNode, null, 'tooltip removed')
+ $tooltip
+ .one('shown.bs.tooltip', function () {
+ assert.notEqual($('.tooltip b').length, 0, 'b tag was inserted')
+ $tooltip.bootstrapTooltip('hide')
+ })
+ .one('hidden.bs.tooltip', function () {
+ assert.strictEqual($tooltip.data('bs.tooltip').tip.parentNode, null, 'tooltip removed')
+ done()
+ })
+ .bootstrapTooltip('show')
})
QUnit.test('should allow DOMElement title (html: false)', function (assert) {
assert.expect(3)
+ var done = assert.async()
var title = document.createTextNode('<3 writing tests')
var $tooltip = $('<a href="#" rel="tooltip"/>')
.appendTo('#qunit-fixture')
title: title
})
- $tooltip.bootstrapTooltip('show')
-
- assert.notEqual($('.tooltip').length, 0, 'tooltip inserted')
- assert.strictEqual($('.tooltip').text(), '<3 writing tests', 'title inserted')
- assert.ok(!$.contains($('.tooltip').get(0), title), 'title node copied, not moved')
+ $tooltip
+ .one('shown.bs.tooltip', function () {
+ assert.notEqual($('.tooltip').length, 0, 'tooltip inserted')
+ assert.strictEqual($('.tooltip').text(), '<3 writing tests', 'title inserted')
+ assert.ok(!$.contains($('.tooltip').get(0), title), 'title node copied, not moved')
+ done()
+ })
+ .bootstrapTooltip('show')
})
QUnit.test('should allow DOMElement title (html: true)', function (assert) {
assert.expect(3)
+ var done = assert.async()
var title = document.createTextNode('<3 writing tests')
var $tooltip = $('<a href="#" rel="tooltip"/>')
.appendTo('#qunit-fixture')
title: title
})
- $tooltip.bootstrapTooltip('show')
-
- assert.notEqual($('.tooltip').length, 0, 'tooltip inserted')
- assert.strictEqual($('.tooltip').text(), '<3 writing tests', 'title inserted')
- assert.ok($.contains($('.tooltip').get(0), title), 'title node moved, not copied')
+ $tooltip
+ .one('shown.bs.tooltip', function () {
+ assert.notEqual($('.tooltip').length, 0, 'tooltip inserted')
+ assert.strictEqual($('.tooltip').text(), '<3 writing tests', 'title inserted')
+ assert.ok($.contains($('.tooltip').get(0), title), 'title node moved, not copied')
+ done()
+ })
+ .bootstrapTooltip('show')
})
QUnit.test('should respect custom classes', function (assert) {
assert.expect(2)
+ var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip({
template: '<div class="tooltip some-class"><div class="tooltip-arrow"/><div class="tooltip-inner"/></div>'
})
- $tooltip.bootstrapTooltip('show')
- assert.ok($('.tooltip').hasClass('some-class'), 'custom class is present')
-
- $tooltip.bootstrapTooltip('hide')
- assert.strictEqual($tooltip.data('bs.tooltip').tip.parentNode, null, 'tooltip removed')
+ $tooltip
+ .one('shown.bs.tooltip', function () {
+ assert.ok($('.tooltip').hasClass('some-class'), 'custom class is present')
+ $tooltip.bootstrapTooltip('hide')
+ })
+ .one('hidden.bs.tooltip', function () {
+ assert.strictEqual($tooltip.data('bs.tooltip').tip.parentNode, null, 'tooltip removed')
+ done()
+ })
+ .bootstrapTooltip('show')
})
QUnit.test('should fire show event', function (assert) {
QUnit.test('should place tooltips inside body when container is body', function (assert) {
assert.expect(3)
+ var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip({
container: 'body'
})
- .bootstrapTooltip('show')
-
- assert.notEqual($('body > .tooltip').length, 0, 'tooltip is direct descendant of body')
- assert.strictEqual($('#qunit-fixture > .tooltip').length, 0, 'tooltip is not in parent')
- $tooltip.bootstrapTooltip('hide')
- assert.strictEqual($('body > .tooltip').length, 0, 'tooltip was removed from dom')
+ $tooltip
+ .one('shown.bs.tooltip', function () {
+ assert.notEqual($('body > .tooltip').length, 0, 'tooltip is direct descendant of body')
+ assert.strictEqual($('#qunit-fixture > .tooltip').length, 0, 'tooltip is not in parent')
+ $tooltip.bootstrapTooltip('hide')
+ })
+ .one('hidden.bs.tooltip', function () {
+ assert.strictEqual($('body > .tooltip').length, 0, 'tooltip was removed from dom')
+ done()
+ })
+ .bootstrapTooltip('show')
})
QUnit.test('should add position class before positioning so that position-specific styles are taken into account', function (assert) {
QUnit.test('should use title attribute for tooltip text', function (assert) {
assert.expect(2)
+ var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Simple tooltip"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip()
- $tooltip.bootstrapTooltip('show')
- assert.strictEqual($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title from title attribute is set')
-
- $tooltip.bootstrapTooltip('hide')
- assert.strictEqual($('.tooltip').length, 0, 'tooltip removed from dom')
+ $tooltip
+ .one('shown.bs.tooltip', function () {
+ assert.strictEqual($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title from title attribute is set')
+ $tooltip.bootstrapTooltip('hide')
+ })
+ .one('hidden.bs.tooltip', function () {
+ assert.strictEqual($('.tooltip').length, 0, 'tooltip removed from dom')
+ done()
+ })
+ .bootstrapTooltip('show')
})
QUnit.test('should prefer title attribute over title option', function (assert) {
assert.expect(2)
+ var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Simple tooltip"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip({
title: 'This is a tooltip with some content'
})
- $tooltip.bootstrapTooltip('show')
- assert.strictEqual($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title is set from title attribute while preferred over title option')
-
- $tooltip.bootstrapTooltip('hide')
- assert.strictEqual($('.tooltip').length, 0, 'tooltip removed from dom')
+ $tooltip
+ .one('shown.bs.tooltip', function () {
+ assert.strictEqual($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title is set from title attribute while preferred over title option')
+ $tooltip.bootstrapTooltip('hide')
+ })
+ .one('hidden.bs.tooltip', function () {
+ assert.strictEqual($('.tooltip').length, 0, 'tooltip removed from dom')
+ done()
+ })
+ .bootstrapTooltip('show')
})
QUnit.test('should use title option', function (assert) {
assert.expect(2)
+ var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip({
title: 'This is a tooltip with some content'
})
- $tooltip.bootstrapTooltip('show')
- assert.strictEqual($('.tooltip').children('.tooltip-inner').text(), 'This is a tooltip with some content', 'title from title option is set')
-
- $tooltip.bootstrapTooltip('hide')
- assert.strictEqual($('.tooltip').length, 0, 'tooltip removed from dom')
+ $tooltip
+ .one('shown.bs.tooltip', function () {
+ assert.strictEqual($('.tooltip').children('.tooltip-inner').text(), 'This is a tooltip with some content', 'title from title option is set')
+ $tooltip.bootstrapTooltip('hide')
+ })
+ .one('hidden.bs.tooltip', function () {
+ assert.strictEqual($('.tooltip').length, 0, 'tooltip removed from dom')
+ done()
+ })
+ .bootstrapTooltip('show')
})
QUnit.test('should not error when trying to show an top-placed tooltip that has been removed from the dom', function (assert) {
var done = assert.async()
var $el = $('<a href="#" rel="tooltip" title="7"/>')
.appendTo('#qunit-fixture')
- .bootstrapTooltip('show')
.on('shown.bs.tooltip', function () {
var tooltip = $el.data('bs.tooltip')
var $tooltip = $(tooltip.getTipElement())
id2 = Util.getUID('test')
assert.ok(id !== id2, id + ' !== ' + id2)
})
+
+ QUnit.test('Util.supportsTransitionEnd should return true', function (assert) {
+ assert.expect(1)
+ assert.ok(Util.supportsTransitionEnd())
+ })
})