aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2015-08-04 22:29:45 -0700
committerMark Otto <[email protected]>2015-08-04 22:29:45 -0700
commit1ddc3f5e21d8a7df6fdec100c48c82aaf8751a83 (patch)
tree9a9380632e1a113b1fe0f8aa72be25bfb0fd7fad /js/tests/unit
parent8ee9da2f54bcf7da2fc599a93e2d53a78be3ce9f (diff)
parentab412b2404d12a3c55d1c4b798bd42ef32e80fab (diff)
downloadbootstrap-1ddc3f5e21d8a7df6fdec100c48c82aaf8751a83.tar.xz
bootstrap-1ddc3f5e21d8a7df6fdec100c48c82aaf8751a83.zip
Merge branch 'master' into v4m
Diffstat (limited to 'js/tests/unit')
-rw-r--r--js/tests/unit/dropdown.js32
1 files changed, 32 insertions, 0 deletions
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()