1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-17 19:06:40 +02:00

Fix unit tests with no assertion

This commit is contained in:
Johann-S
2017-06-14 10:48:58 +02:00
parent 1ec68d748b
commit 4a2b183e48

View File

@@ -45,7 +45,8 @@ $(function () {
}) })
QUnit.test('should not open dropdown if target is disabled via attribute', function (assert) { QUnit.test('should not open dropdown if target is disabled via attribute', function (assert) {
assert.expect(0) assert.expect(1)
var done = assert.async()
var dropdownHTML = '<div class="tabs">' var dropdownHTML = '<div class="tabs">'
+ '<div class="dropdown">' + '<div class="dropdown">'
+ '<button disabled href="#" class="btn dropdown-toggle" data-toggle="dropdown">Dropdown</button>' + '<button disabled href="#" class="btn dropdown-toggle" data-toggle="dropdown">Dropdown</button>'
@@ -57,10 +58,13 @@ $(function () {
+ '</div>' + '</div>'
+ '</div>' + '</div>'
+ '</div>' + '</div>'
var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown() $(dropdownHTML).appendTo('#qunit-fixture')
setTimeout(function () { var $dropdown = $('#qunit-fixture').find('[data-toggle="dropdown"]').bootstrapDropdown()
assert.ok(!$dropdown.parent('.dropdown').hasClass('show'), '"show" class added on click') $dropdown.on('click', function () {
}, 300) assert.ok(!$dropdown.parent('.dropdown').hasClass('show'))
done()
})
$dropdown.trigger($.Event('click'))
}) })
QUnit.test('should set aria-expanded="true" on target when dropdown menu is shown', function (assert) { QUnit.test('should set aria-expanded="true" on target when dropdown menu is shown', function (assert) {
@@ -77,7 +81,10 @@ $(function () {
+ '</div>' + '</div>'
+ '</div>' + '</div>'
+ '</div>' + '</div>'
var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown() var $dropdown = $(dropdownHTML)
.appendTo('#qunit-fixture')
.find('[data-toggle="dropdown"]')
.bootstrapDropdown()
$dropdown $dropdown
.parent('.dropdown') .parent('.dropdown')
.on('shown.bs.dropdown', function () { .on('shown.bs.dropdown', function () {
@@ -118,7 +125,8 @@ $(function () {
}) })
QUnit.test('should not open dropdown if target is disabled via class', function (assert) { QUnit.test('should not open dropdown if target is disabled via class', function (assert) {
assert.expect(0) assert.expect(1)
var done = assert.async()
var dropdownHTML = '<div class="tabs">' var dropdownHTML = '<div class="tabs">'
+ '<div class="dropdown">' + '<div class="dropdown">'
+ '<button href="#" class="btn dropdown-toggle disabled" data-toggle="dropdown">Dropdown</button>' + '<button href="#" class="btn dropdown-toggle disabled" data-toggle="dropdown">Dropdown</button>'
@@ -130,10 +138,14 @@ $(function () {
+ '</div>' + '</div>'
+ '</div>' + '</div>'
+ '</div>' + '</div>'
var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().trigger('click')
setTimeout(function () { $(dropdownHTML).appendTo('#qunit-fixture')
assert.ok(!$dropdown.parent('.dropdown').hasClass('show'), '"show" class added on click') var $dropdown = $('#qunit-fixture').find('[data-toggle="dropdown"]').bootstrapDropdown()
}, 300) $dropdown.on('click', function () {
assert.ok(!$dropdown.parent('.dropdown').hasClass('show'))
done()
})
$dropdown.trigger($.Event('click'))
}) })
QUnit.test('should add class show to menu if clicked', function (assert) { QUnit.test('should add class show to menu if clicked', function (assert) {