forked from RocketChat/Rocket.Chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: broken client-side updates for recent emoji list (RocketChat#33808)
- Loading branch information
1 parent
b4841cb
commit 7681133
Showing
4 changed files
with
73 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@rocket.chat/meteor': patch | ||
--- | ||
|
||
Fixes client-side updates for recent emoji list when custom emojis are modified. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { expect } from 'chai'; | ||
import { describe, it, beforeEach } from 'mocha'; | ||
|
||
import { updateRecent, removeFromRecent, replaceEmojiInRecent } from '../../../../app/emoji/client/helpers'; | ||
import { emoji } from '../../../../app/emoji/client/lib'; | ||
|
||
describe('Emoji Client Helpers', () => { | ||
beforeEach(() => { | ||
emoji.packages.base.emojisByCategory.recent = []; | ||
}); | ||
|
||
describe('updateRecent', () => { | ||
it('should update recent emojis with the provided emojis', () => { | ||
const recentEmojis = ['emoji1', 'emoji2']; | ||
updateRecent(recentEmojis); | ||
expect(emoji.packages.base.emojisByCategory.recent).to.contain('emoji1'); | ||
expect(emoji.packages.base.emojisByCategory.recent).to.contain('emoji2'); | ||
}); | ||
}); | ||
|
||
describe('removeFromRecent', () => { | ||
it('should remove a specific emoji from recent emojis', () => { | ||
emoji.packages.base.emojisByCategory.recent = ['emoji1', 'emoji2', 'emoji3']; | ||
removeFromRecent('emoji2', emoji.packages.base.emojisByCategory.recent); | ||
expect(emoji.packages.base.emojisByCategory.recent).to.not.include('emoji2'); | ||
expect(emoji.packages.base.emojisByCategory.recent).to.deep.equal(['emoji1', 'emoji3']); | ||
}); | ||
|
||
it('should do nothing if the emoji is not in the recent list', () => { | ||
emoji.packages.base.emojisByCategory.recent = ['emoji1', 'emoji2']; | ||
removeFromRecent('emoji3', emoji.packages.base.emojisByCategory.recent); | ||
expect(emoji.packages.base.emojisByCategory.recent).to.deep.equal(['emoji1', 'emoji2']); | ||
}); | ||
}); | ||
|
||
describe('replaceEmojiInRecent', () => { | ||
it('should replace an existing emoji with a new one in recent emojis', () => { | ||
emoji.packages.base.emojisByCategory.recent = ['emoji1', 'emoji2', 'emoji3']; | ||
replaceEmojiInRecent({ oldEmoji: 'emoji2', newEmoji: 'emoji4' }); | ||
expect(emoji.packages.base.emojisByCategory.recent).to.not.include('emoji2'); | ||
expect(emoji.packages.base.emojisByCategory.recent).to.include('emoji4'); | ||
expect(emoji.packages.base.emojisByCategory.recent).to.deep.equal(['emoji1', 'emoji4', 'emoji3']); | ||
}); | ||
|
||
it('should do nothing if the emoji to replace is not in the recent list', () => { | ||
emoji.packages.base.emojisByCategory.recent = ['emoji1', 'emoji2']; | ||
replaceEmojiInRecent({ oldEmoji: 'emoji3', newEmoji: 'emoji4' }); | ||
expect(emoji.packages.base.emojisByCategory.recent).to.deep.equal(['emoji1', 'emoji2']); | ||
}); | ||
}); | ||
}); |