@@ -282,9 +282,9 @@ void main() {
282
282
await Future (() {});
283
283
check (done).isTrue ();
284
284
check (view.results).deepEquals ([
285
- isUnicodeResult (names: ['bookmark' ]),
286
285
isRealmResult (emojiName: 'happy' ),
287
286
isZulipResult (),
287
+ isUnicodeResult (names: ['bookmark' ]),
288
288
]);
289
289
});
290
290
@@ -324,15 +324,17 @@ void main() {
324
324
}
325
325
326
326
test ('results end-to-end' , () async {
327
+ // (See more detailed rank tests below, on EmojiAutocompleteQuery.)
328
+
327
329
final unicodeEmoji = {
328
330
'1f4d3' : ['notebook' ], '1f516' : ['bookmark' ], '1f4d6' : ['book' ]};
329
331
330
332
// Empty query -> base ordering.
331
333
check (await resultsOf ('' , unicodeEmoji: unicodeEmoji)).deepEquals ([
334
+ isZulipResult (),
332
335
isUnicodeResult (names: ['notebook' ]),
333
336
isUnicodeResult (names: ['bookmark' ]),
334
337
isUnicodeResult (names: ['book' ]),
335
- isZulipResult (),
336
338
]);
337
339
338
340
// With query, exact match precedes prefix match precedes other.
@@ -505,17 +507,56 @@ void main() {
505
507
check (rankOf (query, a)! ).isLessThan (rankOf (query, b)! );
506
508
}
507
509
510
+ void checkSameRank (String query, EmojiCandidate a, EmojiCandidate b) {
511
+ check (rankOf (query, a)! ).equals (rankOf (query, b)! );
512
+ }
513
+
514
+ final octopus = unicode (['octopus' ], emojiCode: '1f419' );
515
+ final workingOnIt = unicode (['working_on_it' ], emojiCode: '1f6e0' );
516
+
508
517
test ('ranks exact before prefix before other match' , () {
509
518
checkPrecedes ('o' , unicode (['o' ]), unicode (['onion' ]));
510
519
checkPrecedes ('o' , unicode (['onion' ]), unicode (['book' ]));
511
520
});
512
521
522
+ test ('ranks popular before realm before other Unicode' , () {
523
+ checkPrecedes ('o' , octopus, realmCandidate ('open_book' ));
524
+ checkPrecedes ('o' , realmCandidate ('open_book' ), unicode (['ok' ]));
525
+ });
526
+
527
+ test ('ranks Zulip extra emoji same as realm emoji' , () {
528
+ checkSameRank ('z' , zulipCandidate (), realmCandidate ('zounds' ));
529
+ });
530
+
531
+ test ('ranks exact-vs-not more significant than popular/custom/other' , () {
532
+ // Generic Unicode exact beats popular prefix…
533
+ checkPrecedes ('o' , unicode (['o' ]), octopus);
534
+ // … which really does count as popular, beating realm prefix.
535
+ checkPrecedes ('o' , octopus, realmCandidate ('open_book' ));
536
+ });
537
+
538
+ test ('ranks popular-vs-not more significant than prefix/other' , () {
539
+ // Popular other beats realm prefix.
540
+ checkPrecedes ('o' , workingOnIt, realmCandidate ('open_book' ));
541
+ });
542
+
543
+ test ('ranks prefix/other more significant than custom/other' , () {
544
+ // Generic Unicode prefix beats realm other.
545
+ checkPrecedes ('o' , unicode (['ok' ]), realmCandidate ('yo' ));
546
+ });
547
+
513
548
test ('full list of ranks' , () {
514
549
check ([
515
- rankOf ('o' , unicode (['o' ])), // exact
516
- rankOf ('o' , unicode (['onion' ])), // prefix
517
- rankOf ('o' , unicode (['book' ])), // other
518
- ]).deepEquals ([0 , 1 , 2 ]);
550
+ rankOf ('o' , unicode (['o' ])), // exact (generic)
551
+ rankOf ('o' , octopus), // prefix popular
552
+ rankOf ('o' , workingOnIt), // other popular
553
+ rankOf ('o' , realmCandidate ('open_book' )), // prefix realm
554
+ rankOf ('z' , zulipCandidate ()), // == prefix :zulip:
555
+ rankOf ('o' , unicode (['ok' ])), // prefix generic
556
+ rankOf ('o' , realmCandidate ('yo' )), // other realm
557
+ rankOf ('p' , zulipCandidate ()), // == other :zulip:
558
+ rankOf ('o' , unicode (['book' ])), // other generic
559
+ ]).deepEquals ([0 , 1 , 2 , 3 , 3 , 4 , 5 , 5 , 6 ]);
519
560
});
520
561
});
521
562
}
0 commit comments