Skip to content

Commit

Permalink
wip inspect rank directly
Browse files Browse the repository at this point in the history
  • Loading branch information
gnprice committed Dec 8, 2024
1 parent b60268a commit 75e1fe7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions test/model/emoji_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,12 @@ void main() {
});

group('EmojiAutocompleteView', () {
Condition<Object?> isUnicodeResult({String? emojiCode, List<String>? names}) {
return (it) => it.isA<EmojiAutocompleteResult>().candidate.which(
isUnicodeCandidate(emojiCode, names));
Condition<Object?> isUnicodeResult({int? rank,
String? emojiCode, List<String>? names}) {
return (it) => it.isA<EmojiAutocompleteResult>().which((r) {
r.candidate.which(isUnicodeCandidate(emojiCode, names));
if (rank != null) r.rank.equals(rank);
});
}

Condition<Object?> isRealmResult({String? emojiCode, String? emojiName}) {
Expand Down Expand Up @@ -300,9 +303,9 @@ void main() {

// With query, exact match precedes prefix match precedes other.
check(await resultsOf('o', unicodeEmoji: unicodeEmoji)).deepEquals([
isUnicodeResult(names: ['o']),
isUnicodeResult(names: ['octopus']),
isUnicodeResult(names: ['book']),
isUnicodeResult(rank: 0, names: ['o']),
isUnicodeResult(rank: 1, names: ['octopus']),
isUnicodeResult(rank: 2, names: ['book']),
]);
});
});
Expand Down Expand Up @@ -489,5 +492,6 @@ extension EmojiMatchQualityChecks on Subject<EmojiMatchQuality?> {
}

extension EmojiAutocompleteResultChecks on Subject<EmojiAutocompleteResult> {
Subject<int> get rank => has((x) => x.rank, 'rank');
Subject<EmojiCandidate> get candidate => has((x) => x.candidate, 'candidate');
}

0 comments on commit 75e1fe7

Please sign in to comment.