Add test for focus event on inline search
This adds a test for
02cca7baa7
.
This commit is contained in:
parent
3bc7f4ac78
commit
5b207b287e
@ -137,3 +137,55 @@ test('updating selection does not shift the focus', function (assert) {
|
|||||||
'The search did not have focus after the selection was updated'
|
'The search did not have focus after the selection was updated'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('the focus event shifts the focus', function (assert) {
|
||||||
|
// Check for IE 8, which triggers a false negative during testing
|
||||||
|
if (window.attachEvent && !window.addEventListener) {
|
||||||
|
// We must expect 0 assertions or the test will fail
|
||||||
|
expect(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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');
|
||||||
|
|
||||||
|
assert.notEqual(
|
||||||
|
document.activeElement,
|
||||||
|
$search[0],
|
||||||
|
'The search had focus originally'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.equal($search.length, 1, 'The search was not visible');
|
||||||
|
|
||||||
|
// Focus the container
|
||||||
|
|
||||||
|
container.trigger('focus');
|
||||||
|
|
||||||
|
// Make sure it focuses the search
|
||||||
|
|
||||||
|
assert.equal($search.length, 1, 'The search box disappeared');
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
document.activeElement,
|
||||||
|
$search[0],
|
||||||
|
'The search did not have focus originally'
|
||||||
|
);
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user