Created
July 1, 2019 11:41
-
-
Save blikblum/bc8d8c37d5661de19996fc50a6088937 to your computer and use it in GitHub Desktop.
Unit test select2 dropdown close
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('click on input opens but do not closes the dropdown', function (assert) { | |
var $container = $('#qunit-fixture .event-container'); | |
var container = new MockContainer(); | |
var CustomSelection = Utils.Decorate(MultipleSelection, InlineSearch); | |
var $element = $('#qunit-fixture .multiple'); | |
var selection = new CustomSelection($element, options); | |
var $selection = selection.render(); | |
selection.bind(container, $container); | |
// Update the selection so the search is rendered | |
selection.update([]); | |
// Make it visible so the browser can place focus on the search | |
$container.append($selection); | |
// The search should not be automatically focused | |
var $search = $selection.find('input'); | |
selection.on('toggle', function() { | |
container._isOpen = !container._isOpen; | |
}) | |
$search.click(); | |
assert.ok( | |
container.isOpen(), | |
'The dropdown should open when clicking on input on a closed select' | |
); | |
$search.click(); | |
assert.ok( | |
container.isOpen(), | |
'The dropdown should kept open when clicking on input on an open select' | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment