fix emoji insertion
This commit is contained in:
parent
cd9365cddb
commit
5424242b0f
|
@ -19,9 +19,9 @@ export async function updateCustomEmojiForInstance (instanceName) {
|
|||
|
||||
export function insertEmoji (emoji) {
|
||||
let idx = store.get('composeSelectionStart') || 0
|
||||
let oldText = store.get('rawComposeText')
|
||||
let pre = substring(oldText, 0, idx)
|
||||
let post = substring(oldText, idx)
|
||||
let oldText = store.get('rawComposeText') || ''
|
||||
let pre = oldText ? substring(oldText, 0, idx) : ''
|
||||
let post = oldText ? substring(oldText, idx) : ''
|
||||
let newText = `${pre}:${emoji.shortcode}: ${post}`
|
||||
store.set({
|
||||
rawComposeText: newText
|
||||
|
|
|
@ -81,3 +81,13 @@ test('inserts custom emoji correctly', async t => {
|
|||
.click($('button img[title=":blobpeek:"]'))
|
||||
.expect(composeInput.value).eql(':blobnom: hello :blobpats: world foobar :blobpeek: ')
|
||||
})
|
||||
|
||||
test('inserts emoji without typing anything', async t => {
|
||||
await t.useRole(foobarRole)
|
||||
.click(emojiButton)
|
||||
.click($('button img[title=":blobpats:"]'))
|
||||
.expect(composeInput.value).eql(':blobpats: ')
|
||||
.click(emojiButton)
|
||||
.click($('button img[title=":blobpeek:"]'))
|
||||
.expect(composeInput.value).eql(':blobpeek: :blobpats: ')
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue