mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-14 18:42:30 +03:00
update JS unit tests to future-proof QUnit 1.16.0 API
[skip validator]
This commit is contained in:
+12
-12
@@ -29,8 +29,8 @@ $(function () {
|
||||
strictEqual($scrollspy[0], $el[0], 'collection contains element')
|
||||
})
|
||||
|
||||
test('should only switch "active" class on current target', function () {
|
||||
stop()
|
||||
test('should only switch "active" class on current target', function (assert) {
|
||||
var done = assert.async()
|
||||
|
||||
var sectionHTML = '<div id="root" class="active">'
|
||||
+ '<div class="topbar">'
|
||||
@@ -67,14 +67,14 @@ $(function () {
|
||||
|
||||
$scrollspy.on('scroll.bs.scrollspy', function () {
|
||||
ok($section.hasClass('active'), '"active" class still on root node')
|
||||
start()
|
||||
done()
|
||||
})
|
||||
|
||||
$scrollspy.scrollTop(350)
|
||||
})
|
||||
|
||||
test('should correctly select middle navigation option when large offset is used', function () {
|
||||
stop()
|
||||
test('should correctly select middle navigation option when large offset is used', function (assert) {
|
||||
var done = assert.async()
|
||||
|
||||
var sectionHTML = '<div id="header" style="height: 500px;"></div>'
|
||||
+ '<nav id="navigation" class="navbar">'
|
||||
@@ -100,13 +100,13 @@ $(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')
|
||||
start()
|
||||
done()
|
||||
})
|
||||
|
||||
$scrollspy.scrollTop(550)
|
||||
})
|
||||
|
||||
test('should add the active class to the correct element', function () {
|
||||
test('should add the active class to the correct element', function (assert) {
|
||||
var navbarHtml =
|
||||
'<nav class="navbar">'
|
||||
+ '<ul class="nav">'
|
||||
@@ -128,10 +128,10 @@ $(function () {
|
||||
var testElementIsActiveAfterScroll = function (element, target) {
|
||||
var deferred = $.Deferred()
|
||||
var scrollHeight = Math.ceil($content.scrollTop() + $(target).position().top)
|
||||
stop()
|
||||
var done = assert.async()
|
||||
$content.one('scroll', function () {
|
||||
ok($(element).hasClass('active'), 'target:' + target + ', element' + element)
|
||||
start()
|
||||
done()
|
||||
deferred.resolve()
|
||||
})
|
||||
$content.scrollTop(scrollHeight)
|
||||
@@ -142,8 +142,8 @@ $(function () {
|
||||
.then(function () { return testElementIsActiveAfterScroll('#li-2', '#div-2') })
|
||||
})
|
||||
|
||||
test('should clear selection if above the first section', function () {
|
||||
stop()
|
||||
test('should clear selection if above the first section', function (assert) {
|
||||
var done = assert.async()
|
||||
|
||||
var sectionHTML = '<div id="header" style="height: 500px;"></div>'
|
||||
+ '<nav id="navigation" class="navbar">'
|
||||
@@ -176,7 +176,7 @@ $(function () {
|
||||
$scrollspy
|
||||
.one('scroll.bs.scrollspy', function () {
|
||||
strictEqual($('.active').length, 0, 'selection cleared')
|
||||
start()
|
||||
done()
|
||||
})
|
||||
.scrollTop(0)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user