d4af4b675e
Replace the hand-curated 70-entry shortcode map with the full emojibase catalog (5884 entries unioned over github + iamcal + emojibase, the canonical dataset GitHub, Slack, Discord and Mastodon all derive from) so any reaction users send through the wider Org Social ecosystem now renders as the right emoji. Two relay quirks that still slipped through the original :KEY: scanner: - Some clients send moods as bare tokens (`happy`, `heartbeat`) with no delimiters. The resolver now treats a colon-free input as a candidate shortcode key when the whole string matches the map; multi-word body text is unaffected because it never matches. - Other clients use dashes instead of underscores (`christmas-tree` vs `christmas_tree`). Lookups now fall back to the underscore form. Apply the resolver in the two places it was still missing: NotificationsView (reaction icon + action label) and ThreadView (chips), plus the inline mood badge next to the language tag in PostRowView. The test suite grows from 5 to 8 cases covering bare-token, dash-form and free-text inputs.
55 lines
1.8 KiB
Swift
55 lines
1.8 KiB
Swift
import Foundation
|
||
import Testing
|
||
@testable import OrgSocialKit
|
||
|
||
@Suite("EmojiShortcode – resolver")
|
||
struct EmojiShortcodeResolverTests {
|
||
|
||
@Test("known shortcode resolves to Unicode")
|
||
func known() {
|
||
#expect(EmojiShortcode.resolve(":heartbeat:") == "💓")
|
||
#expect(EmojiShortcode.resolve(":thumbsup:") == "👍")
|
||
#expect(EmojiShortcode.resolve(":+1:") == "👍")
|
||
#expect(EmojiShortcode.resolve(":fire:") == "🔥")
|
||
}
|
||
|
||
@Test("unknown shortcode is left untouched")
|
||
func unknown() {
|
||
#expect(EmojiShortcode.resolve(":custom_emoji_123:") == ":custom_emoji_123:")
|
||
}
|
||
|
||
@Test("strings without any colon are returned as-is")
|
||
func plain() {
|
||
#expect(EmojiShortcode.resolve("❤️") == "❤️")
|
||
#expect(EmojiShortcode.resolve("hello") == "hello")
|
||
#expect(EmojiShortcode.resolve("") == "")
|
||
}
|
||
|
||
@Test("inline shortcodes inside a sentence are replaced")
|
||
func inline() {
|
||
#expect(EmojiShortcode.resolve("got it :thumbsup: thanks") == "got it 👍 thanks")
|
||
}
|
||
|
||
@Test("multiple shortcodes in one string are all resolved")
|
||
func multiple() {
|
||
#expect(EmojiShortcode.resolve(":heart::fire:") == "❤️🔥")
|
||
}
|
||
|
||
@Test("bare token without colons resolves when the whole input is a key")
|
||
func bareToken() {
|
||
#expect(EmojiShortcode.resolve("happy") == "😊")
|
||
#expect(EmojiShortcode.resolve("heartbeat") == "💓")
|
||
}
|
||
|
||
@Test("dash-form shortcode is normalised to underscore form")
|
||
func dashes() {
|
||
#expect(EmojiShortcode.resolve(":christmas-tree:") == "🎄")
|
||
#expect(EmojiShortcode.resolve("christmas-tree") == "🎄")
|
||
}
|
||
|
||
@Test("multi-word free text without colons is left untouched")
|
||
func freeText() {
|
||
#expect(EmojiShortcode.resolve("Hello world") == "Hello world")
|
||
}
|
||
}
|