diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js
index f21aa98fc3..d747f02988 100644
--- a/js/tests/unit/dropdown.js
+++ b/js/tests/unit/dropdown.js
@@ -19,46 +19,48 @@ $(function () {
})
test('should provide no conflict', function () {
- ok(!$.fn.dropdown, 'dropdown was set back to undefined (org value)')
+ strictEqual($.fn.dropdown, undefined, 'dropdown was set back to undefined (org value)')
})
- test('should return element', function () {
- var el = $('
')
- ok(el.bootstrapDropdown()[0] === el[0], 'same element returned')
+ test('should return jquery collection containing the element', function () {
+ var $el = $('')
+ var $dropdown = $el.bootstrapDropdown()
+ ok($dropdown instanceof $, 'returns jquery collection')
+ strictEqual($dropdown[0], $el[0], 'collection contains element')
})
- test('should not open dropdown if target is disabled', function () {
+ test('should not open dropdown if target is disabled via attribute', function () {
var dropdownHTML = '
'
- var dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
+ var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
- ok(!dropdown.parent('.dropdown').hasClass('open'), 'open class added on click')
+ ok(!$dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
})
- test('should not open dropdown if target is disabled', function () {
+ test('should not open dropdown if target is disabled via class', function () {
var dropdownHTML = '
'
- var dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
+ var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
- ok(!dropdown.parent('.dropdown').hasClass('open'), 'open class added on click')
+ ok(!$dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
})
test('should add class open to menu if clicked', function () {
@@ -68,14 +70,14 @@ $(function () {
'
' +
'' +
''
- var dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
+ var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
- ok(dropdown.parent('.dropdown').hasClass('open'), 'open class added on click')
+ 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 () {
@@ -85,77 +87,74 @@ $(function () {
'
' +
'' +
''
- var dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
+ var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
- ok(dropdown.parent('.dropdown').hasClass('open'), 'open class added on click')
+ ok($dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
})
- test('should remove open class if body clicked', function () {
+ test('should remove "open" class if body is clicked', function () {
var dropdownHTML = '
'
- var dropdown = $(dropdownHTML)
- .appendTo('#qunit-fixture')
- .find('[data-toggle="dropdown"]')
- .bootstrapDropdown()
- .click()
+ var $dropdown = $(dropdownHTML)
+ .appendTo('#qunit-fixture')
+ .find('[data-toggle="dropdown"]')
+ .bootstrapDropdown()
+ .click()
- ok(dropdown.parent('.dropdown').hasClass('open'), 'open class added on click')
- $('body').click()
- ok(!dropdown.parent('.dropdown').hasClass('open'), 'open class removed')
- dropdown.remove()
+ ok($dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
+ $(document.body).click()
+ ok(!$dropdown.parent('.dropdown').hasClass('open'), '"open" class removed')
})
- test('should remove open class if body clicked, with multiple drop downs', function () {
+ test('should remove "open" class if body is clicked, with multiple dropdowns', function () {
var dropdownHTML = '