63 lines
2.1 KiB
Dart
63 lines
2.1 KiB
Dart
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);
|
|
});
|
|
});
|
|
}
|