Skip to content

Commit 70004b0

Browse files
committed
emoji test [nfc]: Extract helpers realmCandidate, zulipCandidate
1 parent 37652db commit 70004b0

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

test/model/emoji_test.dart

+18-16
Original file line numberDiff line numberDiff line change
@@ -462,37 +462,39 @@ void main() {
462462
'1f3f3')).none;
463463
});
464464

465-
test('can match realm emoji', () {
466-
EmojiCandidate realmCandidate(String emojiName) {
467-
return EmojiCandidate(
468-
emojiType: ReactionType.realmEmoji,
469-
emojiCode: '1', emojiName: emojiName, aliases: null,
470-
emojiDisplay: ImageEmojiDisplay(
471-
emojiName: emojiName,
472-
resolvedUrl: eg.realmUrl.resolve('/emoji/1.png'),
473-
resolvedStillUrl: eg.realmUrl.resolve('/emoji/1-still.png')));
474-
}
465+
EmojiCandidate realmCandidate(String emojiName) {
466+
return EmojiCandidate(
467+
emojiType: ReactionType.realmEmoji,
468+
emojiCode: '1', emojiName: emojiName, aliases: null,
469+
emojiDisplay: ImageEmojiDisplay(
470+
emojiName: emojiName,
471+
resolvedUrl: eg.realmUrl.resolve('/emoji/1.png'),
472+
resolvedStillUrl: eg.realmUrl.resolve('/emoji/1-still.png')));
473+
}
475474

475+
test('can match realm emoji', () {
476476
check(matchOf('eqeq', realmCandidate('eqeq'))).exact;
477477
check(matchOf('open_', realmCandidate('open_book'))).prefix;
478478
check(matchOf('n_b', realmCandidate('open_book'))).none;
479479
check(matchOf('blue dia', realmCandidate('large_blue_diamond'))).other;
480480
check(matchOf('Smi', realmCandidate('smile'))).prefix;
481481
});
482482

483-
test('can match Zulip extra emoji', () {
483+
EmojiCandidate zulipCandidate() {
484484
final store = eg.store();
485-
final zulipCandidate = EmojiCandidate(
485+
return EmojiCandidate(
486486
emojiType: ReactionType.zulipExtraEmoji,
487487
emojiCode: 'zulip', emojiName: 'zulip', aliases: null,
488488
emojiDisplay: store.emojiDisplayFor(
489489
emojiType: ReactionType.zulipExtraEmoji,
490490
emojiCode: 'zulip', emojiName: 'zulip'));
491+
}
491492

492-
check(matchOf('z', zulipCandidate)).prefix;
493-
check(matchOf('Zulip', zulipCandidate)).exact;
494-
check(matchOf('p', zulipCandidate)).other;
495-
check(matchOf('x', zulipCandidate)).none;
493+
test('can match Zulip extra emoji', () {
494+
check(matchOf('z', zulipCandidate())).prefix;
495+
check(matchOf('Zulip', zulipCandidate())).exact;
496+
check(matchOf('p', zulipCandidate())).other;
497+
check(matchOf('x', zulipCandidate())).none;
496498
});
497499

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

0 commit comments

Comments
 (0)