Commit d619012b authored by JC Brand's avatar JC Brand

Emojis: Fix failing tests

parent bb0670c6
......@@ -458,7 +458,7 @@
const picker = await u.waitUntil(() => view.el.querySelector('.toggle-smiley .emoji-picker__container'));
const item = await u.waitUntil(() => picker.querySelector('.emoji-picker li.insert-emoji'));
item.click()
expect(counter.textContent).toBe('177');
expect(counter.textContent).toBe('179');
const textarea = view.el.querySelector('.chat-textarea');
const ev = {
......
......@@ -34,7 +34,7 @@
const picker = await u.waitUntil(() => view.el.querySelector('.toggle-smiley .emoji-picker__container'));
const item = await u.waitUntil(() => picker.querySelector('.emoji-picker li.insert-emoji'));
item.click()
expect(view.el.querySelector('textarea.chat-textarea').value).toBe(':grinning: ');
expect(view.el.querySelector('textarea.chat-textarea').value).toBe(':smiley: ');
toolbar.querySelector('li.toggle-smiley').click(); // Close the panel again
done();
}));
......@@ -65,9 +65,9 @@
expect(input.value).toBe(':gri');
let visible_emojis = sizzle('.insert-emoji:not(.hidden)', picker);
expect(visible_emojis.length).toBe(3);
expect(visible_emojis[0].getAttribute('data-emoji')).toBe(':grimacing:');
expect(visible_emojis[1].getAttribute('data-emoji')).toBe(':grin:');
expect(visible_emojis[2].getAttribute('data-emoji')).toBe(':grinning:');
expect(visible_emojis[0].getAttribute('data-emoji')).toBe(':grin:');
expect(visible_emojis[1].getAttribute('data-emoji')).toBe(':grinning:');
expect(visible_emojis[2].getAttribute('data-emoji')).toBe(':grimacing:');
// Test that TAB autocompletes the to first match
view.emoji_picker_view.onKeyDown(tab_event);
......@@ -121,7 +121,7 @@
await u.waitUntil(() => u.isVisible(view.el.querySelector('.toggle-smiley .emoji-picker__container')));
const picker = await u.waitUntil(() => view.el.querySelector('.toggle-smiley .emoji-picker__container'));
const input = picker.querySelector('.emoji-search');
expect(sizzle('.insert-emoji:not(.hidden)', picker).length).toBe(1420);
expect(sizzle('.insert-emoji:not(.hidden)', picker).length).toBe(1589);
expect(view.emoji_picker_view.model.get('query')).toBeUndefined();
input.value = 'smiley';
......
......@@ -367,6 +367,7 @@ converse.plugins.add('converse-emoji', {
_converse.emojis_map = Object.keys(_converse.emojis.json).reduce((result, cat) => Object.assign(result, _converse.emojis.json[cat]), {});
_converse.emojis_list = Object.keys(_converse.emojis.json).reduce((result, cat) => [...result, ...Object.values(_converse.emojis.json[cat])], []);
_converse.emoji_shortnames = _converse.emojis_list.map(m => m.sn);
_converse.emoji_shortnames.sort();
const getShortNames = () => _converse.emojis_list.map(emoji => emoji.sn.replace(/[+]/g, "\\$&")).join('|');
_converse.emojis.shortnames_regex = new RegExp("<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|("+getShortNames()+")", "gi");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment