diff options
| author | Mark Otto <[email protected]> | 2015-08-04 22:29:45 -0700 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2015-08-04 22:29:45 -0700 |
| commit | 1ddc3f5e21d8a7df6fdec100c48c82aaf8751a83 (patch) | |
| tree | 9a9380632e1a113b1fe0f8aa72be25bfb0fd7fad /js | |
| parent | 8ee9da2f54bcf7da2fc599a93e2d53a78be3ce9f (diff) | |
| parent | ab412b2404d12a3c55d1c4b798bd42ef32e80fab (diff) | |
| download | bootstrap-1ddc3f5e21d8a7df6fdec100c48c82aaf8751a83.tar.xz bootstrap-1ddc3f5e21d8a7df6fdec100c48c82aaf8751a83.zip | |
Merge branch 'master' into v4m
Diffstat (limited to 'js')
| -rw-r--r-- | js/tests/index.html | 2 | ||||
| -rw-r--r-- | js/tests/unit/dropdown.js | 32 |
2 files changed, 33 insertions, 1 deletions
diff --git a/js/tests/index.html b/js/tests/index.html index 0e2bdd012..a91725cc5 100644 --- a/js/tests/index.html +++ b/js/tests/index.html @@ -55,7 +55,7 @@ <script> // See https://github.com/axemclion/grunt-saucelabs#test-result-details-with-qunit var log = [] - // Require assert.expect in each test. + // Require assert.expect in each test QUnit.config.requireExpects = true QUnit.done(function (testResults) { var tests = [] diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index a55684d52..566b50ee7 100644 --- a/js/tests/unit/dropdown.js +++ b/js/tests/unit/dropdown.js @@ -286,6 +286,38 @@ $(function () { $(document.body).trigger('click') }) + QUnit.test('should fire shown and hidden event with a relatedTarget', function (assert) { + assert.expect(2) + var dropdownHTML = '<ul class="tabs">' + + '<li class="dropdown">' + + '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>' + + '<ul class="dropdown-menu">' + + '<li><a href="#">Secondary link</a></li>' + + '<li><a href="#">Something else here</a></li>' + + '<li class="divider"/>' + + '<li><a href="#">Another link</a></li>' + + '</ul>' + + '</li>' + + '</ul>' + var $dropdown = $(dropdownHTML) + .appendTo('#qunit-fixture') + .find('[data-toggle="dropdown"]') + .bootstrapDropdown() + var done = assert.async() + + $dropdown.parent('.dropdown') + .on('hidden.bs.dropdown', function (e) { + assert.strictEqual(e.relatedTarget, $dropdown[0]) + done() + }) + .on('shown.bs.dropdown', function (e) { + assert.strictEqual(e.relatedTarget, $dropdown[0]) + $(document.body).trigger('click') + }) + + $dropdown.trigger('click') + }) + QUnit.test('should ignore keyboard events within <input>s and <textarea>s', function (assert) { assert.expect(3) var done = assert.async() |
