From 49e094619b171568fcdf59cf2dbf0e8b790e8e54 Mon Sep 17 00:00:00 2001 From: jakubhonisek <36561997+jakubhonisek@users.noreply.github.com> Date: Mon, 25 Jun 2018 15:29:34 +0200 Subject: feat(dropdown): add original click event --- js/tests/unit/dropdown.js | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'js/tests/unit/dropdown.js') diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index f767124d5..81d35ff3a 100644 --- a/js/tests/unit/dropdown.js +++ b/js/tests/unit/dropdown.js @@ -499,6 +499,74 @@ $(function () { $dropdown.trigger('click') }) + QUnit.test('should fire hide and hidden event with a clickEvent', function (assert) { + assert.expect(3) + var dropdownHTML = '
' + + '' + var $dropdown = $(dropdownHTML) + .appendTo('#qunit-fixture') + .find('[data-toggle="dropdown"]') + .bootstrapDropdown() + + $dropdown.parent('.dropdown') + .on('hide.bs.dropdown', function (e) { + assert.ok(e.clickEvent) + }) + .on('hidden.bs.dropdown', function (e) { + assert.ok(e.clickEvent) + }) + .on('shown.bs.dropdown', function () { + assert.ok(true, 'shown was fired') + $(document.body).trigger('click') + }) + + $dropdown.trigger('click') + }) + + QUnit.test('should fire hide and hidden event without a clickEvent if event type is not click', function (assert) { + assert.expect(3) + var dropdownHTML = '
' + + '' + var $dropdown = $(dropdownHTML) + .appendTo('#qunit-fixture') + .find('[data-toggle="dropdown"]') + .bootstrapDropdown() + + $dropdown.parent('.dropdown') + .on('hide.bs.dropdown', function (e) { + assert.notOk(e.clickEvent) + }) + .on('hidden.bs.dropdown', function (e) { + assert.notOk(e.clickEvent) + }) + .on('shown.bs.dropdown', function () { + assert.ok(true, 'shown was fired') + $dropdown.trigger($.Event('keydown', { + which: 27 + })) + }) + + $dropdown.trigger('click') + }) + QUnit.test('should ignore keyboard events within s and