mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-20 17:54:23 +01:00
JS unit tests: use modern QUnit assert object everywhere
This commit is contained in:
parent
1cbbeef47c
commit
7c19fee3f1
@ -3,8 +3,8 @@ $(function () {
|
||||
|
||||
module('affix plugin')
|
||||
|
||||
test('should be defined on jquery object', function () {
|
||||
ok($(document.body).affix, 'affix method is defined')
|
||||
test('should be defined on jquery object', function (assert) {
|
||||
assert.ok($(document.body).affix, 'affix method is defined')
|
||||
})
|
||||
|
||||
module('affix', {
|
||||
@ -18,21 +18,21 @@ $(function () {
|
||||
}
|
||||
})
|
||||
|
||||
test('should provide no conflict', function () {
|
||||
strictEqual($.fn.affix, undefined, 'affix was set back to undefined (org value)')
|
||||
test('should provide no conflict', function (assert) {
|
||||
assert.strictEqual($.fn.affix, undefined, 'affix was set back to undefined (org value)')
|
||||
})
|
||||
|
||||
test('should return jquery collection containing the element', function () {
|
||||
test('should return jquery collection containing the element', function (assert) {
|
||||
var $el = $('<div/>')
|
||||
var $affix = $el.bootstrapAffix()
|
||||
ok($affix instanceof $, 'returns jquery collection')
|
||||
strictEqual($affix[0], $el[0], 'collection contains element')
|
||||
assert.ok($affix instanceof $, 'returns jquery collection')
|
||||
assert.strictEqual($affix[0], $el[0], 'collection contains element')
|
||||
})
|
||||
|
||||
test('should exit early if element is not visible', function () {
|
||||
test('should exit early if element is not visible', function (assert) {
|
||||
var $affix = $('<div style="display: none"/>').bootstrapAffix()
|
||||
$affix.data('bs.affix').checkPosition()
|
||||
ok(!$affix.hasClass('affix'), 'affix class was not added')
|
||||
assert.ok(!$affix.hasClass('affix'), 'affix class was not added')
|
||||
})
|
||||
|
||||
test('should trigger affixed event after affix', function (assert) {
|
||||
@ -53,9 +53,9 @@ $(function () {
|
||||
|
||||
$('#affixTarget')
|
||||
.on('affix.bs.affix', function () {
|
||||
ok(true, 'affix event fired')
|
||||
assert.ok(true, 'affix event fired')
|
||||
}).on('affixed.bs.affix', function () {
|
||||
ok(true, 'affixed event fired')
|
||||
assert.ok(true, 'affixed event fired')
|
||||
$('#affixTarget, #affixAfter').remove()
|
||||
done()
|
||||
})
|
||||
@ -85,7 +85,7 @@ $(function () {
|
||||
offset: { top: 120, bottom: 0 }
|
||||
})
|
||||
.on('affixed-top.bs.affix', function () {
|
||||
ok($('#affixTopTarget').hasClass('affix-top'), 'affix-top class applied')
|
||||
assert.ok($('#affixTopTarget').hasClass('affix-top'), 'affix-top class applied')
|
||||
$('#padding-offset').remove()
|
||||
done()
|
||||
})
|
||||
|
@ -3,8 +3,8 @@ $(function () {
|
||||
|
||||
module('alert plugin')
|
||||
|
||||
test('should be defined on jquery object', function () {
|
||||
ok($(document.body).alert, 'alert method is defined')
|
||||
test('should be defined on jquery object', function (assert) {
|
||||
assert.ok($(document.body).alert, 'alert method is defined')
|
||||
})
|
||||
|
||||
module('alert', {
|
||||
@ -18,18 +18,18 @@ $(function () {
|
||||
}
|
||||
})
|
||||
|
||||
test('should provide no conflict', function () {
|
||||
strictEqual($.fn.alert, undefined, 'alert was set back to undefined (org value)')
|
||||
test('should provide no conflict', function (assert) {
|
||||
assert.strictEqual($.fn.alert, undefined, 'alert was set back to undefined (org value)')
|
||||
})
|
||||
|
||||
test('should return jquery collection containing the element', function () {
|
||||
test('should return jquery collection containing the element', function (assert) {
|
||||
var $el = $('<div/>')
|
||||
var $alert = $el.bootstrapAlert()
|
||||
ok($alert instanceof $, 'returns jquery collection')
|
||||
strictEqual($alert[0], $el[0], 'collection contains element')
|
||||
assert.ok($alert instanceof $, 'returns jquery collection')
|
||||
assert.strictEqual($alert[0], $el[0], 'collection contains element')
|
||||
})
|
||||
|
||||
test('should fade element out on clicking .close', function () {
|
||||
test('should fade element out on clicking .close', function (assert) {
|
||||
var alertHTML = '<div class="alert alert-danger fade in">'
|
||||
+ '<a class="close" href="#" data-dismiss="alert">×</a>'
|
||||
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
|
||||
@ -38,21 +38,21 @@ $(function () {
|
||||
|
||||
$alert.find('.close').click()
|
||||
|
||||
equal($alert.hasClass('in'), false, 'remove .in class on .close click')
|
||||
assert.equal($alert.hasClass('in'), false, 'remove .in class on .close click')
|
||||
})
|
||||
|
||||
test('should remove element when clicking .close', function () {
|
||||
test('should remove element when clicking .close', function (assert) {
|
||||
var alertHTML = '<div class="alert alert-danger fade in">'
|
||||
+ '<a class="close" href="#" data-dismiss="alert">×</a>'
|
||||
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
|
||||
+ '</div>'
|
||||
var $alert = $(alertHTML).appendTo('#qunit-fixture').bootstrapAlert()
|
||||
|
||||
notEqual($('#qunit-fixture').find('.alert').length, 0, 'element added to dom')
|
||||
assert.notEqual($('#qunit-fixture').find('.alert').length, 0, 'element added to dom')
|
||||
|
||||
$alert.find('.close').click()
|
||||
|
||||
equal($('#qunit-fixture').find('.alert').length, 0, 'element removed from dom')
|
||||
assert.equal($('#qunit-fixture').find('.alert').length, 0, 'element removed from dom')
|
||||
})
|
||||
|
||||
test('should not fire closed when close is prevented', function (assert) {
|
||||
@ -60,11 +60,11 @@ $(function () {
|
||||
$('<div class="alert"/>')
|
||||
.on('close.bs.alert', function (e) {
|
||||
e.preventDefault()
|
||||
ok(true, 'close event fired')
|
||||
assert.ok(true, 'close event fired')
|
||||
done()
|
||||
})
|
||||
.on('closed.bs.alert', function () {
|
||||
ok(false, 'closed event fired')
|
||||
assert.ok(false, 'closed event fired')
|
||||
})
|
||||
.bootstrapAlert('close')
|
||||
})
|
||||
|
@ -3,8 +3,8 @@ $(function () {
|
||||
|
||||
module('button plugin')
|
||||
|
||||
test('should be defined on jquery object', function () {
|
||||
ok($(document.body).button, 'button method is defined')
|
||||
test('should be defined on jquery object', function (assert) {
|
||||
assert.ok($(document.body).button, 'button method is defined')
|
||||
})
|
||||
|
||||
module('button', {
|
||||
@ -18,46 +18,46 @@ $(function () {
|
||||
}
|
||||
})
|
||||
|
||||
test('should provide no conflict', function () {
|
||||
strictEqual($.fn.button, undefined, 'button was set back to undefined (org value)')
|
||||
test('should provide no conflict', function (assert) {
|
||||
assert.strictEqual($.fn.button, undefined, 'button was set back to undefined (org value)')
|
||||
})
|
||||
|
||||
test('should return jquery collection containing the element', function () {
|
||||
test('should return jquery collection containing the element', function (assert) {
|
||||
var $el = $('<div/>')
|
||||
var $button = $el.bootstrapButton()
|
||||
ok($button instanceof $, 'returns jquery collection')
|
||||
strictEqual($button[0], $el[0], 'collection contains element')
|
||||
assert.ok($button instanceof $, 'returns jquery collection')
|
||||
assert.strictEqual($button[0], $el[0], 'collection contains element')
|
||||
})
|
||||
|
||||
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')
|
||||
assert.equal($btn.html(), 'mdo', 'btn text equals mdo')
|
||||
$btn.bootstrapButton('loading')
|
||||
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')
|
||||
assert.equal($btn.html(), 'fat', 'btn text equals fat')
|
||||
assert.ok($btn[0].hasAttribute('disabled'), 'btn is disabled')
|
||||
assert.ok($btn.hasClass('disabled'), 'btn has disabled class')
|
||||
done()
|
||||
}, 0)
|
||||
})
|
||||
|
||||
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')
|
||||
assert.equal($btn.html(), 'mdo', 'btn text equals mdo')
|
||||
$btn.bootstrapButton('loading')
|
||||
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')
|
||||
assert.equal($btn.html(), 'fat', 'btn text equals fat')
|
||||
assert.ok($btn[0].hasAttribute('disabled'), 'btn is disabled')
|
||||
assert.ok($btn.hasClass('disabled'), 'btn has disabled class')
|
||||
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')
|
||||
assert.equal($btn.html(), 'mdo', 'btn text equals mdo')
|
||||
assert.ok(!$btn[0].hasAttribute('disabled'), 'btn is not disabled')
|
||||
assert.ok(!$btn.hasClass('disabled'), 'btn does not have disabled class')
|
||||
doneTwo()
|
||||
}, 0)
|
||||
}, 0)
|
||||
@ -65,74 +65,74 @@ $(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 ""')
|
||||
assert.equal($btn.html(), '', 'btn text equals ""')
|
||||
$btn.bootstrapButton('loading')
|
||||
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')
|
||||
assert.equal($btn.html(), 'fat', 'btn text equals fat')
|
||||
assert.ok($btn[0].hasAttribute('disabled'), 'btn is disabled')
|
||||
assert.ok($btn.hasClass('disabled'), 'btn has disabled class')
|
||||
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')
|
||||
assert.equal($btn.html(), '', 'btn text equals ""')
|
||||
assert.ok(!$btn[0].hasAttribute('disabled'), 'btn is not disabled')
|
||||
assert.ok(!$btn.hasClass('disabled'), 'btn does not have disabled class')
|
||||
doneTwo()
|
||||
}, 0)
|
||||
}, 0)
|
||||
})
|
||||
|
||||
test('should toggle active', function () {
|
||||
test('should toggle active', function (assert) {
|
||||
var $btn = $('<button class="btn" data-toggle="button">mdo</button>')
|
||||
ok(!$btn.hasClass('active'), 'btn does not have active class')
|
||||
assert.ok(!$btn.hasClass('active'), 'btn does not have active class')
|
||||
$btn.bootstrapButton('toggle')
|
||||
ok($btn.hasClass('active'), 'btn has class active')
|
||||
assert.ok($btn.hasClass('active'), 'btn has class active')
|
||||
})
|
||||
|
||||
test('should toggle active when btn children are clicked', function () {
|
||||
test('should toggle active when btn children are clicked', function (assert) {
|
||||
var $btn = $('<button class="btn" data-toggle="button">mdo</button>')
|
||||
var $inner = $('<i/>')
|
||||
$btn
|
||||
.append($inner)
|
||||
.appendTo('#qunit-fixture')
|
||||
ok(!$btn.hasClass('active'), 'btn does not have active class')
|
||||
assert.ok(!$btn.hasClass('active'), 'btn does not have active class')
|
||||
$inner.click()
|
||||
ok($btn.hasClass('active'), 'btn has class active')
|
||||
assert.ok($btn.hasClass('active'), 'btn has class active')
|
||||
})
|
||||
|
||||
test('should toggle aria-pressed', function () {
|
||||
test('should toggle aria-pressed', function (assert) {
|
||||
var $btn = $('<button class="btn" data-toggle="button" aria-pressed="false">redux</button>')
|
||||
equal($btn.attr('aria-pressed'), 'false', 'btn aria-pressed state is false')
|
||||
assert.equal($btn.attr('aria-pressed'), 'false', 'btn aria-pressed state is false')
|
||||
$btn.bootstrapButton('toggle')
|
||||
equal($btn.attr('aria-pressed'), 'true', 'btn aria-pressed state is true')
|
||||
assert.equal($btn.attr('aria-pressed'), 'true', 'btn aria-pressed state is true')
|
||||
})
|
||||
|
||||
test('should toggle aria-pressed when btn children are clicked', function () {
|
||||
test('should toggle aria-pressed when btn children are clicked', function (assert) {
|
||||
var $btn = $('<button class="btn" data-toggle="button" aria-pressed="false">redux</button>')
|
||||
var $inner = $('<i/>')
|
||||
$btn
|
||||
.append($inner)
|
||||
.appendTo('#qunit-fixture')
|
||||
equal($btn.attr('aria-pressed'), 'false', 'btn aria-pressed state is false')
|
||||
assert.equal($btn.attr('aria-pressed'), 'false', 'btn aria-pressed state is false')
|
||||
$inner.click()
|
||||
equal($btn.attr('aria-pressed'), 'true', 'btn aria-pressed state is true')
|
||||
assert.equal($btn.attr('aria-pressed'), 'true', 'btn aria-pressed state is true')
|
||||
})
|
||||
|
||||
test('should toggle active when btn children are clicked within btn-group', function () {
|
||||
test('should toggle active when btn children are clicked within btn-group', function (assert) {
|
||||
var $btngroup = $('<div class="btn-group" data-toggle="buttons"/>')
|
||||
var $btn = $('<button class="btn">fat</button>')
|
||||
var $inner = $('<i/>')
|
||||
$btngroup
|
||||
.append($btn.append($inner))
|
||||
.appendTo('#qunit-fixture')
|
||||
ok(!$btn.hasClass('active'), 'btn does not have active class')
|
||||
assert.ok(!$btn.hasClass('active'), 'btn does not have active class')
|
||||
$inner.click()
|
||||
ok($btn.hasClass('active'), 'btn has class active')
|
||||
assert.ok($btn.hasClass('active'), 'btn has class active')
|
||||
})
|
||||
|
||||
test('should check for closest matching toggle', function () {
|
||||
test('should check for closest matching toggle', function (assert) {
|
||||
var groupHTML = '<div class="btn-group" data-toggle="buttons">'
|
||||
+ '<label class="btn btn-primary active">'
|
||||
+ '<input type="radio" name="options" id="option1" checked="true"> Option 1'
|
||||
@ -149,21 +149,21 @@ $(function () {
|
||||
var $btn1 = $group.children().eq(0)
|
||||
var $btn2 = $group.children().eq(1)
|
||||
|
||||
ok($btn1.hasClass('active'), 'btn1 has active class')
|
||||
ok($btn1.find('input').prop('checked'), 'btn1 is checked')
|
||||
ok(!$btn2.hasClass('active'), 'btn2 does not have active class')
|
||||
ok(!$btn2.find('input').prop('checked'), 'btn2 is not checked')
|
||||
assert.ok($btn1.hasClass('active'), 'btn1 has active class')
|
||||
assert.ok($btn1.find('input').prop('checked'), 'btn1 is checked')
|
||||
assert.ok(!$btn2.hasClass('active'), 'btn2 does not have active class')
|
||||
assert.ok(!$btn2.find('input').prop('checked'), 'btn2 is not checked')
|
||||
$btn2.find('input').click()
|
||||
ok(!$btn1.hasClass('active'), 'btn1 does not have active class')
|
||||
ok(!$btn1.find('input').prop('checked'), 'btn1 is checked')
|
||||
ok($btn2.hasClass('active'), 'btn2 has active class')
|
||||
ok($btn2.find('input').prop('checked'), 'btn2 is checked')
|
||||
assert.ok(!$btn1.hasClass('active'), 'btn1 does not have active class')
|
||||
assert.ok(!$btn1.find('input').prop('checked'), 'btn1 is checked')
|
||||
assert.ok($btn2.hasClass('active'), 'btn2 has active class')
|
||||
assert.ok($btn2.find('input').prop('checked'), 'btn2 is checked')
|
||||
|
||||
$btn2.find('input').click() // clicking an already checked radio should not un-check it
|
||||
ok(!$btn1.hasClass('active'), 'btn1 does not have active class')
|
||||
ok(!$btn1.find('input').prop('checked'), 'btn1 is checked')
|
||||
ok($btn2.hasClass('active'), 'btn2 has active class')
|
||||
ok($btn2.find('input').prop('checked'), 'btn2 is checked')
|
||||
assert.ok(!$btn1.hasClass('active'), 'btn1 does not have active class')
|
||||
assert.ok(!$btn1.find('input').prop('checked'), 'btn1 is checked')
|
||||
assert.ok($btn2.hasClass('active'), 'btn2 has active class')
|
||||
assert.ok($btn2.find('input').prop('checked'), 'btn2 is checked')
|
||||
})
|
||||
|
||||
})
|
||||
|
@ -3,8 +3,8 @@ $(function () {
|
||||
|
||||
module('carousel plugin')
|
||||
|
||||
test('should be defined on jQuery object', function () {
|
||||
ok($(document.body).carousel, 'carousel method is defined')
|
||||
test('should be defined on jQuery object', function (assert) {
|
||||
assert.ok($(document.body).carousel, 'carousel method is defined')
|
||||
})
|
||||
|
||||
module('carousel', {
|
||||
@ -18,15 +18,15 @@ $(function () {
|
||||
}
|
||||
})
|
||||
|
||||
test('should provide no conflict', function () {
|
||||
strictEqual($.fn.carousel, undefined, 'carousel was set back to undefined (orig value)')
|
||||
test('should provide no conflict', function (assert) {
|
||||
assert.strictEqual($.fn.carousel, undefined, 'carousel was set back to undefined (orig value)')
|
||||
})
|
||||
|
||||
test('should return jquery collection containing the element', function () {
|
||||
test('should return jquery collection containing the element', function (assert) {
|
||||
var $el = $('<div/>')
|
||||
var $carousel = $el.bootstrapCarousel()
|
||||
ok($carousel instanceof $, 'returns jquery collection')
|
||||
strictEqual($carousel[0], $el[0], 'collection contains element')
|
||||
assert.ok($carousel instanceof $, 'returns jquery collection')
|
||||
assert.strictEqual($carousel[0], $el[0], 'collection contains element')
|
||||
})
|
||||
|
||||
test('should not fire slid when slide is prevented', function (assert) {
|
||||
@ -34,11 +34,11 @@ $(function () {
|
||||
$('<div class="carousel"/>')
|
||||
.on('slide.bs.carousel', function (e) {
|
||||
e.preventDefault()
|
||||
ok(true, 'slide event fired')
|
||||
assert.ok(true, 'slide event fired')
|
||||
done()
|
||||
})
|
||||
.on('slid.bs.carousel', function () {
|
||||
ok(false, 'slid event fired')
|
||||
assert.ok(false, 'slid event fired')
|
||||
})
|
||||
.bootstrapCarousel('next')
|
||||
})
|
||||
@ -71,17 +71,17 @@ $(function () {
|
||||
.one('slide.bs.carousel', function (e) {
|
||||
e.preventDefault()
|
||||
setTimeout(function () {
|
||||
ok($carousel.find('.item:eq(0)').is('.active'), 'first item still active')
|
||||
ok($carousel.find('.carousel-indicators li:eq(0)').is('.active'), 'first indicator still active')
|
||||
assert.ok($carousel.find('.item:eq(0)').is('.active'), 'first item still active')
|
||||
assert.ok($carousel.find('.carousel-indicators li:eq(0)').is('.active'), 'first indicator still active')
|
||||
$carousel.bootstrapCarousel('next')
|
||||
}, 0)
|
||||
})
|
||||
.one('slid.bs.carousel', function () {
|
||||
setTimeout(function () {
|
||||
ok(!$carousel.find('.item:eq(0)').is('.active'), 'first item still active')
|
||||
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')
|
||||
assert.ok(!$carousel.find('.item:eq(0)').is('.active'), 'first item still active')
|
||||
assert.ok(!$carousel.find('.carousel-indicators li:eq(0)').is('.active'), 'first indicator still active')
|
||||
assert.ok($carousel.find('.item:eq(1)').is('.active'), 'second item active')
|
||||
assert.ok($carousel.find('.carousel-indicators li:eq(1)').is('.active'), 'second indicator active')
|
||||
done()
|
||||
}, 0)
|
||||
})
|
||||
@ -128,13 +128,13 @@ $(function () {
|
||||
|
||||
$carousel
|
||||
.one('slide.bs.carousel', function (e) {
|
||||
ok(e.direction, 'direction present on next')
|
||||
strictEqual(e.direction, 'left', 'direction is left on next')
|
||||
assert.ok(e.direction, 'direction present on next')
|
||||
assert.strictEqual(e.direction, 'left', 'direction is left on next')
|
||||
|
||||
$carousel
|
||||
.one('slide.bs.carousel', function (e) {
|
||||
ok(e.direction, 'direction present on prev')
|
||||
strictEqual(e.direction, 'right', 'direction is right on prev')
|
||||
assert.ok(e.direction, 'direction present on prev')
|
||||
assert.strictEqual(e.direction, 'right', 'direction is right on prev')
|
||||
done()
|
||||
})
|
||||
.bootstrapCarousel('prev')
|
||||
@ -182,13 +182,13 @@ $(function () {
|
||||
|
||||
$carousel
|
||||
.one('slid.bs.carousel', function (e) {
|
||||
ok(e.direction, 'direction present on next')
|
||||
strictEqual(e.direction, 'left', 'direction is left on next')
|
||||
assert.ok(e.direction, 'direction present on next')
|
||||
assert.strictEqual(e.direction, 'left', 'direction is left on next')
|
||||
|
||||
$carousel
|
||||
.one('slid.bs.carousel', function (e) {
|
||||
ok(e.direction, 'direction present on prev')
|
||||
strictEqual(e.direction, 'right', 'direction is right on prev')
|
||||
assert.ok(e.direction, 'direction present on prev')
|
||||
assert.strictEqual(e.direction, 'right', 'direction is right on prev')
|
||||
done()
|
||||
})
|
||||
.bootstrapCarousel('prev')
|
||||
@ -235,8 +235,8 @@ $(function () {
|
||||
|
||||
$(template)
|
||||
.on('slide.bs.carousel', function (e) {
|
||||
ok(e.relatedTarget, 'relatedTarget present')
|
||||
ok($(e.relatedTarget).hasClass('item'), 'relatedTarget has class "item"')
|
||||
assert.ok(e.relatedTarget, 'relatedTarget present')
|
||||
assert.ok($(e.relatedTarget).hasClass('item'), 'relatedTarget has class "item"')
|
||||
done()
|
||||
})
|
||||
.bootstrapCarousel('next')
|
||||
@ -281,14 +281,14 @@ $(function () {
|
||||
|
||||
$(template)
|
||||
.on('slid.bs.carousel', function (e) {
|
||||
ok(e.relatedTarget, 'relatedTarget present')
|
||||
ok($(e.relatedTarget).hasClass('item'), 'relatedTarget has class "item"')
|
||||
assert.ok(e.relatedTarget, 'relatedTarget present')
|
||||
assert.ok($(e.relatedTarget).hasClass('item'), 'relatedTarget has class "item"')
|
||||
done()
|
||||
})
|
||||
.bootstrapCarousel('next')
|
||||
})
|
||||
|
||||
test('should set interval from data attribute', function () {
|
||||
test('should set interval from data attribute', function (assert) {
|
||||
var templateHTML = '<div id="myCarousel" class="carousel slide">'
|
||||
+ '<div class="carousel-inner">'
|
||||
+ '<div class="item active">'
|
||||
@ -327,29 +327,29 @@ $(function () {
|
||||
|
||||
$carousel.appendTo('body')
|
||||
$('[data-slide]').first().click()
|
||||
equal($carousel.data('bs.carousel').options.interval, 1814)
|
||||
assert.equal($carousel.data('bs.carousel').options.interval, 1814)
|
||||
$carousel.remove()
|
||||
|
||||
$carousel.appendTo('body').attr('data-modal', 'foobar')
|
||||
$('[data-slide]').first().click()
|
||||
equal($carousel.data('bs.carousel').options.interval, 1814, 'even if there is an data-modal attribute set')
|
||||
assert.equal($carousel.data('bs.carousel').options.interval, 1814, 'even if there is an data-modal attribute set')
|
||||
$carousel.remove()
|
||||
|
||||
$carousel.appendTo('body')
|
||||
$('[data-slide]').first().click()
|
||||
$carousel.attr('data-interval', 1860)
|
||||
$('[data-slide]').first().click()
|
||||
equal($carousel.data('bs.carousel').options.interval, 1814, 'attributes should be read only on initialization')
|
||||
assert.equal($carousel.data('bs.carousel').options.interval, 1814, 'attributes should be read only on initialization')
|
||||
$carousel.remove()
|
||||
|
||||
$carousel.attr('data-interval', false)
|
||||
$carousel.appendTo('body')
|
||||
$carousel.bootstrapCarousel(1)
|
||||
strictEqual($carousel.data('bs.carousel').options.interval, false, 'data attribute has higher priority than default options')
|
||||
assert.strictEqual($carousel.data('bs.carousel').options.interval, false, 'data attribute has higher priority than default options')
|
||||
$carousel.remove()
|
||||
})
|
||||
|
||||
test('should skip over non-items when using item indices', function () {
|
||||
test('should skip over non-items when using item indices', function (assert) {
|
||||
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="1814">'
|
||||
+ '<div class="carousel-inner">'
|
||||
+ '<div class="item active">'
|
||||
@ -367,14 +367,14 @@ $(function () {
|
||||
|
||||
$template.bootstrapCarousel()
|
||||
|
||||
strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active')
|
||||
assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active')
|
||||
|
||||
$template.bootstrapCarousel(1)
|
||||
|
||||
strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active')
|
||||
assert.strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active')
|
||||
})
|
||||
|
||||
test('should skip over non-items when using next/prev methods', function () {
|
||||
test('should skip over non-items when using next/prev methods', function (assert) {
|
||||
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="1814">'
|
||||
+ '<div class="carousel-inner">'
|
||||
+ '<div class="item active">'
|
||||
@ -392,14 +392,14 @@ $(function () {
|
||||
|
||||
$template.bootstrapCarousel()
|
||||
|
||||
strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active')
|
||||
assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active')
|
||||
|
||||
$template.bootstrapCarousel('next')
|
||||
|
||||
strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active')
|
||||
assert.strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active')
|
||||
})
|
||||
|
||||
test('should go to previous item if left arrow key is pressed', function () {
|
||||
test('should go to previous item if left arrow key is pressed', function (assert) {
|
||||
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">'
|
||||
+ '<div class="carousel-inner">'
|
||||
+ '<div id="first" class="item">'
|
||||
@ -417,14 +417,14 @@ $(function () {
|
||||
|
||||
$template.bootstrapCarousel()
|
||||
|
||||
strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active')
|
||||
assert.strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active')
|
||||
|
||||
$template.trigger($.Event('keydown', { which: 37 }))
|
||||
|
||||
strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active')
|
||||
assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active')
|
||||
})
|
||||
|
||||
test('should go to next item if right arrow key is pressed', function () {
|
||||
test('should go to next item if right arrow key is pressed', function (assert) {
|
||||
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">'
|
||||
+ '<div class="carousel-inner">'
|
||||
+ '<div id="first" class="item active">'
|
||||
@ -442,14 +442,14 @@ $(function () {
|
||||
|
||||
$template.bootstrapCarousel()
|
||||
|
||||
strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active')
|
||||
assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active')
|
||||
|
||||
$template.trigger($.Event('keydown', { which: 39 }))
|
||||
|
||||
strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active')
|
||||
assert.strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active')
|
||||
})
|
||||
|
||||
test('should support disabling the keyboard navigation', function () {
|
||||
test('should support disabling the keyboard navigation', function (assert) {
|
||||
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false" data-keyboard="false">'
|
||||
+ '<div class="carousel-inner">'
|
||||
+ '<div id="first" class="item active">'
|
||||
@ -467,18 +467,18 @@ $(function () {
|
||||
|
||||
$template.bootstrapCarousel()
|
||||
|
||||
strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active')
|
||||
assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active')
|
||||
|
||||
$template.trigger($.Event('keydown', { which: 39 }))
|
||||
|
||||
strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after right arrow press')
|
||||
assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after right arrow press')
|
||||
|
||||
$template.trigger($.Event('keydown', { which: 37 }))
|
||||
|
||||
strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after left arrow press')
|
||||
assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after left arrow press')
|
||||
})
|
||||
|
||||
test('should ignore keyboard events within <input>s and <textarea>s', function () {
|
||||
test('should ignore keyboard events within <input>s and <textarea>s', function (assert) {
|
||||
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">'
|
||||
+ '<div class="carousel-inner">'
|
||||
+ '<div id="first" class="item active">'
|
||||
@ -498,29 +498,29 @@ $(function () {
|
||||
var $input = $template.find('#in-put')
|
||||
var $textarea = $template.find('#text-area')
|
||||
|
||||
strictEqual($input.length, 1, 'found <input>')
|
||||
strictEqual($textarea.length, 1, 'found <textarea>')
|
||||
assert.strictEqual($input.length, 1, 'found <input>')
|
||||
assert.strictEqual($textarea.length, 1, 'found <textarea>')
|
||||
|
||||
$template.bootstrapCarousel()
|
||||
|
||||
strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active')
|
||||
assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active')
|
||||
|
||||
|
||||
$input.trigger($.Event('keydown', { which: 39 }))
|
||||
strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after right arrow press in <input>')
|
||||
assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after right arrow press in <input>')
|
||||
|
||||
$input.trigger($.Event('keydown', { which: 37 }))
|
||||
strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after left arrow press in <input>')
|
||||
assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after left arrow press in <input>')
|
||||
|
||||
|
||||
$textarea.trigger($.Event('keydown', { which: 39 }))
|
||||
strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after right arrow press in <textarea>')
|
||||
assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after right arrow press in <textarea>')
|
||||
|
||||
$textarea.trigger($.Event('keydown', { which: 37 }))
|
||||
strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after left arrow press in <textarea>')
|
||||
assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after left arrow press in <textarea>')
|
||||
})
|
||||
|
||||
test('should only add mouseenter and mouseleave listeners when not on mobile', function () {
|
||||
test('should only add mouseenter and mouseleave listeners when not on mobile', function (assert) {
|
||||
var isMobile = 'ontouchstart' in document.documentElement
|
||||
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false" data-pause="hover">'
|
||||
+ '<div class="carousel-inner">'
|
||||
@ -538,7 +538,7 @@ $(function () {
|
||||
var $template = $(templateHTML).bootstrapCarousel()
|
||||
|
||||
$.each(['mouseover', 'mouseout'], function (i, type) {
|
||||
strictEqual(type in $._data($template[0], 'events'), !isMobile, 'does' + (isMobile ? ' not' : '') + ' listen for ' + type + ' events')
|
||||
assert.strictEqual(type in $._data($template[0], 'events'), !isMobile, 'does' + (isMobile ? ' not' : '') + ' listen for ' + type + ' events')
|
||||
})
|
||||
})
|
||||
|
||||
@ -570,13 +570,13 @@ $(function () {
|
||||
|
||||
$carousel
|
||||
.one('slid.bs.carousel', function () {
|
||||
strictEqual(getActiveId(), 'two', 'carousel slid from 1st to 2nd slide')
|
||||
assert.strictEqual(getActiveId(), 'two', 'carousel slid from 1st to 2nd slide')
|
||||
$carousel
|
||||
.one('slid.bs.carousel', function () {
|
||||
strictEqual(getActiveId(), 'three', 'carousel slid from 2nd to 3rd slide')
|
||||
assert.strictEqual(getActiveId(), 'three', 'carousel slid from 2nd to 3rd slide')
|
||||
$carousel
|
||||
.one('slid.bs.carousel', function () {
|
||||
strictEqual(getActiveId(), 'one', 'carousel wrapped around and slid from 3rd to 1st slide')
|
||||
assert.strictEqual(getActiveId(), 'one', 'carousel wrapped around and slid from 3rd to 1st slide')
|
||||
done()
|
||||
})
|
||||
.bootstrapCarousel('next')
|
||||
@ -613,7 +613,7 @@ $(function () {
|
||||
|
||||
$carousel
|
||||
.on('slid.bs.carousel', function () {
|
||||
strictEqual($carousel.find('.item.active').attr('id'), 'three', 'carousel wrapped around and slid from 1st to 3rd slide')
|
||||
assert.strictEqual($carousel.find('.item.active').attr('id'), 'three', 'carousel wrapped around and slid from 1st to 3rd slide')
|
||||
done()
|
||||
})
|
||||
.bootstrapCarousel('prev')
|
||||
@ -647,16 +647,16 @@ $(function () {
|
||||
|
||||
$carousel
|
||||
.one('slid.bs.carousel', function () {
|
||||
strictEqual(getActiveId(), 'two', 'carousel slid from 1st to 2nd slide')
|
||||
assert.strictEqual(getActiveId(), 'two', 'carousel slid from 1st to 2nd slide')
|
||||
$carousel
|
||||
.one('slid.bs.carousel', function () {
|
||||
strictEqual(getActiveId(), 'three', 'carousel slid from 2nd to 3rd slide')
|
||||
assert.strictEqual(getActiveId(), 'three', 'carousel slid from 2nd to 3rd slide')
|
||||
$carousel
|
||||
.one('slid.bs.carousel', function () {
|
||||
ok(false, 'carousel slid when it should not have slid')
|
||||
assert.ok(false, 'carousel slid when it should not have slid')
|
||||
})
|
||||
.bootstrapCarousel('next')
|
||||
strictEqual(getActiveId(), 'three', 'carousel did not wrap around and stayed on 3rd slide')
|
||||
assert.strictEqual(getActiveId(), 'three', 'carousel did not wrap around and stayed on 3rd slide')
|
||||
done()
|
||||
})
|
||||
.bootstrapCarousel('next')
|
||||
@ -664,7 +664,7 @@ $(function () {
|
||||
.bootstrapCarousel('next')
|
||||
})
|
||||
|
||||
test('should stay at the start when the prev method is called and wrap is false', function () {
|
||||
test('should stay at the start when the prev 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"/>'
|
||||
@ -689,9 +689,9 @@ $(function () {
|
||||
|
||||
$carousel
|
||||
.on('slid.bs.carousel', function () {
|
||||
ok(false, 'carousel slid when it should not have slid')
|
||||
assert.ok(false, 'carousel slid when it should not have slid')
|
||||
})
|
||||
.bootstrapCarousel('prev')
|
||||
strictEqual($carousel.find('.item.active').attr('id'), 'one', 'carousel did not wrap around and stayed on 1st slide')
|
||||
assert.strictEqual($carousel.find('.item.active').attr('id'), 'one', 'carousel did not wrap around and stayed on 1st slide')
|
||||
})
|
||||
})
|
||||
|
@ -3,8 +3,8 @@ $(function () {
|
||||
|
||||
module('collapse plugin')
|
||||
|
||||
test('should be defined on jquery object', function () {
|
||||
ok($(document.body).collapse, 'collapse method is defined')
|
||||
test('should be defined on jquery object', function (assert) {
|
||||
assert.ok($(document.body).collapse, 'collapse method is defined')
|
||||
})
|
||||
|
||||
module('collapse', {
|
||||
@ -18,29 +18,29 @@ $(function () {
|
||||
}
|
||||
})
|
||||
|
||||
test('should provide no conflict', function () {
|
||||
strictEqual($.fn.collapse, undefined, 'collapse was set back to undefined (org value)')
|
||||
test('should provide no conflict', function (assert) {
|
||||
assert.strictEqual($.fn.collapse, undefined, 'collapse was set back to undefined (org value)')
|
||||
})
|
||||
|
||||
test('should return jquery collection containing the element', function () {
|
||||
test('should return jquery collection containing the element', function (assert) {
|
||||
var $el = $('<div/>')
|
||||
var $collapse = $el.bootstrapCollapse()
|
||||
ok($collapse instanceof $, 'returns jquery collection')
|
||||
strictEqual($collapse[0], $el[0], 'collection contains element')
|
||||
assert.ok($collapse instanceof $, 'returns jquery collection')
|
||||
assert.strictEqual($collapse[0], $el[0], 'collection contains element')
|
||||
})
|
||||
|
||||
test('should show a collapsed element', function () {
|
||||
test('should show a collapsed element', function (assert) {
|
||||
var $el = $('<div class="collapse"/>').bootstrapCollapse('show')
|
||||
|
||||
ok($el.hasClass('in'), 'has class "in"')
|
||||
ok(!/height/i.test($el.attr('style')), 'has height reset')
|
||||
assert.ok($el.hasClass('in'), 'has class "in"')
|
||||
assert.ok(!/height/i.test($el.attr('style')), 'has height reset')
|
||||
})
|
||||
|
||||
test('should hide a collapsed element', function () {
|
||||
test('should hide a collapsed element', function (assert) {
|
||||
var $el = $('<div class="collapse"/>').bootstrapCollapse('hide')
|
||||
|
||||
ok(!$el.hasClass('in'), 'does not have class "in"')
|
||||
ok(/height/i.test($el.attr('style')), 'has height set')
|
||||
assert.ok(!$el.hasClass('in'), 'does not have class "in"')
|
||||
assert.ok(/height/i.test($el.attr('style')), 'has height set')
|
||||
})
|
||||
|
||||
test('should not fire shown when show is prevented', function (assert) {
|
||||
@ -49,11 +49,11 @@ $(function () {
|
||||
$('<div class="collapse"/>')
|
||||
.on('show.bs.collapse', function (e) {
|
||||
e.preventDefault()
|
||||
ok(true, 'show event fired')
|
||||
assert.ok(true, 'show event fired')
|
||||
done()
|
||||
})
|
||||
.on('shown.bs.collapse', function () {
|
||||
ok(false, 'shown event fired')
|
||||
assert.ok(false, 'shown event fired')
|
||||
})
|
||||
.bootstrapCollapse('show')
|
||||
})
|
||||
@ -63,10 +63,10 @@ $(function () {
|
||||
|
||||
$('<div class="collapse" style="height: 0px"/>')
|
||||
.on('show.bs.collapse', function () {
|
||||
equal(this.style.height, '0px', 'height is 0px')
|
||||
assert.equal(this.style.height, '0px', 'height is 0px')
|
||||
})
|
||||
.on('shown.bs.collapse', function () {
|
||||
strictEqual(this.style.height, '', 'height is auto')
|
||||
assert.strictEqual(this.style.height, '', 'height is auto')
|
||||
done()
|
||||
})
|
||||
.bootstrapCollapse('show')
|
||||
@ -80,7 +80,7 @@ $(function () {
|
||||
$('<div id="test1"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.on('shown.bs.collapse', function () {
|
||||
ok(!$target.hasClass('collapsed'))
|
||||
assert.ok(!$target.hasClass('collapsed'))
|
||||
done()
|
||||
})
|
||||
|
||||
@ -95,7 +95,7 @@ $(function () {
|
||||
$('<div id="test1" class="in"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.on('hidden.bs.collapse', function () {
|
||||
ok($target.hasClass('collapsed'))
|
||||
assert.ok($target.hasClass('collapsed'))
|
||||
done()
|
||||
})
|
||||
|
||||
@ -105,12 +105,12 @@ $(function () {
|
||||
test('should not close a collapse when initialized with "show" if already shown', function (assert) {
|
||||
var done = assert.async()
|
||||
|
||||
expect(0)
|
||||
assert.expect(0)
|
||||
|
||||
var $test = $('<div id="test1" class="in"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.on('hide.bs.collapse', function () {
|
||||
ok(false)
|
||||
assert.ok(false)
|
||||
})
|
||||
|
||||
$test.bootstrapCollapse('show')
|
||||
@ -121,12 +121,12 @@ $(function () {
|
||||
test('should open a collapse when initialized with "show" if not already shown', function (assert) {
|
||||
var done = assert.async()
|
||||
|
||||
expect(1)
|
||||
assert.expect(1)
|
||||
|
||||
var $test = $('<div id="test1" />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.on('show.bs.collapse', function () {
|
||||
ok(true)
|
||||
assert.ok(true)
|
||||
})
|
||||
|
||||
$test.bootstrapCollapse('show')
|
||||
@ -157,9 +157,9 @@ $(function () {
|
||||
$('<div id="body3"/>')
|
||||
.appendTo($groups.eq(2))
|
||||
.on('shown.bs.collapse', function () {
|
||||
ok($target1.hasClass('collapsed'), 'inactive target 1 does have class "collapsed"')
|
||||
ok($target2.hasClass('collapsed'), 'inactive target 2 does have class "collapsed"')
|
||||
ok(!$target3.hasClass('collapsed'), 'active target 3 does not have class "collapsed"')
|
||||
assert.ok($target1.hasClass('collapsed'), 'inactive target 1 does have class "collapsed"')
|
||||
assert.ok($target2.hasClass('collapsed'), 'inactive target 2 does have class "collapsed"')
|
||||
assert.ok(!$target3.hasClass('collapsed'), 'active target 3 does not have class "collapsed"')
|
||||
|
||||
done()
|
||||
})
|
||||
@ -190,9 +190,9 @@ $(function () {
|
||||
$('<div id="body3"/>')
|
||||
.appendTo($groups.eq(2))
|
||||
.on('shown.bs.collapse', function () {
|
||||
ok($target1.hasClass('collapsed'), 'inactive target 1 does have class "collapsed"')
|
||||
ok($target2.hasClass('collapsed'), 'inactive target 2 does have class "collapsed"')
|
||||
ok(!$target3.hasClass('collapsed'), 'active target 3 does not have class "collapsed"')
|
||||
assert.ok($target1.hasClass('collapsed'), 'inactive target 1 does have class "collapsed"')
|
||||
assert.ok($target2.hasClass('collapsed'), 'inactive target 2 does have class "collapsed"')
|
||||
assert.ok(!$target3.hasClass('collapsed'), 'active target 3 does not have class "collapsed"')
|
||||
|
||||
done()
|
||||
})
|
||||
@ -208,7 +208,7 @@ $(function () {
|
||||
$('<div id="test1"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.on('shown.bs.collapse', function () {
|
||||
equal($target.attr('aria-expanded'), 'true', 'aria-expanded on target is "true"')
|
||||
assert.equal($target.attr('aria-expanded'), 'true', 'aria-expanded on target is "true"')
|
||||
done()
|
||||
})
|
||||
|
||||
@ -223,7 +223,7 @@ $(function () {
|
||||
$('<div id="test1" class="in"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.on('hidden.bs.collapse', function () {
|
||||
equal($target.attr('aria-expanded'), 'false', 'aria-expanded on target is "false"')
|
||||
assert.equal($target.attr('aria-expanded'), 'false', 'aria-expanded on target is "false"')
|
||||
done()
|
||||
})
|
||||
|
||||
@ -253,9 +253,9 @@ $(function () {
|
||||
$('<div id="body3" aria-expanded="false"/>')
|
||||
.appendTo($groups.eq(2))
|
||||
.on('shown.bs.collapse', function () {
|
||||
equal($target1.attr('aria-expanded'), 'false', 'inactive target 1 has aria-expanded="false"')
|
||||
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"')
|
||||
assert.equal($target1.attr('aria-expanded'), 'false', 'inactive target 1 has aria-expanded="false"')
|
||||
assert.equal($target2.attr('aria-expanded'), 'false', 'inactive target 2 has aria-expanded="false"')
|
||||
assert.equal($target3.attr('aria-expanded'), 'true', 'active target 3 has aria-expanded="false"')
|
||||
|
||||
done()
|
||||
})
|
||||
@ -293,7 +293,7 @@ $(function () {
|
||||
$target1.click()
|
||||
|
||||
setTimeout(function () {
|
||||
ok(!showFired, 'show event didn\'t fire')
|
||||
assert.ok(!showFired, 'show event didn\'t fire')
|
||||
done()
|
||||
}, 1)
|
||||
})
|
||||
@ -306,7 +306,7 @@ $(function () {
|
||||
$('<div id="test1" class="in"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.on('hidden.bs.collapse', function () {
|
||||
ok($target.hasClass('collapsed'))
|
||||
assert.ok($target.hasClass('collapsed'))
|
||||
done()
|
||||
})
|
||||
.bootstrapCollapse('hide')
|
||||
@ -320,7 +320,7 @@ $(function () {
|
||||
$('<div id="test1"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.on('shown.bs.collapse', function () {
|
||||
ok(!$target.hasClass('collapsed'))
|
||||
assert.ok(!$target.hasClass('collapsed'))
|
||||
done()
|
||||
})
|
||||
.bootstrapCollapse('show')
|
||||
|
@ -3,8 +3,8 @@ $(function () {
|
||||
|
||||
module('dropdowns plugin')
|
||||
|
||||
test('should be defined on jquery object', function () {
|
||||
ok($(document.body).dropdown, 'dropdown method is defined')
|
||||
test('should be defined on jquery object', function (assert) {
|
||||
assert.ok($(document.body).dropdown, 'dropdown method is defined')
|
||||
})
|
||||
|
||||
module('dropdowns', {
|
||||
@ -18,18 +18,18 @@ $(function () {
|
||||
}
|
||||
})
|
||||
|
||||
test('should provide no conflict', function () {
|
||||
strictEqual($.fn.dropdown, undefined, 'dropdown was set back to undefined (org value)')
|
||||
test('should provide no conflict', function (assert) {
|
||||
assert.strictEqual($.fn.dropdown, undefined, 'dropdown was set back to undefined (org value)')
|
||||
})
|
||||
|
||||
test('should return jquery collection containing the element', function () {
|
||||
test('should return jquery collection containing the element', function (assert) {
|
||||
var $el = $('<div/>')
|
||||
var $dropdown = $el.bootstrapDropdown()
|
||||
ok($dropdown instanceof $, 'returns jquery collection')
|
||||
strictEqual($dropdown[0], $el[0], 'collection contains element')
|
||||
assert.ok($dropdown instanceof $, 'returns jquery collection')
|
||||
assert.strictEqual($dropdown[0], $el[0], 'collection contains element')
|
||||
})
|
||||
|
||||
test('should not open dropdown if target is disabled via attribute', function () {
|
||||
test('should not open dropdown if target is disabled via attribute', function (assert) {
|
||||
var dropdownHTML = '<ul class="tabs">'
|
||||
+ '<li class="dropdown">'
|
||||
+ '<button disabled href="#" class="btn dropdown-toggle" data-toggle="dropdown">Dropdown</button>'
|
||||
@ -43,10 +43,10 @@ $(function () {
|
||||
+ '</ul>'
|
||||
var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
|
||||
|
||||
ok(!$dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
|
||||
assert.ok(!$dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
|
||||
})
|
||||
|
||||
test('should not open dropdown if target is disabled via class', function () {
|
||||
test('should not open dropdown if target is disabled via class', function (assert) {
|
||||
var dropdownHTML = '<ul class="tabs">'
|
||||
+ '<li class="dropdown">'
|
||||
+ '<button href="#" class="btn dropdown-toggle disabled" data-toggle="dropdown">Dropdown</button>'
|
||||
@ -60,10 +60,10 @@ $(function () {
|
||||
+ '</ul>'
|
||||
var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
|
||||
|
||||
ok(!$dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
|
||||
assert.ok(!$dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
|
||||
})
|
||||
|
||||
test('should add class open to menu if clicked', function () {
|
||||
test('should add class open to menu if clicked', function (assert) {
|
||||
var dropdownHTML = '<ul class="tabs">'
|
||||
+ '<li class="dropdown">'
|
||||
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
|
||||
@ -77,10 +77,10 @@ $(function () {
|
||||
+ '</ul>'
|
||||
var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
|
||||
|
||||
ok($dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
|
||||
assert.ok($dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
|
||||
})
|
||||
|
||||
test('should test if element has a # before assuming it\'s a selector', function () {
|
||||
test('should test if element has a # before assuming it\'s a selector', function (assert) {
|
||||
var dropdownHTML = '<ul class="tabs">'
|
||||
+ '<li class="dropdown">'
|
||||
+ '<a href="/foo/" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
|
||||
@ -94,11 +94,11 @@ $(function () {
|
||||
+ '</ul>'
|
||||
var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
|
||||
|
||||
ok($dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
|
||||
assert.ok($dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
|
||||
})
|
||||
|
||||
|
||||
test('should remove "open" class if body is clicked', function () {
|
||||
test('should remove "open" class if body is clicked', function (assert) {
|
||||
var dropdownHTML = '<ul class="tabs">'
|
||||
+ '<li class="dropdown">'
|
||||
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
|
||||
@ -116,12 +116,12 @@ $(function () {
|
||||
.bootstrapDropdown()
|
||||
.click()
|
||||
|
||||
ok($dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
|
||||
assert.ok($dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
|
||||
$(document.body).click()
|
||||
ok(!$dropdown.parent('.dropdown').hasClass('open'), '"open" class removed')
|
||||
assert.ok(!$dropdown.parent('.dropdown').hasClass('open'), '"open" class removed')
|
||||
})
|
||||
|
||||
test('should remove "open" class if body is clicked, with multiple dropdowns', function () {
|
||||
test('should remove "open" class if body is clicked, with multiple dropdowns', function (assert) {
|
||||
var dropdownHTML = '<ul class="nav">'
|
||||
+ '<li><a href="#menu1">Menu 1</a></li>'
|
||||
+ '<li class="dropdown" id="testmenu">'
|
||||
@ -142,19 +142,19 @@ $(function () {
|
||||
var $first = $dropdowns.first()
|
||||
var $last = $dropdowns.last()
|
||||
|
||||
strictEqual($dropdowns.length, 2, 'two dropdowns')
|
||||
assert.strictEqual($dropdowns.length, 2, 'two dropdowns')
|
||||
|
||||
$first.click()
|
||||
strictEqual($first.parents('.open').length, 1, '"open" class added on click')
|
||||
strictEqual($('#qunit-fixture .open').length, 1, 'only one dropdown is open')
|
||||
assert.strictEqual($first.parents('.open').length, 1, '"open" class added on click')
|
||||
assert.strictEqual($('#qunit-fixture .open').length, 1, 'only one dropdown is open')
|
||||
$(document.body).click()
|
||||
strictEqual($('#qunit-fixture .open').length, 0, '"open" class removed')
|
||||
assert.strictEqual($('#qunit-fixture .open').length, 0, '"open" class removed')
|
||||
|
||||
$last.click()
|
||||
strictEqual($last.parent('.open').length, 1, '"open" class added on click')
|
||||
strictEqual($('#qunit-fixture .open').length, 1, 'only one dropdown is open')
|
||||
assert.strictEqual($last.parent('.open').length, 1, '"open" class added on click')
|
||||
assert.strictEqual($('#qunit-fixture .open').length, 1, 'only one dropdown is open')
|
||||
$(document.body).click()
|
||||
strictEqual($('#qunit-fixture .open').length, 0, '"open" class removed')
|
||||
assert.strictEqual($('#qunit-fixture .open').length, 0, '"open" class removed')
|
||||
})
|
||||
|
||||
test('should fire show and hide event', function (assert) {
|
||||
@ -179,10 +179,10 @@ $(function () {
|
||||
$dropdown
|
||||
.parent('.dropdown')
|
||||
.on('show.bs.dropdown', function () {
|
||||
ok(true, 'show was fired')
|
||||
assert.ok(true, 'show was fired')
|
||||
})
|
||||
.on('hide.bs.dropdown', function () {
|
||||
ok(true, 'hide was fired')
|
||||
assert.ok(true, 'hide was fired')
|
||||
done()
|
||||
})
|
||||
|
||||
@ -213,10 +213,10 @@ $(function () {
|
||||
$dropdown
|
||||
.parent('.dropdown')
|
||||
.on('shown.bs.dropdown', function () {
|
||||
ok(true, 'shown was fired')
|
||||
assert.ok(true, 'shown was fired')
|
||||
})
|
||||
.on('hidden.bs.dropdown', function () {
|
||||
ok(true, 'hidden was fired')
|
||||
assert.ok(true, 'hidden was fired')
|
||||
done()
|
||||
})
|
||||
|
||||
@ -251,13 +251,13 @@ $(function () {
|
||||
$dropdown
|
||||
.parent('.dropdown')
|
||||
.on('shown.bs.dropdown', function () {
|
||||
ok(true, 'shown was fired')
|
||||
assert.ok(true, 'shown was fired')
|
||||
|
||||
$input.focus().trigger($.Event('keydown', { which: 38 }))
|
||||
ok($(document.activeElement).is($input), 'input still focused')
|
||||
assert.ok($(document.activeElement).is($input), 'input still focused')
|
||||
|
||||
$textarea.focus().trigger($.Event('keydown', { which: 38 }))
|
||||
ok($(document.activeElement).is($textarea), 'textarea still focused')
|
||||
assert.ok($(document.activeElement).is($textarea), 'textarea still focused')
|
||||
|
||||
done()
|
||||
})
|
||||
|
@ -3,8 +3,8 @@ $(function () {
|
||||
|
||||
module('modal plugin')
|
||||
|
||||
test('should be defined on jquery object', function () {
|
||||
ok($(document.body).modal, 'modal method is defined')
|
||||
test('should be defined on jquery object', function (assert) {
|
||||
assert.ok($(document.body).modal, 'modal method is defined')
|
||||
})
|
||||
|
||||
module('modal', {
|
||||
@ -18,19 +18,19 @@ $(function () {
|
||||
}
|
||||
})
|
||||
|
||||
test('should provide no conflict', function () {
|
||||
strictEqual($.fn.modal, undefined, 'modal was set back to undefined (orig value)')
|
||||
test('should provide no conflict', function (assert) {
|
||||
assert.strictEqual($.fn.modal, undefined, 'modal was set back to undefined (orig value)')
|
||||
})
|
||||
|
||||
test('should return jquery collection containing the element', function () {
|
||||
test('should return jquery collection containing the element', function (assert) {
|
||||
var $el = $('<div id="modal-test"/>')
|
||||
var $modal = $el.bootstrapModal()
|
||||
ok($modal instanceof $, 'returns jquery collection')
|
||||
strictEqual($modal[0], $el[0], 'collection contains element')
|
||||
assert.ok($modal instanceof $, 'returns jquery collection')
|
||||
assert.strictEqual($modal[0], $el[0], 'collection contains element')
|
||||
})
|
||||
|
||||
test('should expose defaults var for settings', function () {
|
||||
ok($.fn.bootstrapModal.Constructor.DEFAULTS, 'default object exposed')
|
||||
test('should expose defaults var for settings', function (assert) {
|
||||
assert.ok($.fn.bootstrapModal.Constructor.DEFAULTS, 'default object exposed')
|
||||
})
|
||||
|
||||
test('should insert into dom when show method is called', function (assert) {
|
||||
@ -38,7 +38,7 @@ $(function () {
|
||||
|
||||
$('<div id="modal-test"/>')
|
||||
.on('shown.bs.modal', function () {
|
||||
notEqual($('#modal-test').length, 0, 'modal inserted into dom')
|
||||
assert.notEqual($('#modal-test').length, 0, 'modal inserted into dom')
|
||||
done()
|
||||
})
|
||||
.bootstrapModal('show')
|
||||
@ -49,7 +49,7 @@ $(function () {
|
||||
|
||||
$('<div id="modal-test"/>')
|
||||
.on('show.bs.modal', function () {
|
||||
ok(true, 'show event fired')
|
||||
assert.ok(true, 'show event fired')
|
||||
done()
|
||||
})
|
||||
.bootstrapModal('show')
|
||||
@ -61,11 +61,11 @@ $(function () {
|
||||
$('<div id="modal-test"/>')
|
||||
.on('show.bs.modal', function (e) {
|
||||
e.preventDefault()
|
||||
ok(true, 'show event fired')
|
||||
assert.ok(true, 'show event fired')
|
||||
done()
|
||||
})
|
||||
.on('shown.bs.modal', function () {
|
||||
ok(false, 'shown event fired')
|
||||
assert.ok(false, 'shown event fired')
|
||||
})
|
||||
.bootstrapModal('show')
|
||||
})
|
||||
@ -75,12 +75,12 @@ $(function () {
|
||||
|
||||
$('<div id="modal-test"/>')
|
||||
.on('shown.bs.modal', function () {
|
||||
ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
notEqual($('#modal-test').length, 0, 'modal inserted into dom')
|
||||
assert.ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
assert.notEqual($('#modal-test').length, 0, 'modal inserted into dom')
|
||||
$(this).bootstrapModal('hide')
|
||||
})
|
||||
.on('hidden.bs.modal', function () {
|
||||
ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
assert.ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
done()
|
||||
})
|
||||
.bootstrapModal('show')
|
||||
@ -91,12 +91,12 @@ $(function () {
|
||||
|
||||
$('<div id="modal-test"/>')
|
||||
.on('shown.bs.modal', function () {
|
||||
ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
notEqual($('#modal-test').length, 0, 'modal inserted into dom')
|
||||
assert.ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
assert.notEqual($('#modal-test').length, 0, 'modal inserted into dom')
|
||||
$(this).bootstrapModal('toggle')
|
||||
})
|
||||
.on('hidden.bs.modal', function () {
|
||||
ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
assert.ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
done()
|
||||
})
|
||||
.bootstrapModal('toggle')
|
||||
@ -107,12 +107,12 @@ $(function () {
|
||||
|
||||
$('<div id="modal-test"><span class="close" data-dismiss="modal"/></div>')
|
||||
.on('shown.bs.modal', function () {
|
||||
ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
notEqual($('#modal-test').length, 0, 'modal inserted into dom')
|
||||
assert.ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
assert.notEqual($('#modal-test').length, 0, 'modal inserted into dom')
|
||||
$(this).find('.close').click()
|
||||
})
|
||||
.on('hidden.bs.modal', function () {
|
||||
ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
assert.ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
done()
|
||||
})
|
||||
.bootstrapModal('toggle')
|
||||
@ -123,11 +123,11 @@ $(function () {
|
||||
|
||||
$('<div id="modal-test" data-backdrop="false"/>')
|
||||
.on('shown.bs.modal', function () {
|
||||
ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
assert.ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
$(this).bootstrapModal('hide')
|
||||
})
|
||||
.on('hidden.bs.modal', function () {
|
||||
ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
assert.ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
done()
|
||||
})
|
||||
.bootstrapModal('show')
|
||||
@ -138,13 +138,13 @@ $(function () {
|
||||
|
||||
$('<div id="modal-test"><div class="contents"/></div>')
|
||||
.on('shown.bs.modal', function () {
|
||||
notEqual($('#modal-test').length, 0, 'modal insterted into dom')
|
||||
assert.notEqual($('#modal-test').length, 0, 'modal insterted into dom')
|
||||
$('.contents').click()
|
||||
ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
assert.ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
$('#modal-test .modal-backdrop').click()
|
||||
})
|
||||
.on('hidden.bs.modal', function () {
|
||||
ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
assert.ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
done()
|
||||
})
|
||||
.bootstrapModal('show')
|
||||
@ -156,12 +156,12 @@ $(function () {
|
||||
var div = $('<div id="modal-test"/>')
|
||||
div
|
||||
.on('shown.bs.modal', function () {
|
||||
ok($('#modal-test').length, 'modal insterted into dom')
|
||||
ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
assert.ok($('#modal-test').length, 'modal insterted into dom')
|
||||
assert.ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
div.trigger($.Event('keydown', { which: 27 }))
|
||||
|
||||
setTimeout(function () {
|
||||
ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
assert.ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
div.remove()
|
||||
done()
|
||||
}, 0)
|
||||
@ -175,12 +175,12 @@ $(function () {
|
||||
var div = $('<div id="modal-test"/>')
|
||||
div
|
||||
.on('shown.bs.modal', function () {
|
||||
ok($('#modal-test').length, 'modal insterted into dom')
|
||||
ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
assert.ok($('#modal-test').length, 'modal insterted into dom')
|
||||
assert.ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
div.trigger($.Event('keyup', { which: 27 }))
|
||||
|
||||
setTimeout(function () {
|
||||
ok($('#modal-test').is(':visible'), 'modal still visible')
|
||||
assert.ok($('#modal-test').is(':visible'), 'modal still visible')
|
||||
div.remove()
|
||||
done()
|
||||
}, 0)
|
||||
@ -200,7 +200,7 @@ $(function () {
|
||||
})
|
||||
.on('hide.bs.modal', function () {
|
||||
triggered += 1
|
||||
strictEqual(triggered, 1, 'modal hide triggered once')
|
||||
assert.strictEqual(triggered, 1, 'modal hide triggered once')
|
||||
done()
|
||||
})
|
||||
.bootstrapModal('show')
|
||||
@ -215,13 +215,13 @@ $(function () {
|
||||
})
|
||||
.one('hidden.bs.modal', function () {
|
||||
// after one open-close cycle
|
||||
ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
assert.ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
$(this)
|
||||
.one('shown.bs.modal', function () {
|
||||
$('#close').click()
|
||||
})
|
||||
.one('hidden.bs.modal', function () {
|
||||
ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
assert.ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
done()
|
||||
})
|
||||
.bootstrapModal('show')
|
||||
@ -237,7 +237,7 @@ $(function () {
|
||||
$('<div id="modal-test"><div class="contents"><div id="close" data-dismiss="modal"/></div></div>')
|
||||
.on('hidden.bs.modal', function () {
|
||||
setTimeout(function () {
|
||||
ok($(document.activeElement).is($toggleBtn), 'toggling element is once again focused')
|
||||
assert.ok($(document.activeElement).is($toggleBtn), 'toggling element is once again focused')
|
||||
done()
|
||||
}, 0)
|
||||
})
|
||||
@ -264,7 +264,7 @@ $(function () {
|
||||
})
|
||||
.on('hidden.bs.modal', function () {
|
||||
setTimeout(function () {
|
||||
ok($(document.activeElement).is($otherBtn), 'focus returned to toggling element')
|
||||
assert.ok($(document.activeElement).is($otherBtn), 'focus returned to toggling element')
|
||||
done()
|
||||
}, 0)
|
||||
})
|
||||
|
@ -3,8 +3,8 @@ $(function () {
|
||||
|
||||
module('popover plugin')
|
||||
|
||||
test('should be defined on jquery object', function () {
|
||||
ok($(document.body).popover, 'popover method is defined')
|
||||
test('should be defined on jquery object', function (assert) {
|
||||
assert.ok($(document.body).popover, 'popover method is defined')
|
||||
})
|
||||
|
||||
module('popover', {
|
||||
@ -18,44 +18,44 @@ $(function () {
|
||||
}
|
||||
})
|
||||
|
||||
test('should provide no conflict', function () {
|
||||
strictEqual($.fn.popover, undefined, 'popover was set back to undefined (org value)')
|
||||
test('should provide no conflict', function (assert) {
|
||||
assert.strictEqual($.fn.popover, undefined, 'popover was set back to undefined (org value)')
|
||||
})
|
||||
|
||||
test('should return jquery collection containing the element', function () {
|
||||
test('should return jquery collection containing the element', function (assert) {
|
||||
var $el = $('<div/>')
|
||||
var $popover = $el.bootstrapPopover()
|
||||
ok($popover instanceof $, 'returns jquery collection')
|
||||
strictEqual($popover[0], $el[0], 'collection contains element')
|
||||
assert.ok($popover instanceof $, 'returns jquery collection')
|
||||
assert.strictEqual($popover[0], $el[0], 'collection contains element')
|
||||
})
|
||||
|
||||
test('should render popover element', function () {
|
||||
test('should render popover element', function (assert) {
|
||||
var $popover = $('<a href="#" title="mdo" data-content="https://twitter.com/mdo">@mdo</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover('show')
|
||||
|
||||
notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
$popover.bootstrapPopover('hide')
|
||||
equal($('.popover').length, 0, 'popover removed')
|
||||
assert.equal($('.popover').length, 0, 'popover removed')
|
||||
})
|
||||
|
||||
test('should store popover instance in popover data object', function () {
|
||||
test('should store popover instance in popover data object', function (assert) {
|
||||
var $popover = $('<a href="#" title="mdo" data-content="https://twitter.com/mdo">@mdo</a>').bootstrapPopover()
|
||||
|
||||
ok($popover.data('bs.popover'), 'popover instance exists')
|
||||
assert.ok($popover.data('bs.popover'), 'popover instance exists')
|
||||
})
|
||||
|
||||
test('should store popover trigger in popover instance data object', function () {
|
||||
test('should store popover trigger in popover instance data object', function (assert) {
|
||||
var $popover = $('<a href="#" title="ResentedHook">@ResentedHook</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover()
|
||||
|
||||
$popover.bootstrapPopover('show')
|
||||
|
||||
ok($('.popover').data('bs.popover'), 'popover trigger stored in instance data')
|
||||
assert.ok($('.popover').data('bs.popover'), 'popover trigger stored in instance data')
|
||||
})
|
||||
|
||||
test('should get title and content from options', function () {
|
||||
test('should get title and content from options', function (assert) {
|
||||
var $popover = $('<a href="#">@fat</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover({
|
||||
@ -69,15 +69,15 @@ $(function () {
|
||||
|
||||
$popover.bootstrapPopover('show')
|
||||
|
||||
notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
equal($('.popover .popover-title').text(), '@fat', 'title correctly inserted')
|
||||
equal($('.popover .popover-content').text(), 'loves writing tests (╯°□°)╯︵ ┻━┻', 'content correctly inserted')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
assert.equal($('.popover .popover-title').text(), '@fat', 'title correctly inserted')
|
||||
assert.equal($('.popover .popover-content').text(), 'loves writing tests (╯°□°)╯︵ ┻━┻', 'content correctly inserted')
|
||||
|
||||
$popover.bootstrapPopover('hide')
|
||||
equal($('.popover').length, 0, 'popover was removed')
|
||||
assert.equal($('.popover').length, 0, 'popover was removed')
|
||||
})
|
||||
|
||||
test('should not duplicate HTML object', function () {
|
||||
test('should not duplicate HTML object', function (assert) {
|
||||
var $div = $('<div/>').html('loves writing tests (╯°□°)╯︵ ┻━┻')
|
||||
|
||||
var $popover = $('<a href="#">@fat</a>')
|
||||
@ -89,36 +89,36 @@ $(function () {
|
||||
})
|
||||
|
||||
$popover.bootstrapPopover('show')
|
||||
notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
equal($('.popover .popover-content').html(), $div, 'content correctly inserted')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
assert.equal($('.popover .popover-content').html(), $div, 'content correctly inserted')
|
||||
|
||||
$popover.bootstrapPopover('hide')
|
||||
equal($('.popover').length, 0, 'popover was removed')
|
||||
assert.equal($('.popover').length, 0, 'popover was removed')
|
||||
|
||||
$popover.bootstrapPopover('show')
|
||||
notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
equal($('.popover .popover-content').html(), $div, 'content correctly inserted')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
assert.equal($('.popover .popover-content').html(), $div, 'content correctly inserted')
|
||||
|
||||
$popover.bootstrapPopover('hide')
|
||||
equal($('.popover').length, 0, 'popover was removed')
|
||||
assert.equal($('.popover').length, 0, 'popover was removed')
|
||||
})
|
||||
|
||||
test('should get title and content from attributes', function () {
|
||||
test('should get title and content from attributes', function (assert) {
|
||||
var $popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover()
|
||||
.bootstrapPopover('show')
|
||||
|
||||
notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
equal($('.popover .popover-title').text(), '@mdo', 'title correctly inserted')
|
||||
equal($('.popover .popover-content').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
assert.equal($('.popover .popover-title').text(), '@mdo', 'title correctly inserted')
|
||||
assert.equal($('.popover .popover-content').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted')
|
||||
|
||||
$popover.bootstrapPopover('hide')
|
||||
equal($('.popover').length, 0, 'popover was removed')
|
||||
assert.equal($('.popover').length, 0, 'popover was removed')
|
||||
})
|
||||
|
||||
|
||||
test('should get title and content from attributes ignoring options passed via js', function () {
|
||||
test('should get title and content from attributes ignoring options passed via js', function (assert) {
|
||||
var $popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover({
|
||||
@ -127,15 +127,15 @@ $(function () {
|
||||
})
|
||||
.bootstrapPopover('show')
|
||||
|
||||
notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
equal($('.popover .popover-title').text(), '@mdo', 'title correctly inserted')
|
||||
equal($('.popover .popover-content').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
assert.equal($('.popover .popover-title').text(), '@mdo', 'title correctly inserted')
|
||||
assert.equal($('.popover .popover-content').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted')
|
||||
|
||||
$popover.bootstrapPopover('hide')
|
||||
equal($('.popover').length, 0, 'popover was removed')
|
||||
assert.equal($('.popover').length, 0, 'popover was removed')
|
||||
})
|
||||
|
||||
test('should respect custom template', function () {
|
||||
test('should respect custom template', function (assert) {
|
||||
var $popover = $('<a href="#">@fat</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover({
|
||||
@ -146,34 +146,34 @@ $(function () {
|
||||
|
||||
$popover.bootstrapPopover('show')
|
||||
|
||||
notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
ok($('.popover').hasClass('foobar'), 'custom class is present')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
assert.ok($('.popover').hasClass('foobar'), 'custom class is present')
|
||||
|
||||
$popover.bootstrapPopover('hide')
|
||||
equal($('.popover').length, 0, 'popover was removed')
|
||||
assert.equal($('.popover').length, 0, 'popover was removed')
|
||||
})
|
||||
|
||||
test('should destroy popover', function () {
|
||||
test('should destroy popover', function (assert) {
|
||||
var $popover = $('<div/>')
|
||||
.bootstrapPopover({
|
||||
trigger: 'hover'
|
||||
})
|
||||
.on('click.foo', $.noop)
|
||||
|
||||
ok($popover.data('bs.popover'), 'popover has data')
|
||||
ok($._data($popover[0], 'events').mouseover && $._data($popover[0], 'events').mouseout, 'popover has hover event')
|
||||
equal($._data($popover[0], 'events').click[0].namespace, 'foo', 'popover has extra click.foo event')
|
||||
assert.ok($popover.data('bs.popover'), 'popover has data')
|
||||
assert.ok($._data($popover[0], 'events').mouseover && $._data($popover[0], 'events').mouseout, 'popover has hover event')
|
||||
assert.equal($._data($popover[0], 'events').click[0].namespace, 'foo', 'popover has extra click.foo event')
|
||||
|
||||
$popover.bootstrapPopover('show')
|
||||
$popover.bootstrapPopover('destroy')
|
||||
|
||||
ok(!$popover.hasClass('in'), 'popover is hidden')
|
||||
ok(!$popover.data('popover'), 'popover does not have data')
|
||||
equal($._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')
|
||||
assert.ok(!$popover.hasClass('in'), 'popover is hidden')
|
||||
assert.ok(!$popover.data('popover'), 'popover does not have data')
|
||||
assert.equal($._data($popover[0], 'events').click[0].namespace, 'foo', 'popover still has click.foo')
|
||||
assert.ok(!$._data($popover[0], 'events').mouseover && !$._data($popover[0], 'events').mouseout, 'popover does not have any events')
|
||||
})
|
||||
|
||||
test('should render popover element using delegated selector', function () {
|
||||
test('should render popover element using delegated selector', function (assert) {
|
||||
var $div = $('<div><a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a></div>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover({
|
||||
@ -182,10 +182,10 @@ $(function () {
|
||||
})
|
||||
|
||||
$div.find('a').click()
|
||||
notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
assert.notEqual($('.popover').length, 0, 'popover was inserted')
|
||||
|
||||
$div.find('a').click()
|
||||
equal($('.popover').length, 0, 'popover was removed')
|
||||
assert.equal($('.popover').length, 0, 'popover was removed')
|
||||
})
|
||||
|
||||
test('should detach popover content rather than removing it so that event handlers are left intact', function (assert) {
|
||||
@ -216,7 +216,7 @@ $(function () {
|
||||
.one('shown.bs.popover', function () {
|
||||
$('.content-with-handler .btn').click()
|
||||
$div.bootstrapPopover('destroy')
|
||||
ok(handlerCalled, 'content\'s event handler still present')
|
||||
assert.ok(handlerCalled, 'content\'s event handler still present')
|
||||
done()
|
||||
})
|
||||
.bootstrapPopover('show')
|
||||
@ -226,8 +226,8 @@ $(function () {
|
||||
.bootstrapPopover('show')
|
||||
})
|
||||
|
||||
test('should throw an error when initializing popover on the document object without specifying a delegation selector', function () {
|
||||
throws(function () {
|
||||
test('should throw an error when initializing popover on the document object without specifying a delegation selector', function (assert) {
|
||||
assert.throws(function () {
|
||||
$(document).bootstrapPopover({ title: 'What am I on?', content: 'My selector is missing' })
|
||||
}, new Error('`selector` option must be specified when initializing popover on the window.document object!'))
|
||||
})
|
||||
|
@ -3,8 +3,8 @@ $(function () {
|
||||
|
||||
module('scrollspy plugin')
|
||||
|
||||
test('should be defined on jquery object', function () {
|
||||
ok($(document.body).scrollspy, 'scrollspy method is defined')
|
||||
test('should be defined on jquery object', function (assert) {
|
||||
assert.ok($(document.body).scrollspy, 'scrollspy method is defined')
|
||||
})
|
||||
|
||||
module('scrollspy', {
|
||||
@ -18,15 +18,15 @@ $(function () {
|
||||
}
|
||||
})
|
||||
|
||||
test('should provide no conflict', function () {
|
||||
strictEqual($.fn.scrollspy, undefined, 'scrollspy was set back to undefined (org value)')
|
||||
test('should provide no conflict', function (assert) {
|
||||
assert.strictEqual($.fn.scrollspy, undefined, 'scrollspy was set back to undefined (org value)')
|
||||
})
|
||||
|
||||
test('should return jquery collection containing the element', function () {
|
||||
test('should return jquery collection containing the element', function (assert) {
|
||||
var $el = $('<div/>')
|
||||
var $scrollspy = $el.bootstrapScrollspy()
|
||||
ok($scrollspy instanceof $, 'returns jquery collection')
|
||||
strictEqual($scrollspy[0], $el[0], 'collection contains element')
|
||||
assert.ok($scrollspy instanceof $, 'returns jquery collection')
|
||||
assert.strictEqual($scrollspy[0], $el[0], 'collection contains element')
|
||||
})
|
||||
|
||||
test('should only switch "active" class on current target', function (assert) {
|
||||
@ -66,7 +66,7 @@ $(function () {
|
||||
.bootstrapScrollspy({ target: '#ss-target' })
|
||||
|
||||
$scrollspy.on('scroll.bs.scrollspy', function () {
|
||||
ok($section.hasClass('active'), '"active" class still on root node')
|
||||
assert.ok($section.hasClass('active'), '"active" class still on root node')
|
||||
done()
|
||||
})
|
||||
|
||||
@ -97,9 +97,9 @@ $(function () {
|
||||
$scrollspy.bootstrapScrollspy({ target: '#navigation', offset: $scrollspy.position().top })
|
||||
|
||||
$scrollspy.on('scroll.bs.scrollspy', function () {
|
||||
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')
|
||||
assert.ok(!$section.find('#one-link').parent().hasClass('active'), '"active" class removed from first section')
|
||||
assert.ok($section.find('#two-link').parent().hasClass('active'), '"active" class on middle section')
|
||||
assert.ok(!$section.find('#three-link').parent().hasClass('active'), '"active" class not on last section')
|
||||
done()
|
||||
})
|
||||
|
||||
@ -130,7 +130,7 @@ $(function () {
|
||||
var scrollHeight = Math.ceil($content.scrollTop() + $(target).position().top)
|
||||
var done = assert.async()
|
||||
$content.one('scroll', function () {
|
||||
ok($(element).hasClass('active'), 'target:' + target + ', element' + element)
|
||||
assert.ok($(element).hasClass('active'), 'target:' + target + ', element' + element)
|
||||
done()
|
||||
deferred.resolve()
|
||||
})
|
||||
@ -170,12 +170,12 @@ $(function () {
|
||||
offset: $scrollspy.position().top
|
||||
})
|
||||
.one('scroll.bs.scrollspy', function () {
|
||||
strictEqual($('.active').length, 1, '"active" class on only one element present')
|
||||
strictEqual($('.active').has('#two-link').length, 1, '"active" class on second section')
|
||||
assert.strictEqual($('.active').length, 1, '"active" class on only one element present')
|
||||
assert.strictEqual($('.active').has('#two-link').length, 1, '"active" class on second section')
|
||||
|
||||
$scrollspy
|
||||
.one('scroll.bs.scrollspy', function () {
|
||||
strictEqual($('.active').length, 0, 'selection cleared')
|
||||
assert.strictEqual($('.active').length, 0, 'selection cleared')
|
||||
done()
|
||||
})
|
||||
.scrollTop(0)
|
||||
|
@ -3,8 +3,8 @@ $(function () {
|
||||
|
||||
module('tabs plugin')
|
||||
|
||||
test('should be defined on jquery object', function () {
|
||||
ok($(document.body).tab, 'tabs method is defined')
|
||||
test('should be defined on jquery object', function (assert) {
|
||||
assert.ok($(document.body).tab, 'tabs method is defined')
|
||||
})
|
||||
|
||||
module('tabs', {
|
||||
@ -18,18 +18,18 @@ $(function () {
|
||||
}
|
||||
})
|
||||
|
||||
test('should provide no conflict', function () {
|
||||
strictEqual($.fn.tab, undefined, 'tab was set back to undefined (org value)')
|
||||
test('should provide no conflict', function (assert) {
|
||||
assert.strictEqual($.fn.tab, undefined, 'tab was set back to undefined (org value)')
|
||||
})
|
||||
|
||||
test('should return jquery collection containing the element', function () {
|
||||
test('should return jquery collection containing the element', function (assert) {
|
||||
var $el = $('<div/>')
|
||||
var $tab = $el.bootstrapTab()
|
||||
ok($tab instanceof $, 'returns jquery collection')
|
||||
strictEqual($tab[0], $el[0], 'collection contains element')
|
||||
assert.ok($tab instanceof $, 'returns jquery collection')
|
||||
assert.strictEqual($tab[0], $el[0], 'collection contains element')
|
||||
})
|
||||
|
||||
test('should activate element by tab id', function () {
|
||||
test('should activate element by tab id', function (assert) {
|
||||
var tabsHTML = '<ul class="tabs">'
|
||||
+ '<li><a href="#home">Home</a></li>'
|
||||
+ '<li><a href="#profile">Profile</a></li>'
|
||||
@ -38,13 +38,13 @@ $(function () {
|
||||
$('<ul><li id="home"/><li id="profile"/></ul>').appendTo('#qunit-fixture')
|
||||
|
||||
$(tabsHTML).find('li:last a').bootstrapTab('show')
|
||||
equal($('#qunit-fixture').find('.active').attr('id'), 'profile')
|
||||
assert.equal($('#qunit-fixture').find('.active').attr('id'), 'profile')
|
||||
|
||||
$(tabsHTML).find('li:first a').bootstrapTab('show')
|
||||
equal($('#qunit-fixture').find('.active').attr('id'), 'home')
|
||||
assert.equal($('#qunit-fixture').find('.active').attr('id'), 'home')
|
||||
})
|
||||
|
||||
test('should activate element by tab id', function () {
|
||||
test('should activate element by tab id', function (assert) {
|
||||
var pillsHTML = '<ul class="pills">'
|
||||
+ '<li><a href="#home">Home</a></li>'
|
||||
+ '<li><a href="#profile">Profile</a></li>'
|
||||
@ -53,10 +53,10 @@ $(function () {
|
||||
$('<ul><li id="home"/><li id="profile"/></ul>').appendTo('#qunit-fixture')
|
||||
|
||||
$(pillsHTML).find('li:last a').bootstrapTab('show')
|
||||
equal($('#qunit-fixture').find('.active').attr('id'), 'profile')
|
||||
assert.equal($('#qunit-fixture').find('.active').attr('id'), 'profile')
|
||||
|
||||
$(pillsHTML).find('li:first a').bootstrapTab('show')
|
||||
equal($('#qunit-fixture').find('.active').attr('id'), 'home')
|
||||
assert.equal($('#qunit-fixture').find('.active').attr('id'), 'home')
|
||||
})
|
||||
|
||||
test('should not fire shown when show is prevented', function (assert) {
|
||||
@ -65,11 +65,11 @@ $(function () {
|
||||
$('<div class="tab"/>')
|
||||
.on('show.bs.tab', function (e) {
|
||||
e.preventDefault()
|
||||
ok(true, 'show event fired')
|
||||
assert.ok(true, 'show event fired')
|
||||
done()
|
||||
})
|
||||
.on('shown.bs.tab', function () {
|
||||
ok(false, 'shown event fired')
|
||||
assert.ok(false, 'shown event fired')
|
||||
})
|
||||
.bootstrapTab('show')
|
||||
})
|
||||
@ -92,10 +92,10 @@ $(function () {
|
||||
.end()
|
||||
.find('ul > li:last a')
|
||||
.on('show.bs.tab', function (e) {
|
||||
equal(e.relatedTarget.hash, '#1-1', 'references correct element as relatedTarget')
|
||||
assert.equal(e.relatedTarget.hash, '#1-1', 'references correct element as relatedTarget')
|
||||
})
|
||||
.on('shown.bs.tab', function (e) {
|
||||
equal(e.relatedTarget.hash, '#1-1', 'references correct element as relatedTarget')
|
||||
assert.equal(e.relatedTarget.hash, '#1-1', 'references correct element as relatedTarget')
|
||||
done()
|
||||
})
|
||||
.bootstrapTab('show')
|
||||
@ -112,7 +112,7 @@ $(function () {
|
||||
$(tabsHTML)
|
||||
.find('li:first a')
|
||||
.on('hide.bs.tab', function () {
|
||||
ok(true, 'hide event fired')
|
||||
assert.ok(true, 'hide event fired')
|
||||
})
|
||||
.bootstrapTab('show')
|
||||
.end()
|
||||
@ -122,7 +122,7 @@ $(function () {
|
||||
$(tabsHTML)
|
||||
.find('li:first a')
|
||||
.on('hidden.bs.tab', function () {
|
||||
ok(true, 'hidden event fired')
|
||||
assert.ok(true, 'hidden event fired')
|
||||
done()
|
||||
})
|
||||
.bootstrapTab('show')
|
||||
@ -143,11 +143,11 @@ $(function () {
|
||||
.find('li:first a')
|
||||
.on('hide.bs.tab', function (e) {
|
||||
e.preventDefault()
|
||||
ok(true, 'hide event fired')
|
||||
assert.ok(true, 'hide event fired')
|
||||
done()
|
||||
})
|
||||
.on('hidden.bs.tab', function () {
|
||||
ok(false, 'hidden event fired')
|
||||
assert.ok(false, 'hidden event fired')
|
||||
})
|
||||
.bootstrapTab('show')
|
||||
.end()
|
||||
@ -166,10 +166,10 @@ $(function () {
|
||||
$(tabsHTML)
|
||||
.find('li:first a')
|
||||
.on('hide.bs.tab', function (e) {
|
||||
equal(e.relatedTarget.hash, '#profile', 'references correct element as relatedTarget')
|
||||
assert.equal(e.relatedTarget.hash, '#profile', 'references correct element as relatedTarget')
|
||||
})
|
||||
.on('hidden.bs.tab', function (e) {
|
||||
equal(e.relatedTarget.hash, '#profile', 'references correct element as relatedTarget')
|
||||
assert.equal(e.relatedTarget.hash, '#profile', 'references correct element as relatedTarget')
|
||||
done()
|
||||
})
|
||||
.bootstrapTab('show')
|
||||
@ -178,7 +178,7 @@ $(function () {
|
||||
.bootstrapTab('show')
|
||||
})
|
||||
|
||||
test('selected tab should have aria-expanded', function () {
|
||||
test('selected tab should have aria-expanded', function (assert) {
|
||||
var tabsHTML = '<ul class="nav nav-tabs">'
|
||||
+ '<li class="active"><a href="#home" toggle="tab" aria-expanded="true">Home</a></li>'
|
||||
+ '<li><a href="#profile" toggle="tab" aria-expanded="false">Profile</a></li>'
|
||||
@ -186,20 +186,20 @@ $(function () {
|
||||
var $tabs = $(tabsHTML).appendTo('#qunit-fixture')
|
||||
|
||||
$tabs.find('li:first a').bootstrapTab('show')
|
||||
equal($tabs.find('.active a').attr('aria-expanded'), 'true', 'shown tab has aria-expanded = true')
|
||||
equal($tabs.find('li:not(.active) a').attr('aria-expanded'), 'false', 'hidden tab has aria-expanded = false')
|
||||
assert.equal($tabs.find('.active a').attr('aria-expanded'), 'true', 'shown tab has aria-expanded = true')
|
||||
assert.equal($tabs.find('li:not(.active) a').attr('aria-expanded'), 'false', 'hidden tab has aria-expanded = false')
|
||||
|
||||
$tabs.find('li:last a').click()
|
||||
equal($tabs.find('.active a').attr('aria-expanded'), 'true', 'after click, shown tab has aria-expanded = true')
|
||||
equal($tabs.find('li:not(.active) a').attr('aria-expanded'), 'false', 'after click, hidden tab has aria-expanded = false')
|
||||
assert.equal($tabs.find('.active a').attr('aria-expanded'), 'true', 'after click, shown tab has aria-expanded = true')
|
||||
assert.equal($tabs.find('li:not(.active) a').attr('aria-expanded'), 'false', 'after click, hidden tab has aria-expanded = false')
|
||||
|
||||
$tabs.find('li:first a').bootstrapTab('show')
|
||||
equal($tabs.find('.active a').attr('aria-expanded'), 'true', 'shown tab has aria-expanded = true')
|
||||
equal($tabs.find('li:not(.active) a').attr('aria-expanded'), 'false', 'hidden tab has aria-expanded = false')
|
||||
assert.equal($tabs.find('.active a').attr('aria-expanded'), 'true', 'shown tab has aria-expanded = true')
|
||||
assert.equal($tabs.find('li:not(.active) a').attr('aria-expanded'), 'false', 'hidden tab has aria-expanded = false')
|
||||
|
||||
$tabs.find('li:first a').click()
|
||||
equal($tabs.find('.active a').attr('aria-expanded'), 'true', 'after second show event, shown tab still has aria-expanded = true')
|
||||
equal($tabs.find('li:not(.active) a').attr('aria-expanded'), 'false', 'after second show event, hidden tab has aria-expanded = false')
|
||||
assert.equal($tabs.find('.active a').attr('aria-expanded'), 'true', 'after second show event, shown tab still has aria-expanded = true')
|
||||
assert.equal($tabs.find('li:not(.active) a').attr('aria-expanded'), 'false', 'after second show event, hidden tab has aria-expanded = false')
|
||||
})
|
||||
|
||||
})
|
||||
|
@ -3,8 +3,8 @@ $(function () {
|
||||
|
||||
module('tooltip plugin')
|
||||
|
||||
test('should be defined on jquery object', function () {
|
||||
ok($(document.body).tooltip, 'tooltip method is defined')
|
||||
test('should be defined on jquery object', function (assert) {
|
||||
assert.ok($(document.body).tooltip, 'tooltip method is defined')
|
||||
})
|
||||
|
||||
module('tooltip', {
|
||||
@ -18,32 +18,32 @@ $(function () {
|
||||
}
|
||||
})
|
||||
|
||||
test('should provide no conflict', function () {
|
||||
strictEqual($.fn.tooltip, undefined, 'tooltip was set back to undefined (org value)')
|
||||
test('should provide no conflict', function (assert) {
|
||||
assert.strictEqual($.fn.tooltip, undefined, 'tooltip was set back to undefined (org value)')
|
||||
})
|
||||
|
||||
test('should return jquery collection containing the element', function () {
|
||||
test('should return jquery collection containing the element', function (assert) {
|
||||
var $el = $('<div/>')
|
||||
var $tooltip = $el.bootstrapTooltip()
|
||||
ok($tooltip instanceof $, 'returns jquery collection')
|
||||
strictEqual($tooltip[0], $el[0], 'collection contains element')
|
||||
assert.ok($tooltip instanceof $, 'returns jquery collection')
|
||||
assert.strictEqual($tooltip[0], $el[0], 'collection contains element')
|
||||
})
|
||||
|
||||
test('should expose default settings', function () {
|
||||
ok($.fn.bootstrapTooltip.Constructor.DEFAULTS, 'defaults is defined')
|
||||
test('should expose default settings', function (assert) {
|
||||
assert.ok($.fn.bootstrapTooltip.Constructor.DEFAULTS, 'defaults is defined')
|
||||
})
|
||||
|
||||
test('should empty title attribute', function () {
|
||||
test('should empty title attribute', function (assert) {
|
||||
var $trigger = $('<a href="#" rel="tooltip" title="Another tooltip"/>').bootstrapTooltip()
|
||||
strictEqual($trigger.attr('title'), '', 'title attribute was emptied')
|
||||
assert.strictEqual($trigger.attr('title'), '', 'title attribute was emptied')
|
||||
})
|
||||
|
||||
test('should add data attribute for referencing original title', function () {
|
||||
test('should add data attribute for referencing original title', function (assert) {
|
||||
var $trigger = $('<a href="#" rel="tooltip" title="Another tooltip"/>').bootstrapTooltip()
|
||||
strictEqual($trigger.attr('data-original-title'), 'Another tooltip', 'original title preserved in data attribute')
|
||||
assert.strictEqual($trigger.attr('data-original-title'), 'Another tooltip', 'original title preserved in data attribute')
|
||||
})
|
||||
|
||||
test('should add aria-describedby to the trigger on show', function () {
|
||||
test('should add aria-describedby to the trigger on show', function (assert) {
|
||||
var $trigger = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
|
||||
.bootstrapTooltip()
|
||||
.appendTo('#qunit-fixture')
|
||||
@ -51,68 +51,68 @@ $(function () {
|
||||
|
||||
var id = $('.tooltip').attr('id')
|
||||
|
||||
strictEqual($('#' + id).length, 1, 'has a unique id')
|
||||
strictEqual($('.tooltip').attr('aria-describedby'), $trigger.attr('id'), 'tooltip id and aria-describedby on trigger match')
|
||||
ok($trigger[0].hasAttribute('aria-describedby'), 'trigger has aria-describedby')
|
||||
assert.strictEqual($('#' + id).length, 1, 'has a unique id')
|
||||
assert.strictEqual($('.tooltip').attr('aria-describedby'), $trigger.attr('id'), 'tooltip id and aria-describedby on trigger match')
|
||||
assert.ok($trigger[0].hasAttribute('aria-describedby'), 'trigger has aria-describedby')
|
||||
})
|
||||
|
||||
test('should remove aria-describedby from trigger on hide', function () {
|
||||
test('should remove aria-describedby from trigger on hide', function (assert) {
|
||||
var $trigger = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
|
||||
.bootstrapTooltip()
|
||||
.appendTo('#qunit-fixture')
|
||||
|
||||
$trigger.bootstrapTooltip('show')
|
||||
ok($trigger[0].hasAttribute('aria-describedby'), 'trigger has aria-describedby')
|
||||
assert.ok($trigger[0].hasAttribute('aria-describedby'), 'trigger has aria-describedby')
|
||||
|
||||
$trigger.bootstrapTooltip('hide')
|
||||
ok(!$trigger[0].hasAttribute('aria-describedby'), 'trigger does not have aria-describedby')
|
||||
assert.ok(!$trigger[0].hasAttribute('aria-describedby'), 'trigger does not have aria-describedby')
|
||||
})
|
||||
|
||||
test('should assign a unique id tooltip element', function () {
|
||||
test('should assign a unique id tooltip element', function (assert) {
|
||||
$('<a href="#" rel="tooltip" title="Another tooltip"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapTooltip('show')
|
||||
|
||||
var id = $('.tooltip').attr('id')
|
||||
|
||||
strictEqual($('#' + id).length, 1, 'tooltip has unique id')
|
||||
strictEqual(id.indexOf('tooltip'), 0, 'tooltip id has prefix')
|
||||
assert.strictEqual($('#' + id).length, 1, 'tooltip has unique id')
|
||||
assert.strictEqual(id.indexOf('tooltip'), 0, 'tooltip id has prefix')
|
||||
})
|
||||
|
||||
test('should place tooltips relative to placement option', function () {
|
||||
test('should place tooltips relative to placement option', function (assert) {
|
||||
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapTooltip({ placement: 'bottom' })
|
||||
|
||||
$tooltip.bootstrapTooltip('show')
|
||||
ok($('.tooltip').is('.fade.bottom.in'), 'has correct classes applied')
|
||||
assert.ok($('.tooltip').is('.fade.bottom.in'), 'has correct classes applied')
|
||||
|
||||
$tooltip.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed')
|
||||
})
|
||||
|
||||
test('should allow html entities', function () {
|
||||
test('should allow html entities', function (assert) {
|
||||
var $tooltip = $('<a href="#" rel="tooltip" title="<b>@fat</b>"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapTooltip({ html: true })
|
||||
|
||||
$tooltip.bootstrapTooltip('show')
|
||||
notEqual($('.tooltip b').length, 0, 'b tag was inserted')
|
||||
assert.notEqual($('.tooltip b').length, 0, 'b tag was inserted')
|
||||
|
||||
$tooltip.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed')
|
||||
})
|
||||
|
||||
test('should respect custom classes', function () {
|
||||
test('should respect custom classes', function (assert) {
|
||||
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')
|
||||
ok($('.tooltip').hasClass('some-class'), 'custom class is present')
|
||||
assert.ok($('.tooltip').hasClass('some-class'), 'custom class is present')
|
||||
|
||||
$tooltip.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed')
|
||||
})
|
||||
|
||||
test('should fire show event', function (assert) {
|
||||
@ -120,7 +120,7 @@ $(function () {
|
||||
|
||||
$('<div title="tooltip title"/>')
|
||||
.on('show.bs.tooltip', function () {
|
||||
ok(true, 'show event fired')
|
||||
assert.ok(true, 'show event fired')
|
||||
done()
|
||||
})
|
||||
.bootstrapTooltip('show')
|
||||
@ -132,7 +132,7 @@ $(function () {
|
||||
$('<div title="tooltip title"></div>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.on('shown.bs.tooltip', function () {
|
||||
ok(true, 'shown was called')
|
||||
assert.ok(true, 'shown was called')
|
||||
done()
|
||||
})
|
||||
.bootstrapTooltip('show')
|
||||
@ -144,11 +144,11 @@ $(function () {
|
||||
$('<div title="tooltip title"/>')
|
||||
.on('show.bs.tooltip', function (e) {
|
||||
e.preventDefault()
|
||||
ok(true, 'show event fired')
|
||||
assert.ok(true, 'show event fired')
|
||||
done()
|
||||
})
|
||||
.on('shown.bs.tooltip', function () {
|
||||
ok(false, 'shown event fired')
|
||||
assert.ok(false, 'shown event fired')
|
||||
})
|
||||
.bootstrapTooltip('show')
|
||||
})
|
||||
@ -162,7 +162,7 @@ $(function () {
|
||||
$(this).bootstrapTooltip('hide')
|
||||
})
|
||||
.on('hide.bs.tooltip', function () {
|
||||
ok(true, 'hide event fired')
|
||||
assert.ok(true, 'hide event fired')
|
||||
done()
|
||||
})
|
||||
.bootstrapTooltip('show')
|
||||
@ -177,7 +177,7 @@ $(function () {
|
||||
$(this).bootstrapTooltip('hide')
|
||||
})
|
||||
.on('hidden.bs.tooltip', function () {
|
||||
ok(true, 'hidden event fired')
|
||||
assert.ok(true, 'hidden event fired')
|
||||
done()
|
||||
})
|
||||
.bootstrapTooltip('show')
|
||||
@ -193,34 +193,34 @@ $(function () {
|
||||
})
|
||||
.on('hide.bs.tooltip', function (e) {
|
||||
e.preventDefault()
|
||||
ok(true, 'hide event fired')
|
||||
assert.ok(true, 'hide event fired')
|
||||
done()
|
||||
})
|
||||
.on('hidden.bs.tooltip', function () {
|
||||
ok(false, 'hidden event fired')
|
||||
assert.ok(false, 'hidden event fired')
|
||||
})
|
||||
.bootstrapTooltip('show')
|
||||
})
|
||||
|
||||
test('should destroy tooltip', function () {
|
||||
test('should destroy tooltip', function (assert) {
|
||||
var $tooltip = $('<div/>')
|
||||
.bootstrapTooltip()
|
||||
.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 events')
|
||||
equal($._data($tooltip[0], 'events').click[0].namespace, 'foo', 'tooltip has extra click.foo event')
|
||||
assert.ok($tooltip.data('bs.tooltip'), 'tooltip has data')
|
||||
assert.ok($._data($tooltip[0], 'events').mouseover && $._data($tooltip[0], 'events').mouseout, 'tooltip has hover events')
|
||||
assert.equal($._data($tooltip[0], 'events').click[0].namespace, 'foo', 'tooltip has extra click.foo event')
|
||||
|
||||
$tooltip.bootstrapTooltip('show')
|
||||
$tooltip.bootstrapTooltip('destroy')
|
||||
|
||||
ok(!$tooltip.hasClass('in'), 'tooltip is hidden')
|
||||
ok(!$._data($tooltip[0], 'bs.tooltip'), 'tooltip does not have data')
|
||||
equal($._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 hover events')
|
||||
assert.ok(!$tooltip.hasClass('in'), 'tooltip is hidden')
|
||||
assert.ok(!$._data($tooltip[0], 'bs.tooltip'), 'tooltip does not have data')
|
||||
assert.equal($._data($tooltip[0], 'events').click[0].namespace, 'foo', 'tooltip still has click.foo')
|
||||
assert.ok(!$._data($tooltip[0], 'events').mouseover && !$._data($tooltip[0], 'events').mouseout, 'tooltip does not have hover events')
|
||||
})
|
||||
|
||||
test('should show tooltip with delegate selector on click', function () {
|
||||
test('should show tooltip with delegate selector on click', function (assert) {
|
||||
var $div = $('<div><a href="#" rel="tooltip" title="Another tooltip"/></div>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapTooltip({
|
||||
@ -229,45 +229,45 @@ $(function () {
|
||||
})
|
||||
|
||||
$div.find('a').click()
|
||||
ok($('.tooltip').is('.fade.in'), 'tooltip is faded in')
|
||||
assert.ok($('.tooltip').is('.fade.in'), 'tooltip is faded in')
|
||||
|
||||
$div.find('a').click()
|
||||
equal($('.tooltip').length, 0, 'tooltip was removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip was removed from dom')
|
||||
})
|
||||
|
||||
test('should show tooltip when toggle is called', function () {
|
||||
test('should show tooltip when toggle is called', function (assert) {
|
||||
$('<a href="#" rel="tooltip" title="tooltip on toggle"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapTooltip({ trigger: 'manual' })
|
||||
.bootstrapTooltip('toggle')
|
||||
|
||||
ok($('.tooltip').is('.fade.in'), 'tooltip is faded in')
|
||||
assert.ok($('.tooltip').is('.fade.in'), 'tooltip is faded in')
|
||||
})
|
||||
|
||||
test('should hide previously shown tooltip when toggle is called on tooltip', function () {
|
||||
test('should hide previously shown tooltip when toggle is called on tooltip', function (assert) {
|
||||
$('<a href="#" rel="tooltip" title="tooltip on toggle">@ResentedHook</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapTooltip({ trigger: 'manual' })
|
||||
.bootstrapTooltip('show')
|
||||
|
||||
$('.tooltip').bootstrapTooltip('toggle')
|
||||
ok($('.tooltip').not('.fade.in'), 'tooltip was faded out')
|
||||
assert.ok($('.tooltip').not('.fade.in'), 'tooltip was faded out')
|
||||
})
|
||||
|
||||
test('should place tooltips inside body when container is body', function () {
|
||||
test('should place tooltips inside body when container is body', function (assert) {
|
||||
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapTooltip({ container: 'body' })
|
||||
.bootstrapTooltip('show')
|
||||
|
||||
notEqual($('body > .tooltip').length, 0, 'tooltip is direct descendant of body')
|
||||
equal($('#qunit-fixture > .tooltip').length, 0, 'tooltip is not in parent')
|
||||
assert.notEqual($('body > .tooltip').length, 0, 'tooltip is direct descendant of body')
|
||||
assert.equal($('#qunit-fixture > .tooltip').length, 0, 'tooltip is not in parent')
|
||||
|
||||
$tooltip.bootstrapTooltip('hide')
|
||||
equal($('body > .tooltip').length, 0, 'tooltip was removed from dom')
|
||||
assert.equal($('body > .tooltip').length, 0, 'tooltip was removed from dom')
|
||||
})
|
||||
|
||||
test('should add position class before positioning so that position-specific styles are taken into account', function () {
|
||||
test('should add position class before positioning so that position-specific styles are taken into account', function (assert) {
|
||||
var styles = '<style>'
|
||||
+ '.tooltip.right { white-space: nowrap; }'
|
||||
+ '.tooltip.right .tooltip-inner { max-width: none; }'
|
||||
@ -288,26 +288,26 @@ $(function () {
|
||||
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)
|
||||
assert.ok(topDiff <= 1 && topDiff >= -1)
|
||||
$target.bootstrapTooltip('hide')
|
||||
|
||||
$container.remove()
|
||||
$styles.remove()
|
||||
})
|
||||
|
||||
test('should use title attribute for tooltip text', function () {
|
||||
test('should use title attribute for tooltip text', function (assert) {
|
||||
var $tooltip = $('<a href="#" rel="tooltip" title="Simple tooltip"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapTooltip()
|
||||
|
||||
$tooltip.bootstrapTooltip('show')
|
||||
equal($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title from title attribute is set')
|
||||
assert.equal($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title from title attribute is set')
|
||||
|
||||
$tooltip.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
})
|
||||
|
||||
test('should prefer title attribute over title option', function () {
|
||||
test('should prefer title attribute over title option', function (assert) {
|
||||
var $tooltip = $('<a href="#" rel="tooltip" title="Simple tooltip"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapTooltip({
|
||||
@ -315,13 +315,13 @@ $(function () {
|
||||
})
|
||||
|
||||
$tooltip.bootstrapTooltip('show')
|
||||
equal($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title is set from title attribute while preferred over title option')
|
||||
assert.equal($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title is set from title attribute while preferred over title option')
|
||||
|
||||
$tooltip.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
})
|
||||
|
||||
test('should use title option', function () {
|
||||
test('should use title option', function (assert) {
|
||||
var $tooltip = $('<a href="#" rel="tooltip"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapTooltip({
|
||||
@ -329,13 +329,13 @@ $(function () {
|
||||
})
|
||||
|
||||
$tooltip.bootstrapTooltip('show')
|
||||
equal($('.tooltip').children('.tooltip-inner').text(), 'This is a tooltip with some content', 'title from title option is set')
|
||||
assert.equal($('.tooltip').children('.tooltip-inner').text(), 'This is a tooltip with some content', 'title from title option is set')
|
||||
|
||||
$tooltip.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
})
|
||||
|
||||
test('should be placed dynamically with the dynamic placement option', function () {
|
||||
test('should be placed dynamically with the dynamic placement option', function (assert) {
|
||||
var $style = $('<style> a[rel="tooltip"] { display: inline-block; position: absolute; } </style>')
|
||||
var $container = $('<div/>')
|
||||
.css({
|
||||
@ -353,36 +353,36 @@ $(function () {
|
||||
.bootstrapTooltip({ placement: 'auto' })
|
||||
|
||||
$topTooltip.bootstrapTooltip('show')
|
||||
ok($('.tooltip').is('.bottom'), 'top positioned tooltip is dynamically positioned to bottom')
|
||||
assert.ok($('.tooltip').is('.bottom'), 'top positioned tooltip is dynamically positioned to bottom')
|
||||
|
||||
$topTooltip.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'top positioned tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'top positioned tooltip removed from dom')
|
||||
|
||||
var $rightTooltip = $('<div style="right: 0;" rel="tooltip" title="Right tooltip">Right Dynamic Tooltip</div>')
|
||||
.appendTo($container)
|
||||
.bootstrapTooltip({ placement: 'right auto' })
|
||||
|
||||
$rightTooltip.bootstrapTooltip('show')
|
||||
ok($('.tooltip').is('.left'), 'right positioned tooltip is dynamically positioned left')
|
||||
assert.ok($('.tooltip').is('.left'), 'right positioned tooltip is dynamically positioned left')
|
||||
|
||||
$rightTooltip.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'right positioned tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'right positioned tooltip removed from dom')
|
||||
|
||||
var $leftTooltip = $('<div style="left: 0;" rel="tooltip" title="Left tooltip">Left Dynamic Tooltip</div>')
|
||||
.appendTo($container)
|
||||
.bootstrapTooltip({ placement: 'auto left' })
|
||||
|
||||
$leftTooltip.bootstrapTooltip('show')
|
||||
ok($('.tooltip').is('.right'), 'left positioned tooltip is dynamically positioned right')
|
||||
assert.ok($('.tooltip').is('.right'), 'left positioned tooltip is dynamically positioned right')
|
||||
|
||||
$leftTooltip.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'left positioned tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'left positioned tooltip removed from dom')
|
||||
|
||||
$container.remove()
|
||||
$style.remove()
|
||||
})
|
||||
|
||||
test('should position tip on top if viewport has enough space and placement is "auto top"', function () {
|
||||
test('should position tip on top if viewport has enough space and placement is "auto top"', function (assert) {
|
||||
var styles = '<style>'
|
||||
+ 'body { padding-top: 100px; }'
|
||||
+ '#section { height: 300px; border: 1px solid red; padding-top: 50px }'
|
||||
@ -399,15 +399,15 @@ $(function () {
|
||||
})
|
||||
|
||||
$target.bootstrapTooltip('show')
|
||||
ok($('.tooltip').is('.top'), 'top positioned tooltip is dynamically positioned to top')
|
||||
assert.ok($('.tooltip').is('.top'), 'top positioned tooltip is dynamically positioned to top')
|
||||
|
||||
$target.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
|
||||
$styles.remove()
|
||||
})
|
||||
|
||||
test('should position tip on bottom if the tip\'s dimension exceeds the viewport area and placement is "auto top"', function () {
|
||||
test('should position tip on bottom if the tip\'s dimension exceeds the viewport area and placement is "auto top"', function (assert) {
|
||||
var styles = '<style>'
|
||||
+ 'body { padding-top: 100px; }'
|
||||
+ '#section { height: 300px; border: 1px solid red; }'
|
||||
@ -424,15 +424,15 @@ $(function () {
|
||||
})
|
||||
|
||||
$target.bootstrapTooltip('show')
|
||||
ok($('.tooltip').is('.bottom'), 'top positioned tooltip is dynamically positioned to bottom')
|
||||
assert.ok($('.tooltip').is('.bottom'), 'top positioned tooltip is dynamically positioned to bottom')
|
||||
|
||||
$target.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
|
||||
$styles.remove()
|
||||
})
|
||||
|
||||
test('should display the tip on top whenever scrollable viewport has enough room if the given placement is "auto top"', function () {
|
||||
test('should display the tip on top whenever scrollable viewport has enough room if the given placement is "auto top"', function (assert) {
|
||||
var styles = '<style>'
|
||||
+ '#scrollable-div { height: 200px; overflow: auto; }'
|
||||
+ '.tooltip-item { margin: 200px 0 400px; width: 150px; }'
|
||||
@ -450,15 +450,15 @@ $(function () {
|
||||
$('#scrollable-div').scrollTop(100)
|
||||
|
||||
$target.bootstrapTooltip('show')
|
||||
ok($('.tooltip').is('.fade.top.in'), 'has correct classes applied')
|
||||
assert.ok($('.tooltip').is('.fade.top.in'), 'has correct classes applied')
|
||||
|
||||
$target.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
|
||||
$styles.remove()
|
||||
})
|
||||
|
||||
test('should display the tip on bottom whenever scrollable viewport doesn\'t have enough room if the given placement is "auto top"', function () {
|
||||
test('should display the tip on bottom whenever scrollable viewport doesn\'t have enough room if the given placement is "auto top"', function (assert) {
|
||||
var styles = '<style>'
|
||||
+ '#scrollable-div { height: 200px; overflow: auto; }'
|
||||
+ '.tooltip-item { padding: 200px 0 400px; width: 150px; }'
|
||||
@ -476,15 +476,15 @@ $(function () {
|
||||
$('#scrollable-div').scrollTop(200)
|
||||
|
||||
$target.bootstrapTooltip('show')
|
||||
ok($('.tooltip').is('.fade.bottom.in'), 'has correct classes applied')
|
||||
assert.ok($('.tooltip').is('.fade.bottom.in'), 'has correct classes applied')
|
||||
|
||||
$target.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
|
||||
$styles.remove()
|
||||
})
|
||||
|
||||
test('should display the tip on bottom whenever scrollable viewport has enough room if the given placement is "auto bottom"', function () {
|
||||
test('should display the tip on bottom whenever scrollable viewport has enough room if the given placement is "auto bottom"', function (assert) {
|
||||
var styles = '<style>'
|
||||
+ '#scrollable-div { height: 200px; overflow: auto; }'
|
||||
+ '.spacer { height: 400px; }'
|
||||
@ -506,15 +506,15 @@ $(function () {
|
||||
$('#scrollable-div').scrollTop(200)
|
||||
|
||||
$target.bootstrapTooltip('show')
|
||||
ok($('.tooltip').is('.fade.bottom.in'), 'has correct classes applied')
|
||||
assert.ok($('.tooltip').is('.fade.bottom.in'), 'has correct classes applied')
|
||||
|
||||
$target.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
|
||||
$styles.remove()
|
||||
})
|
||||
|
||||
test('should display the tip on top whenever scrollable viewport doesn\'t have enough room if the given placement is "auto bottom"', function () {
|
||||
test('should display the tip on top whenever scrollable viewport doesn\'t have enough room if the given placement is "auto bottom"', function (assert) {
|
||||
var styles = '<style>'
|
||||
+ '#scrollable-div { height: 200px; overflow: auto; }'
|
||||
+ '.tooltip-item { margin-top: 400px; width: 150px; }'
|
||||
@ -532,15 +532,15 @@ $(function () {
|
||||
$('#scrollable-div').scrollTop(400)
|
||||
|
||||
$target.bootstrapTooltip('show')
|
||||
ok($('.tooltip').is('.fade.top.in'), 'has correct classes applied')
|
||||
assert.ok($('.tooltip').is('.fade.top.in'), 'has correct classes applied')
|
||||
|
||||
$target.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
|
||||
$styles.remove()
|
||||
})
|
||||
|
||||
test('should adjust the tip\'s top position when up against the top of the viewport', function () {
|
||||
test('should adjust the tip\'s top position when up against the top of the viewport', function (assert) {
|
||||
var styles = '<style>'
|
||||
+ '.tooltip .tooltip-inner { width: 200px; height: 200px; max-width: none; }'
|
||||
+ 'a[rel="tooltip"] { position: fixed; }'
|
||||
@ -559,15 +559,15 @@ $(function () {
|
||||
})
|
||||
|
||||
$target.bootstrapTooltip('show')
|
||||
equal(Math.round($container.find('.tooltip').offset().top), 12)
|
||||
assert.equal(Math.round($container.find('.tooltip').offset().top), 12)
|
||||
|
||||
$target.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
|
||||
$styles.remove()
|
||||
})
|
||||
|
||||
test('should adjust the tip\'s top position when up against the bottom of the viewport', function () {
|
||||
test('should adjust the tip\'s top position when up against the bottom of the viewport', function (assert) {
|
||||
var styles = '<style>'
|
||||
+ '.tooltip .tooltip-inner { width: 200px; height: 200px; max-width: none; }'
|
||||
+ 'a[rel="tooltip"] { position: fixed; }'
|
||||
@ -587,16 +587,16 @@ $(function () {
|
||||
|
||||
$target.bootstrapTooltip('show')
|
||||
var $tooltip = $container.find('.tooltip')
|
||||
strictEqual(Math.round($tooltip.offset().top), Math.round($(window).height() - 12 - $tooltip[0].offsetHeight))
|
||||
assert.strictEqual(Math.round($tooltip.offset().top), Math.round($(window).height() - 12 - $tooltip[0].offsetHeight))
|
||||
|
||||
$target.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
|
||||
$container.remove()
|
||||
$styles.remove()
|
||||
})
|
||||
|
||||
test('should adjust the tip\'s left position when up against the left of the viewport', function () {
|
||||
test('should adjust the tip\'s left position when up against the left of the viewport', function (assert) {
|
||||
var styles = '<style>'
|
||||
+ '.tooltip .tooltip-inner { width: 200px; height: 200px; max-width: none; }'
|
||||
+ 'a[rel="tooltip"] { position: fixed; }'
|
||||
@ -615,16 +615,16 @@ $(function () {
|
||||
})
|
||||
|
||||
$target.bootstrapTooltip('show')
|
||||
strictEqual(Math.round($container.find('.tooltip').offset().left), 12)
|
||||
assert.strictEqual(Math.round($container.find('.tooltip').offset().left), 12)
|
||||
|
||||
$target.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
|
||||
$container.remove()
|
||||
$styles.remove()
|
||||
})
|
||||
|
||||
test('should adjust the tip\'s left position when up against the right of the viewport', function () {
|
||||
test('should adjust the tip\'s left position when up against the right of the viewport', function (assert) {
|
||||
var styles = '<style>'
|
||||
+ '.tooltip .tooltip-inner { width: 200px; height: 200px; max-width: none; }'
|
||||
+ 'a[rel="tooltip"] { position: fixed; }'
|
||||
@ -644,16 +644,16 @@ $(function () {
|
||||
|
||||
$target.bootstrapTooltip('show')
|
||||
var $tooltip = $container.find('.tooltip')
|
||||
strictEqual(Math.round($tooltip.offset().left), Math.round($(window).width() - 12 - $tooltip[0].offsetWidth))
|
||||
assert.strictEqual(Math.round($tooltip.offset().left), Math.round($(window).width() - 12 - $tooltip[0].offsetWidth))
|
||||
|
||||
$target.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
|
||||
$container.remove()
|
||||
$styles.remove()
|
||||
})
|
||||
|
||||
test('should adjust the tip when up against the right of an arbitrary viewport', function () {
|
||||
test('should adjust the tip when up against the right of an arbitrary viewport', function (assert) {
|
||||
var styles = '<style>'
|
||||
+ '.tooltip, .tooltip .tooltip-inner { width: 200px; height: 200px; max-width: none; }'
|
||||
+ '.container-viewport { position: absolute; top: 50px; left: 60px; width: 300px; height: 300px; }'
|
||||
@ -671,16 +671,16 @@ $(function () {
|
||||
|
||||
$target.bootstrapTooltip('show')
|
||||
var $tooltip = $container.find('.tooltip')
|
||||
strictEqual(Math.round($tooltip.offset().left), Math.round(60 + $container.width() - $tooltip[0].offsetWidth))
|
||||
assert.strictEqual(Math.round($tooltip.offset().left), Math.round(60 + $container.width() - $tooltip[0].offsetWidth))
|
||||
|
||||
$target.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
|
||||
$container.remove()
|
||||
$styles.remove()
|
||||
})
|
||||
|
||||
test('should not error when trying to show an auto-placed tooltip that has been removed from the dom', function () {
|
||||
test('should not error when trying to show an auto-placed tooltip that has been removed from the dom', function (assert) {
|
||||
var passed = true
|
||||
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
@ -696,7 +696,7 @@ $(function () {
|
||||
console.log(err)
|
||||
}
|
||||
|
||||
ok(passed, '.tooltip(\'show\') should not throw an error if element no longer is in dom')
|
||||
assert.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 (assert) {
|
||||
@ -731,7 +731,7 @@ $(function () {
|
||||
var $tooltip = $container.find('.tooltip')
|
||||
|
||||
setTimeout(function () {
|
||||
ok(Math.round($tooltip.offset().top + $tooltip.outerHeight()) <= Math.round($trigger.offset().top))
|
||||
assert.ok(Math.round($tooltip.offset().top + $tooltip.outerHeight()) <= Math.round($trigger.offset().top))
|
||||
done()
|
||||
}, 0)
|
||||
})
|
||||
@ -762,7 +762,7 @@ $(function () {
|
||||
.bootstrapTooltip('show')
|
||||
|
||||
setTimeout(function () {
|
||||
ok($('.tooltip').offset().left >= 0)
|
||||
assert.ok($('.tooltip').offset().left >= 0)
|
||||
done()
|
||||
}, 0)
|
||||
})
|
||||
@ -775,11 +775,11 @@ $(function () {
|
||||
.bootstrapTooltip({ delay: 150 })
|
||||
|
||||
setTimeout(function () {
|
||||
ok(!$('.tooltip').is('.fade.in'), '100ms: tooltip is not faded in')
|
||||
assert.ok(!$('.tooltip').is('.fade.in'), '100ms: tooltip is not faded in')
|
||||
}, 100)
|
||||
|
||||
setTimeout(function () {
|
||||
ok($('.tooltip').is('.fade.in'), '200ms: tooltip is faded in')
|
||||
assert.ok($('.tooltip').is('.fade.in'), '200ms: tooltip is faded in')
|
||||
done()
|
||||
}, 200)
|
||||
|
||||
@ -794,12 +794,12 @@ $(function () {
|
||||
.bootstrapTooltip({ delay: 150 })
|
||||
|
||||
setTimeout(function () {
|
||||
ok(!$('.tooltip').is('.fade.in'), '100ms: tooltip not faded in')
|
||||
assert.ok(!$('.tooltip').is('.fade.in'), '100ms: tooltip not faded in')
|
||||
$tooltip.trigger('mouseout')
|
||||
}, 100)
|
||||
|
||||
setTimeout(function () {
|
||||
ok(!$('.tooltip').is('.fade.in'), '200ms: tooltip not faded in')
|
||||
assert.ok(!$('.tooltip').is('.fade.in'), '200ms: tooltip not faded in')
|
||||
done()
|
||||
}, 200)
|
||||
|
||||
@ -814,16 +814,16 @@ $(function () {
|
||||
.bootstrapTooltip({ delay: { show: 0, hide: 150 }})
|
||||
|
||||
setTimeout(function () {
|
||||
ok($('.tooltip').is('.fade.in'), '1ms: tooltip faded in')
|
||||
assert.ok($('.tooltip').is('.fade.in'), '1ms: tooltip faded in')
|
||||
$tooltip.trigger('mouseout')
|
||||
|
||||
setTimeout(function () {
|
||||
ok($('.tooltip').is('.fade.in'), '100ms: tooltip still faded in')
|
||||
assert.ok($('.tooltip').is('.fade.in'), '100ms: tooltip still faded in')
|
||||
$tooltip.trigger('mouseenter')
|
||||
}, 100)
|
||||
|
||||
setTimeout(function () {
|
||||
ok($('.tooltip').is('.fade.in'), '200ms: tooltip still faded in')
|
||||
assert.ok($('.tooltip').is('.fade.in'), '200ms: tooltip still faded in')
|
||||
done()
|
||||
}, 200)
|
||||
}, 0)
|
||||
@ -839,12 +839,12 @@ $(function () {
|
||||
.bootstrapTooltip({ delay: 150 })
|
||||
|
||||
setTimeout(function () {
|
||||
ok(!$('.tooltip').is('.fade.in'), '100ms: tooltip not faded in')
|
||||
assert.ok(!$('.tooltip').is('.fade.in'), '100ms: tooltip not faded in')
|
||||
$tooltip.trigger('mouseout')
|
||||
}, 100)
|
||||
|
||||
setTimeout(function () {
|
||||
ok(!$('.tooltip').is('.fade.in'), '200ms: tooltip not faded in')
|
||||
assert.ok(!$('.tooltip').is('.fade.in'), '200ms: tooltip not faded in')
|
||||
done()
|
||||
}, 200)
|
||||
|
||||
@ -859,12 +859,12 @@ $(function () {
|
||||
.bootstrapTooltip({ delay: { show: 150, hide: 0 }})
|
||||
|
||||
setTimeout(function () {
|
||||
ok(!$('.tooltip').is('.fade.in'), '100ms: tooltip not faded in')
|
||||
assert.ok(!$('.tooltip').is('.fade.in'), '100ms: tooltip not faded in')
|
||||
$tooltip.trigger('mouseout')
|
||||
}, 100)
|
||||
|
||||
setTimeout(function () {
|
||||
ok(!$('.tooltip').is('.fade.in'), '250ms: tooltip not faded in')
|
||||
assert.ok(!$('.tooltip').is('.fade.in'), '250ms: tooltip not faded in')
|
||||
done()
|
||||
}, 250)
|
||||
|
||||
@ -879,16 +879,16 @@ $(function () {
|
||||
.bootstrapTooltip({ delay: { show: 0, hide: 150 }})
|
||||
|
||||
setTimeout(function () {
|
||||
ok($tooltip.data('bs.tooltip').$tip.is('.fade.in'), '1ms: tooltip faded in')
|
||||
assert.ok($tooltip.data('bs.tooltip').$tip.is('.fade.in'), '1ms: tooltip faded in')
|
||||
|
||||
$tooltip.trigger('mouseout')
|
||||
|
||||
setTimeout(function () {
|
||||
ok($tooltip.data('bs.tooltip').$tip.is('.fade.in'), '100ms: tooltip still faded in')
|
||||
assert.ok($tooltip.data('bs.tooltip').$tip.is('.fade.in'), '100ms: tooltip still faded in')
|
||||
}, 100)
|
||||
|
||||
setTimeout(function () {
|
||||
ok(!$tooltip.data('bs.tooltip').$tip.is('.in'), '200ms: tooltip removed')
|
||||
assert.ok(!$tooltip.data('bs.tooltip').$tip.is('.in'), '200ms: tooltip removed')
|
||||
done()
|
||||
}, 200)
|
||||
|
||||
@ -900,7 +900,7 @@ $(function () {
|
||||
test('should correctly position tooltips on SVG elements', function (assert) {
|
||||
if (!window.SVGElement) {
|
||||
// Skip IE8 since it doesn't support SVG
|
||||
expect(0)
|
||||
assert.expect(0)
|
||||
return
|
||||
}
|
||||
|
||||
@ -925,9 +925,9 @@ $(function () {
|
||||
.on('shown.bs.tooltip', function () {
|
||||
var offset = $('.tooltip').offset()
|
||||
$styles.remove()
|
||||
ok(Math.abs(offset.left - 88) <= 1, 'tooltip has correct horizontal location')
|
||||
assert.ok(Math.abs(offset.left - 88) <= 1, 'tooltip has correct horizontal location')
|
||||
$circle.bootstrapTooltip('hide')
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
done()
|
||||
})
|
||||
.bootstrapTooltip({ container: 'body', placement: 'top', trigger: 'manual' })
|
||||
@ -958,13 +958,13 @@ $(function () {
|
||||
var $tip = $('.tooltip-inner')
|
||||
var tipXrightEdge = $tip.offset().left + $tip.width()
|
||||
var triggerXleftEdge = $trigger.offset().left
|
||||
ok(tipXrightEdge < triggerXleftEdge, 'tooltip with auto left placement, when near the right edge of the viewport, gets left placement')
|
||||
assert.ok(tipXrightEdge < triggerXleftEdge, 'tooltip with auto left placement, when near the right edge of the viewport, gets left placement')
|
||||
$trigger.bootstrapTooltip('hide')
|
||||
})
|
||||
.on('hidden.bs.tooltip', function () {
|
||||
$styles.remove()
|
||||
$(this).remove()
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
done()
|
||||
})
|
||||
.bootstrapTooltip({
|
||||
@ -976,7 +976,7 @@ $(function () {
|
||||
$trigger.bootstrapTooltip('show')
|
||||
})
|
||||
|
||||
test('should not reload the tooltip on subsequent mouseenter events', function () {
|
||||
test('should not reload the tooltip on subsequent mouseenter events', function (assert) {
|
||||
var titleHtml = function () {
|
||||
var uid = $.fn.bootstrapTooltip.Constructor.prototype.getUID('tooltip')
|
||||
return '<p id="tt-content">' + uid + '</p><p>' + uid + '</p><p>' + uid + '</p>'
|
||||
@ -999,10 +999,10 @@ $(function () {
|
||||
var currentUid = $('#tt-content').text()
|
||||
|
||||
$('#tt-content').trigger('mouseenter')
|
||||
equal(currentUid, $('#tt-content').text())
|
||||
assert.equal(currentUid, $('#tt-content').text())
|
||||
})
|
||||
|
||||
test('should not reload the tooltip if the mouse leaves and re-enters before hiding', function () {
|
||||
test('should not reload the tooltip if the mouse leaves and re-enters before hiding', function (assert) {
|
||||
var titleHtml = function () {
|
||||
var uid = $.fn.bootstrapTooltip.Constructor.prototype.getUID('tooltip')
|
||||
return '<p id="tt-content">' + uid + '</p><p>' + uid + '</p><p>' + uid + '</p>'
|
||||
@ -1027,14 +1027,14 @@ $(function () {
|
||||
var currentUid = $('#tt-content').text()
|
||||
|
||||
$('#tt-outer').trigger('mouseleave')
|
||||
equal(currentUid, $('#tt-content').text())
|
||||
assert.equal(currentUid, $('#tt-content').text())
|
||||
|
||||
ok(obj.hoverState == 'out', 'the tooltip hoverState should be set to "out"')
|
||||
assert.ok(obj.hoverState == 'out', 'the tooltip hoverState should be set to "out"')
|
||||
|
||||
$('#tt-content').trigger('mouseenter')
|
||||
ok(obj.hoverState == 'in', 'the tooltip hoverState should be set to "in"')
|
||||
assert.ok(obj.hoverState == 'in', 'the tooltip hoverState should be set to "in"')
|
||||
|
||||
equal(currentUid, $('#tt-content').text())
|
||||
assert.equal(currentUid, $('#tt-content').text())
|
||||
})
|
||||
|
||||
test('should position arrow correctly when tooltip is moved to not appear offscreen', function (assert) {
|
||||
@ -1052,13 +1052,13 @@ $(function () {
|
||||
.appendTo('body')
|
||||
.on('shown.bs.tooltip', function () {
|
||||
var arrowStyles = $(this).data('bs.tooltip').$tip.find('.tooltip-arrow').attr('style')
|
||||
ok(/left/i.test(arrowStyles) && !/top/i.test(arrowStyles), 'arrow positioned correctly')
|
||||
assert.ok(/left/i.test(arrowStyles) && !/top/i.test(arrowStyles), 'arrow positioned correctly')
|
||||
$(this).bootstrapTooltip('hide')
|
||||
})
|
||||
.on('hidden.bs.tooltip', function () {
|
||||
$styles.remove()
|
||||
$(this).remove()
|
||||
equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
assert.equal($('.tooltip').length, 0, 'tooltip removed from dom')
|
||||
done()
|
||||
})
|
||||
.bootstrapTooltip({
|
||||
@ -1072,7 +1072,7 @@ $(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)
|
||||
assert.expect(0)
|
||||
return
|
||||
}
|
||||
|
||||
@ -1093,8 +1093,8 @@ $(function () {
|
||||
.on('shown.bs.tooltip', function () {
|
||||
var offset = $('.tooltip').offset()
|
||||
$styles.remove()
|
||||
ok(Math.abs(offset.left - 88) <= 1, 'tooltip has correct horizontal location')
|
||||
ok(Math.abs(offset.top - 126) <= 1, 'tooltip has correct vertical location')
|
||||
assert.ok(Math.abs(offset.left - 88) <= 1, 'tooltip has correct horizontal location')
|
||||
assert.ok(Math.abs(offset.top - 126) <= 1, 'tooltip has correct vertical location')
|
||||
$element.bootstrapTooltip('hide')
|
||||
done()
|
||||
})
|
||||
@ -1107,8 +1107,8 @@ $(function () {
|
||||
$element.bootstrapTooltip('show')
|
||||
})
|
||||
|
||||
test('should throw an error when initializing tooltip on the document object without specifying a delegation selector', function () {
|
||||
throws(function () {
|
||||
test('should throw an error when initializing tooltip on the document object without specifying a delegation selector', function (assert) {
|
||||
assert.throws(function () {
|
||||
$(document).bootstrapTooltip({ title: 'What am I on?' })
|
||||
}, new Error('`selector` option must be specified when initializing tooltip on the window.document object!'))
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user