Skip to content

Commit 39d57e2

Browse files
chrisbobbegnprice
authored andcommitted
emoji test [nfc]: Make a nested prepare more like another (2/2)
This shorthand wasn't saving *that* much boilerplate; seems okay to remove it. The two `prepare` functions are now identical; we'll deduplicate them next.
1 parent 140c4cb commit 39d57e2

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

test/model/emoji_test.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,13 @@ void main() {
323323
(c) => isUnicodeResult(emojiCode: c.emojiCode)).toList();
324324

325325
PerAccountStore prepare({
326-
Map<String, String> realmEmoji = const {},
326+
Map<String, RealmEmojiItem> realmEmoji = const {},
327327
bool addServerDataForPopular = true,
328328
Map<String, List<String>>? unicodeEmoji,
329329
}) {
330330
final store = eg.store(
331-
initialSnapshot: eg.initialSnapshot(realmEmoji: {
332-
for (final MapEntry(:key, :value) in realmEmoji.entries)
333-
key: eg.realmEmojiItem(emojiCode: key, emojiName: value),
334-
}));
331+
initialSnapshot: eg.initialSnapshot(realmEmoji: realmEmoji));
332+
335333
if (addServerDataForPopular || unicodeEmoji != null) {
336334
final extraEmojiData = ServerEmojiData(codeToNames: unicodeEmoji ?? {});
337335
final emojiData = addServerDataForPopular
@@ -344,7 +342,9 @@ void main() {
344342

345343
test('results can include all three emoji types', () async {
346344
final store = prepare(
347-
realmEmoji: {'1': 'happy'}, unicodeEmoji: {'1f516': ['bookmark']});
345+
realmEmoji: {'1': eg.realmEmojiItem(emojiCode: '1', emojiName: 'happy')},
346+
unicodeEmoji: {'1f516': ['bookmark']},
347+
);
348348
final view = EmojiAutocompleteView.init(store: store,
349349
query: EmojiAutocompleteQuery(''));
350350
bool done = false;
@@ -361,7 +361,8 @@ void main() {
361361

362362
test('results update after query change', () async {
363363
final store = prepare(
364-
realmEmoji: {'1': 'happy'}, unicodeEmoji: {'1f516': ['bookmark']});
364+
realmEmoji: {'1': eg.realmEmojiItem(emojiCode: '1', emojiName: 'happy')},
365+
unicodeEmoji: {'1f516': ['bookmark']});
365366
final view = EmojiAutocompleteView.init(store: store,
366367
query: EmojiAutocompleteQuery('hap'));
367368
bool done = false;
@@ -381,7 +382,7 @@ void main() {
381382

382383
Future<Iterable<EmojiAutocompleteResult>> resultsOf(
383384
String query, {
384-
Map<String, String> realmEmoji = const {},
385+
Map<String, RealmEmojiItem> realmEmoji = const {},
385386
Map<String, List<String>>? unicodeEmoji,
386387
}) async {
387388
final store = prepare(realmEmoji: realmEmoji, unicodeEmoji: unicodeEmoji);

0 commit comments

Comments
 (0)