Commit d619012b authored by JC Brand's avatar JC Brand

Emojis: Fix failing tests

parent bb0670c6
...@@ -458,7 +458,7 @@ ...@@ -458,7 +458,7 @@
const picker = await u.waitUntil(() => view.el.querySelector('.toggle-smiley .emoji-picker__container')); 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')); const item = await u.waitUntil(() => picker.querySelector('.emoji-picker li.insert-emoji'));
item.click() item.click()
expect(counter.textContent).toBe('177'); expect(counter.textContent).toBe('179');
const textarea = view.el.querySelector('.chat-textarea'); const textarea = view.el.querySelector('.chat-textarea');
const ev = { const ev = {
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
const picker = await u.waitUntil(() => view.el.querySelector('.toggle-smiley .emoji-picker__container')); 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')); const item = await u.waitUntil(() => picker.querySelector('.emoji-picker li.insert-emoji'));
item.click() 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 toolbar.querySelector('li.toggle-smiley').click(); // Close the panel again
done(); done();
})); }));
...@@ -65,9 +65,9 @@ ...@@ -65,9 +65,9 @@
expect(input.value).toBe(':gri'); expect(input.value).toBe(':gri');
let visible_emojis = sizzle('.insert-emoji:not(.hidden)', picker); let visible_emojis = sizzle('.insert-emoji:not(.hidden)', picker);
expect(visible_emojis.length).toBe(3); expect(visible_emojis.length).toBe(3);
expect(visible_emojis[0].getAttribute('data-emoji')).toBe(':grimacing:'); expect(visible_emojis[0].getAttribute('data-emoji')).toBe(':grin:');
expect(visible_emojis[1].getAttribute('data-emoji')).toBe(':grin:'); expect(visible_emojis[1].getAttribute('data-emoji')).toBe(':grinning:');
expect(visible_emojis[2].getAttribute('data-emoji')).toBe(':grinning:'); expect(visible_emojis[2].getAttribute('data-emoji')).toBe(':grimacing:');
// Test that TAB autocompletes the to first match // Test that TAB autocompletes the to first match
view.emoji_picker_view.onKeyDown(tab_event); view.emoji_picker_view.onKeyDown(tab_event);
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
await u.waitUntil(() => u.isVisible(view.el.querySelector('.toggle-smiley .emoji-picker__container'))); 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 picker = await u.waitUntil(() => view.el.querySelector('.toggle-smiley .emoji-picker__container'));
const input = picker.querySelector('.emoji-search'); 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(); expect(view.emoji_picker_view.model.get('query')).toBeUndefined();
input.value = 'smiley'; input.value = 'smiley';
......
...@@ -367,6 +367,7 @@ converse.plugins.add('converse-emoji', { ...@@ -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_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.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 = _converse.emojis_list.map(m => m.sn);
_converse.emoji_shortnames.sort();
const getShortNames = () => _converse.emojis_list.map(emoji => emoji.sn.replace(/[+]/g, "\\$&")).join('|'); 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"); _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