mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
tests: Test pasting into pill input area.
This commit is contained in:
@@ -7,6 +7,7 @@ zrequire('templates');
|
|||||||
global.compile_template('input_pill');
|
global.compile_template('input_pill');
|
||||||
|
|
||||||
set_global('blueslip', global.make_zblueslip());
|
set_global('blueslip', global.make_zblueslip());
|
||||||
|
set_global('document', {});
|
||||||
|
|
||||||
var noop = function () {};
|
var noop = function () {};
|
||||||
var example_img_link = 'http://example.com/example.png';
|
var example_img_link = 'http://example.com/example.png';
|
||||||
@@ -183,6 +184,43 @@ run_test('copy from pill', () => {
|
|||||||
assert.equal(copied_text, 'RED');
|
assert.equal(copied_text, 'RED');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
run_test('paste to input', () => {
|
||||||
|
const info = set_up();
|
||||||
|
const config = info.config;
|
||||||
|
const container = info.container;
|
||||||
|
const items = info.items;
|
||||||
|
|
||||||
|
const widget = input_pill.create(config);
|
||||||
|
|
||||||
|
const paste_handler = container.get_on_handler('paste', '.input');
|
||||||
|
|
||||||
|
var paste_text = 'blue,yellow';
|
||||||
|
|
||||||
|
const e = {
|
||||||
|
originalEvent: {
|
||||||
|
clipboardData: {
|
||||||
|
getData: (format) => {
|
||||||
|
assert.equal(format, 'text/plain');
|
||||||
|
return paste_text;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
preventDefault: noop,
|
||||||
|
};
|
||||||
|
|
||||||
|
document.execCommand = (cmd, _, text) => {
|
||||||
|
assert.equal(cmd, 'insertText');
|
||||||
|
container.find('.input').text(text);
|
||||||
|
};
|
||||||
|
|
||||||
|
paste_handler(e);
|
||||||
|
|
||||||
|
assert.deepEqual(widget.items(), [
|
||||||
|
items.blue,
|
||||||
|
items.yellow,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
run_test('left arrow on input', () => {
|
run_test('left arrow on input', () => {
|
||||||
const info = set_up();
|
const info = set_up();
|
||||||
const config = info.config;
|
const config = info.config;
|
||||||
|
|||||||
Reference in New Issue
Block a user