Commit ecd469ec authored by Chris Rebert's avatar Chris Rebert

Merge pull request #15893 from twbs/qunit-modern

Modernize QUnit usage by avoiding usage of global functions
parents feda77f1 9c75c855
$(function () {
'use strict';
module('affix plugin')
QUnit.module('affix plugin')
test('should be defined on jquery object', function () {
ok($(document.body).affix, 'affix method is defined')
QUnit.test('should be defined on jquery object', function (assert) {
assert.ok($(document.body).affix, 'affix method is defined')
})
module('affix', {
QUnit.module('affix', {
setup: function () {
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$.fn.bootstrapAffix = $.fn.affix.noConflict()
......@@ -18,24 +18,24 @@ $(function () {
}
})
test('should provide no conflict', function () {
strictEqual($.fn.affix, undefined, 'affix was set back to undefined (org value)')
QUnit.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 () {
QUnit.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 () {
QUnit.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) {
QUnit.test('should trigger affixed event after affix', function (assert) {
var done = assert.async()
var templateHTML = '<div id="affixTarget">'
......@@ -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()
})
......@@ -69,7 +69,7 @@ $(function () {
}, 0)
})
test('should affix-top when scrolling up to offset when parent has padding', function (assert) {
QUnit.test('should affix-top when scrolling up to offset when parent has padding', function (assert) {
var done = assert.async()
var templateHTML = '<div id="padding-offset" style="padding-top: 20px;">'
......@@ -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()
})
......
$(function () {
'use strict';
module('alert plugin')
QUnit.module('alert plugin')
test('should be defined on jquery object', function () {
ok($(document.body).alert, 'alert method is defined')
QUnit.test('should be defined on jquery object', function (assert) {
assert.ok($(document.body).alert, 'alert method is defined')
})
module('alert', {
QUnit.module('alert', {
setup: function () {
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$.fn.bootstrapAlert = $.fn.alert.noConflict()
......@@ -18,18 +18,18 @@ $(function () {
}
})
test('should provide no conflict', function () {
strictEqual($.fn.alert, undefined, 'alert was set back to undefined (org value)')
QUnit.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 () {
QUnit.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 () {
QUnit.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,33 +38,33 @@ $(function () {
$alert.find('.close').click()
equal($alert.hasClass('in'), false, 'remove .in class on .close click')
assert.strictEqual($alert.hasClass('in'), false, 'remove .in class on .close click')
})
test('should remove element when clicking .close', function () {
QUnit.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.strictEqual($('#qunit-fixture').find('.alert').length, 0, 'element removed from dom')
})
test('should not fire closed when close is prevented', function (assert) {
QUnit.test('should not fire closed when close is prevented', function (assert) {
var done = assert.async()
$('<div class="alert"/>')
.on('close.bs.alert', function (e) {
e.preventDefault()
ok(true, 'close event fired')
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')
})
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
$(function () {
'use strict';
module('dropdowns plugin')
QUnit.module('dropdowns plugin')
test('should be defined on jquery object', function () {
ok($(document.body).dropdown, 'dropdown method is defined')
QUnit.test('should be defined on jquery object', function (assert) {
assert.ok($(document.body).dropdown, 'dropdown method is defined')
})
module('dropdowns', {
QUnit.module('dropdowns', {
setup: function () {
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$.fn.bootstrapDropdown = $.fn.dropdown.noConflict()
......@@ -18,18 +18,18 @@ $(function () {
}
})
test('should provide no conflict', function () {
strictEqual($.fn.dropdown, undefined, 'dropdown was set back to undefined (org value)')
QUnit.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 () {
QUnit.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 () {
QUnit.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 () {
QUnit.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 () {
QUnit.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 () {
QUnit.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 () {
QUnit.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 () {
QUnit.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,22 +142,22 @@ $(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) {
QUnit.test('should fire show and hide event', function (assert) {
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
......@@ -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()
})
......@@ -191,7 +191,7 @@ $(function () {
})
test('should fire shown and hidden event', function (assert) {
QUnit.test('should fire shown and hidden event', function (assert) {
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
......@@ -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()
})
......@@ -224,7 +224,7 @@ $(function () {
$(document.body).click()
})
test('should ignore keyboard events within <input>s and <textarea>s', function (assert) {
QUnit.test('should ignore keyboard events within <input>s and <textarea>s', function (assert) {
var done = assert.async()
var dropdownHTML = '<ul class="tabs">'
......@@ -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()
})
......
This diff is collapsed.
This diff is collapsed.
$(function () {
'use strict';
module('scrollspy plugin')
QUnit.module('scrollspy plugin')
test('should be defined on jquery object', function () {
ok($(document.body).scrollspy, 'scrollspy method is defined')
QUnit.test('should be defined on jquery object', function (assert) {
assert.ok($(document.body).scrollspy, 'scrollspy method is defined')
})
module('scrollspy', {
QUnit.module('scrollspy', {
setup: function () {
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$.fn.bootstrapScrollspy = $.fn.scrollspy.noConflict()
......@@ -18,18 +18,18 @@ $(function () {
}
})
test('should provide no conflict', function () {
strictEqual($.fn.scrollspy, undefined, 'scrollspy was set back to undefined (org value)')
QUnit.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 () {
QUnit.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) {
QUnit.test('should only switch "active" class on current target', function (assert) {
var done = assert.async()
var sectionHTML = '<div id="root" class="active">'
......@@ -66,14 +66,14 @@ $(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()
})
$scrollspy.scrollTop(350)
})
test('should correctly select middle navigation option when large offset is used', function (assert) {
QUnit.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>'
......@@ -97,16 +97,16 @@ $(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()
})
$scrollspy.scrollTop(550)
})
test('should add the active class to the correct element', function (assert) {
QUnit.test('should add the active class to the correct element', function (assert) {
var navbarHtml =
'<nav class="navbar">'
+ '<ul class="nav">'
......@@ -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()
})
......@@ -142,7 +142,7 @@ $(function () {
.then(function () { return testElementIsActiveAfterScroll('#li-2', '#div-2') })
})
test('should clear selection if above the first section', function (assert) {
QUnit.test('should clear selection if above the first section', function (assert) {
var done = assert.async()
var sectionHTML = '<div id="header" style="height: 500px;"></div>'
......@@ -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)
......
$(function () {
'use strict';
module('tabs plugin')
QUnit.module('tabs plugin')
test('should be defined on jquery object', function () {
ok($(document.body).tab, 'tabs method is defined')
QUnit.test('should be defined on jquery object', function (assert) {
assert.ok($(document.body).tab, 'tabs method is defined')
})
module('tabs', {
QUnit.module('tabs', {
setup: function () {
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$.fn.bootstrapTab = $.fn.tab.noConflict()
......@@ -18,18 +18,18 @@ $(function () {
}
})
test('should provide no conflict', function () {
strictEqual($.fn.tab, undefined, 'tab was set back to undefined (org value)')
QUnit.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 () {
QUnit.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 () {
QUnit.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.strictEqual($('#qunit-fixture').find('.active').attr('id'), 'profile')
$(tabsHTML).find('li:first a').bootstrapTab('show')
equal($('#qunit-fixture').find('.active').attr('id'), 'home')
assert.strictEqual($('#qunit-fixture').find('.active').attr('id'), 'home')
})
test('should activate element by tab id', function () {
QUnit.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,28 +53,28 @@ $(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.strictEqual($('#qunit-fixture').find('.active').attr('id'), 'profile')
$(pillsHTML).find('li:first a').bootstrapTab('show')
equal($('#qunit-fixture').find('.active').attr('id'), 'home')
assert.strictEqual($('#qunit-fixture').find('.active').attr('id'), 'home')
})
test('should not fire shown when show is prevented', function (assert) {
QUnit.test('should not fire shown when show is prevented', function (assert) {
var done = assert.async()
$('<div class="tab"/>')
.on('show.bs.tab', function (e) {
e.preventDefault()
ok(true, 'show event fired')
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')
})
test('show and shown events should reference correct relatedTarget', function (assert) {
QUnit.test('show and shown events should reference correct relatedTarget', function (assert) {
var done = assert.async()
var dropHTML = '<ul class="drop">'
......@@ -92,16 +92,16 @@ $(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.strictEqual(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.strictEqual(e.relatedTarget.hash, '#1-1', 'references correct element as relatedTarget')
done()
})
.bootstrapTab('show')
})
test('should fire hide and hidden events', function (assert) {
QUnit.test('should fire hide and hidden events', function (assert) {
var done = assert.async()
var tabsHTML = '<ul class="tabs">'
......@@ -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')
......@@ -131,7 +131,7 @@ $(function () {
.bootstrapTab('show')
})
test('should not fire hidden when hide is prevented', function (assert) {
QUnit.test('should not fire hidden when hide is prevented', function (assert) {
var done = assert.async()
var tabsHTML = '<ul class="tabs">'
......@@ -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()
......@@ -155,7 +155,7 @@ $(function () {
.bootstrapTab('show')
})
test('hide and hidden events contain correct relatedTarget', function (assert) {
QUnit.test('hide and hidden events contain correct relatedTarget', function (assert) {
var done = assert.async()
var tabsHTML = '<ul class="tabs">'
......@@ -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.strictEqual(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.strictEqual(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 () {
QUnit.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.strictEqual($tabs.find('.active a').attr('aria-expanded'), 'true', 'shown tab has aria-expanded = true')
assert.strictEqual($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.strictEqual($tabs.find('.active a').attr('aria-expanded'), 'true', 'after click, shown tab has aria-expanded = true')
assert.strictEqual($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.strictEqual($tabs.find('.active a').attr('aria-expanded'), 'true', 'shown tab has aria-expanded = true')
assert.strictEqual($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.strictEqual($tabs.find('.active a').attr('aria-expanded'), 'true', 'after second show event, shown tab still has aria-expanded = true')
assert.strictEqual($tabs.find('li:not(.active) a').attr('aria-expanded'), 'false', 'after second show event, hidden tab has aria-expanded = false')
})
})
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment