tests: Test enter-key behavior for input pills.

This commit is contained in:
Steve Howell 2018-08-24 16:09:57 +00:00 committed by Tim Abbott
parent 0b548b6b6e
commit 383567aa73
1 changed files with 37 additions and 0 deletions

View File

@ -135,6 +135,43 @@ function set_up() {
};
}
run_test('enter key with text', () => {
const info = set_up();
const config = info.config;
const items = info.items;
const pill_input = info.pill_input;
const container = info.container;
const widget = input_pill.create(config);
pill_input.before = () => {};
widget.appendValue('blue,red');
assert.deepEqual(widget.items(), [
items.blue,
items.red,
]);
const ENTER = 13;
const key_handler = container.get_on_handler('keydown', '.input');
key_handler({
keyCode: ENTER,
preventDefault: noop,
stopPropagation: noop,
target: {
innerText: ' yellow ',
},
});
assert.deepEqual(widget.items(), [
items.blue,
items.red,
items.yellow,
]);
});
run_test('insert_remove', () => {
const info = set_up();