Skip to content

Commit 3a6d127

Browse files
committed
emoji test [nfc]: Extract helpers realmCandidate, zulipCandidate
1 parent 4d82466 commit 3a6d127

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

test/model/emoji_test.dart

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -425,37 +425,39 @@ void main() {
425425
'1f3f3')).none;
426426
});
427427

428-
test('can match realm emoji', () {
429-
EmojiCandidate realmCandidate(String emojiName) {
430-
return EmojiCandidate(
431-
emojiType: ReactionType.realmEmoji,
432-
emojiCode: '1', emojiName: emojiName, aliases: null,
433-
emojiDisplay: ImageEmojiDisplay(
434-
emojiName: emojiName,
435-
resolvedUrl: eg.realmUrl.resolve('/emoji/1.png'),
436-
resolvedStillUrl: eg.realmUrl.resolve('/emoji/1-still.png')));
437-
}
428+
EmojiCandidate realmCandidate(String emojiName) {
429+
return EmojiCandidate(
430+
emojiType: ReactionType.realmEmoji,
431+
emojiCode: '1', emojiName: emojiName, aliases: null,
432+
emojiDisplay: ImageEmojiDisplay(
433+
emojiName: emojiName,
434+
resolvedUrl: eg.realmUrl.resolve('/emoji/1.png'),
435+
resolvedStillUrl: eg.realmUrl.resolve('/emoji/1-still.png')));
436+
}
438437

438+
test('can match realm emoji', () {
439439
check(matchOf('eqeq', realmCandidate('eqeq'))).exact;
440440
check(matchOf('open_', realmCandidate('open_book'))).prefix;
441441
check(matchOf('n_b', realmCandidate('open_book'))).none;
442442
check(matchOf('blue dia', realmCandidate('large_blue_diamond'))).other;
443443
check(matchOf('Smi', realmCandidate('smile'))).prefix;
444444
});
445445

446-
test('can match Zulip extra emoji', () {
446+
EmojiCandidate zulipCandidate() {
447447
final store = eg.store();
448-
final zulipCandidate = EmojiCandidate(
448+
return EmojiCandidate(
449449
emojiType: ReactionType.zulipExtraEmoji,
450450
emojiCode: 'zulip', emojiName: 'zulip', aliases: null,
451451
emojiDisplay: store.emojiDisplayFor(
452452
emojiType: ReactionType.zulipExtraEmoji,
453453
emojiCode: 'zulip', emojiName: 'zulip'));
454+
}
454455

455-
check(matchOf('z', zulipCandidate)).prefix;
456-
check(matchOf('Zulip', zulipCandidate)).exact;
457-
check(matchOf('p', zulipCandidate)).other;
458-
check(matchOf('x', zulipCandidate)).none;
456+
test('can match Zulip extra emoji', () {
457+
check(matchOf('z', zulipCandidate())).prefix;
458+
check(matchOf('Zulip', zulipCandidate())).exact;
459+
check(matchOf('p', zulipCandidate())).other;
460+
check(matchOf('x', zulipCandidate())).none;
459461
});
460462

461463
int? rankOf(String query, EmojiCandidate candidate) {

0 commit comments

Comments
 (0)