import 'package:flutter_test/flutter_test.dart'; import 'package:marianum_mobile/utils/emoji_detection.dart'; void main() { group('standaloneEmojiFontSize', () { test('returns null for empty or whitespace-only text', () { expect(standaloneEmojiFontSize(''), isNull); expect(standaloneEmojiFontSize(' '), isNull); }); test('returns null for plain text', () { expect(standaloneEmojiFontSize('Hallo'), isNull); expect(standaloneEmojiFontSize('ok'), isNull); }); test('returns null when emoji is mixed with text', () { expect(standaloneEmojiFontSize('Hallo ๐Ÿ˜€'), isNull); expect(standaloneEmojiFontSize('๐Ÿ˜€ super'), isNull); }); test('enlarges a single emoji the most', () { expect(standaloneEmojiFontSize('๐Ÿ˜€'), 34); expect(standaloneEmojiFontSize('๐Ÿ‘'), 34); }); test('enlarges up to three emojis at the largest size', () { expect(standaloneEmojiFontSize('๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€'), 34); expect(standaloneEmojiFontSize('๐Ÿ˜€ ๐Ÿ˜€ ๐Ÿ˜€'), 34); }); test('does not enlarge more than three emojis', () { expect(standaloneEmojiFontSize('๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€'), isNull); expect(standaloneEmojiFontSize('๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€'), isNull); }); test('handles ZWJ sequences as a single emoji', () { // Family emoji: multiple codepoints joined via ZWJ โ†’ one cluster. expect(standaloneEmojiFontSize('๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ'), 34); }); test('handles skin-tone modified emoji as a single emoji', () { expect(standaloneEmojiFontSize('๐Ÿ‘๐Ÿฝ'), 34); }); test('handles emoji with variation selectors', () { expect(standaloneEmojiFontSize('โค๏ธ'), 34); expect(standaloneEmojiFontSize('โญ'), 34); }); test('handles keycap emoji', () { expect(standaloneEmojiFontSize('1๏ธโƒฃ'), 34); }); test('handles flag emoji (regional indicators)', () { expect(standaloneEmojiFontSize('๐Ÿ‡ฉ๐Ÿ‡ช'), 34); }); test('bare digits without keycap are not emoji', () { expect(standaloneEmojiFontSize('123'), isNull); }); }); group('extractEmojis', () { test('returns empty list for plain text', () { expect(extractEmojis('Hallo Welt'), isEmpty); expect(extractEmojis(''), isEmpty); }); test('extracts emojis from mixed text, ties keep first appearance', () { expect(extractEmojis('Super ๐Ÿ‘ gemacht ๐ŸŽ‰'), ['๐Ÿ‘', '๐ŸŽ‰']); }); test('sorts by frequency, most-frequent first', () { // ๐ŸŽ‰ appears first but ๐Ÿ‘ occurs more often โ†’ ๐Ÿ‘ wins. expect(extractEmojis('๐ŸŽ‰ ๐Ÿ‘ super ๐Ÿ‘'), ['๐Ÿ‘', '๐ŸŽ‰']); }); test('dedupes repeated emojis, most-frequent first', () { expect(extractEmojis('๐Ÿ˜€ ๐Ÿ˜€ ๐Ÿš€ ๐Ÿ˜€'), ['๐Ÿ˜€', '๐Ÿš€']); }); test('extracts composite emojis as single entries', () { expect(extractEmojis('Familie ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ und ๐Ÿ‘๐Ÿฝ'), ['๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ', '๐Ÿ‘๐Ÿฝ']); }); test('extracts flag emojis', () { expect(extractEmojis('Hallo ๐Ÿ‡ฉ๐Ÿ‡ช'), ['๐Ÿ‡ฉ๐Ÿ‡ช']); }); }); group('emojiSkinToneNeutral', () { test('strips skin-tone modifiers', () { expect(emojiSkinToneNeutral('๐Ÿ‘๐Ÿป'), '๐Ÿ‘'); expect(emojiSkinToneNeutral('๐Ÿ‘๐Ÿฟ'), '๐Ÿ‘'); }); test('leaves emojis without skin tone unchanged', () { expect(emojiSkinToneNeutral('๐Ÿ‘'), '๐Ÿ‘'); expect(emojiSkinToneNeutral('โค๏ธ'), 'โค๏ธ'); expect(emojiSkinToneNeutral('๐ŸŽ‰'), '๐ŸŽ‰'); }); test('tone variants compare equal after normalization', () { expect( emojiSkinToneNeutral('๐Ÿ‘๐Ÿป'), emojiSkinToneNeutral('๐Ÿ‘๐Ÿฝ'), ); }); }); }