@@ -245,9 +245,9 @@ void main() {
245
245
await Future (() {});
246
246
check (done).isTrue ();
247
247
check (view.results).deepEquals ([
248
- isUnicodeResult (names: ['bookmark' ]),
249
248
isRealmResult (emojiName: 'happy' ),
250
249
isZulipResult (),
250
+ isUnicodeResult (names: ['bookmark' ]),
251
251
]);
252
252
});
253
253
@@ -287,15 +287,17 @@ void main() {
287
287
}
288
288
289
289
test ('results end-to-end' , () async {
290
+ // (See more detailed rank tests below, on EmojiAutocompleteQuery.)
291
+
290
292
final unicodeEmoji = {
291
293
'1f4d3' : ['notebook' ], '1f516' : ['bookmark' ], '1f4d6' : ['book' ]};
292
294
293
295
// Empty query -> base ordering.
294
296
check (await resultsOf ('' , unicodeEmoji: unicodeEmoji)).deepEquals ([
297
+ isZulipResult (),
295
298
isUnicodeResult (names: ['notebook' ]),
296
299
isUnicodeResult (names: ['bookmark' ]),
297
300
isUnicodeResult (names: ['book' ]),
298
- isZulipResult (),
299
301
]);
300
302
301
303
// With query, exact match precedes prefix match precedes other.
@@ -468,17 +470,56 @@ void main() {
468
470
check (rankOf (query, a)! ).isLessThan (rankOf (query, b)! );
469
471
}
470
472
473
+ void checkSameRank (String query, EmojiCandidate a, EmojiCandidate b) {
474
+ check (rankOf (query, a)! ).equals (rankOf (query, b)! );
475
+ }
476
+
477
+ final octopus = unicode (['octopus' ], emojiCode: '1f419' );
478
+ final workingOnIt = unicode (['working_on_it' ], emojiCode: '1f6e0' );
479
+
471
480
test ('ranks exact before prefix before other match' , () {
472
481
checkPrecedes ('o' , unicode (['o' ]), unicode (['onion' ]));
473
482
checkPrecedes ('o' , unicode (['onion' ]), unicode (['book' ]));
474
483
});
475
484
485
+ test ('ranks popular before realm before other Unicode' , () {
486
+ checkPrecedes ('o' , octopus, realmCandidate ('open_book' ));
487
+ checkPrecedes ('o' , realmCandidate ('open_book' ), unicode (['ok' ]));
488
+ });
489
+
490
+ test ('ranks Zulip extra emoji same as realm emoji' , () {
491
+ checkSameRank ('z' , zulipCandidate (), realmCandidate ('zounds' ));
492
+ });
493
+
494
+ test ('ranks exact-vs-not more significant than popular/custom/other' , () {
495
+ // Generic Unicode exact beats popular prefix…
496
+ checkPrecedes ('o' , unicode (['o' ]), octopus);
497
+ // … which really does count as popular, beating realm prefix.
498
+ checkPrecedes ('o' , octopus, realmCandidate ('open_book' ));
499
+ });
500
+
501
+ test ('ranks popular-vs-not more significant than prefix/other' , () {
502
+ // Popular other beats realm prefix.
503
+ checkPrecedes ('o' , workingOnIt, realmCandidate ('open_book' ));
504
+ });
505
+
506
+ test ('ranks prefix/other more significant than custom/other' , () {
507
+ // Generic Unicode prefix beats realm other.
508
+ checkPrecedes ('o' , unicode (['ok' ]), realmCandidate ('yo' ));
509
+ });
510
+
476
511
test ('full list of ranks' , () {
477
512
check ([
478
- rankOf ('o' , unicode (['o' ])), // exact
479
- rankOf ('o' , unicode (['onion' ])), // prefix
480
- rankOf ('o' , unicode (['book' ])), // other
481
- ]).deepEquals ([0 , 1 , 2 ]);
513
+ rankOf ('o' , unicode (['o' ])), // exact (generic)
514
+ rankOf ('o' , octopus), // prefix popular
515
+ rankOf ('o' , workingOnIt), // other popular
516
+ rankOf ('o' , realmCandidate ('open_book' )), // prefix realm
517
+ rankOf ('z' , zulipCandidate ()), // == prefix :zulip:
518
+ rankOf ('o' , unicode (['ok' ])), // prefix generic
519
+ rankOf ('o' , realmCandidate ('yo' )), // other realm
520
+ rankOf ('p' , zulipCandidate ()), // == other :zulip:
521
+ rankOf ('o' , unicode (['book' ])), // other generic
522
+ ]).deepEquals ([0 , 1 , 2 , 3 , 3 , 4 , 5 , 5 , 6 ]);
482
523
});
483
524
});
484
525
}
0 commit comments