The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
import { describe, expect, it } from 'vitest'
import { ensureEmojiPresentation } from '../lib/emoji.js'
const VS16 = '\uFE0F'
describe('ensureEmojiPresentation', () => {
it('passes through ASCII unchanged', () => {
expect(ensureEmojiPresentation('hello world')).toBe('hello world')
expect(ensureEmojiPresentation('')).toBe('')
})
it('passes through emoji that already defaults to emoji presentation', () => {
expect(ensureEmojiPresentation('π rocket')).toBe('π rocket')
expect(ensureEmojiPresentation('π')).toBe('π')
})
it('injects VS16 after text-default emoji codepoints', () => {
expect(ensureEmojiPresentation('β careful')).toBe(`β ${VS16} careful`)
expect(ensureEmojiPresentation('βΉ info')).toBe(`βΉ${VS16} info`)
expect(ensureEmojiPresentation('love β€ you')).toBe(`love β€${VS16} you`)
expect(ensureEmojiPresentation('β done')).toBe(`β${VS16} done`)
})
it('is idempotent when VS16 is already present', () => {
const already = `β ${VS16} βΉ${VS16} β€${VS16}`
expect(ensureEmojiPresentation(already)).toBe(already)
expect(ensureEmojiPresentation(ensureEmojiPresentation('β '))).toBe(`β ${VS16}`)
})
it('leaves keycap sequences alone when the base is not a text-default emoji', () => {
expect(ensureEmojiPresentation('1\u20e3')).toBe('1\u20e3')
})
it('injects VS16 before ZWJ so text-default bases participate in emoji sequences', () => {
// β€ + ZWJ + π₯ β β€οΈβπ₯ (heart on fire). Without VS16 between the heart
// and the ZWJ, terminals render the heart in text/monochrome form and
// the ZWJ ligature can fail to form.
const heartFire = '\u2764\u200d\ud83d\udd25'
expect(ensureEmojiPresentation(heartFire)).toBe(`\u2764\uFE0F\u200d\ud83d\udd25`)
})
it('leaves explicit text-presentation selector (VS15) alone', () => {
// `β€οΈ` (U+2764 + U+FE0E) asks for text presentation β injecting VS16
// would create an invalid double-variation sequence.
const explicitText = '\u2764\ufe0e'
expect(ensureEmojiPresentation(explicitText)).toBe(explicitText)
})
it('handles mixed content', () => {
expect(ensureEmojiPresentation('β path: /tmp/x β€ done')).toBe(`β ${VS16} path: /tmp/x β€${VS16} done`)
})
})