Skip to content

Commit d8d9e58

Browse files
committed
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 b8abc6b commit d8d9e58

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

test/model/emoji_test.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -319,15 +319,13 @@ void main() {
319319
(c) => isUnicodeResult(emojiCode: c.emojiCode)).toList();
320320

321321
PerAccountStore prepare({
322-
Map<String, String> realmEmoji = const {},
322+
Map<String, RealmEmojiItem> realmEmoji = const {},
323323
bool addServerDataForPopular = true,
324324
Map<String, List<String>>? unicodeEmoji,
325325
}) {
326326
final store = eg.store(
327-
initialSnapshot: eg.initialSnapshot(realmEmoji: {
328-
for (final MapEntry(:key, :value) in realmEmoji.entries)
329-
key: eg.realmEmojiItem(emojiCode: key, emojiName: value),
330-
}));
327+
initialSnapshot: eg.initialSnapshot(realmEmoji: realmEmoji));
328+
331329
final extraEmojiData = ServerEmojiData(codeToNames: unicodeEmoji ?? {});
332330
final emojiData = addServerDataForPopular
333331
? eg.serverEmojiDataPopularPlus(extraEmojiData)
@@ -338,7 +336,9 @@ void main() {
338336

339337
test('results can include all three emoji types', () async {
340338
final store = prepare(
341-
realmEmoji: {'1': 'happy'}, unicodeEmoji: {'1f516': ['bookmark']});
339+
realmEmoji: {'1': eg.realmEmojiItem(emojiCode: '1', emojiName: 'happy')},
340+
unicodeEmoji: {'1f516': ['bookmark']},
341+
);
342342
final view = EmojiAutocompleteView.init(store: store,
343343
query: EmojiAutocompleteQuery(''));
344344
bool done = false;
@@ -355,7 +355,9 @@ void main() {
355355

356356
test('results update after query change', () async {
357357
final store = prepare(
358-
realmEmoji: {'1': 'happy'}, unicodeEmoji: {'1f516': ['bookmark']});
358+
realmEmoji: {'1': eg.realmEmojiItem(emojiCode: '1', emojiName: 'happy')},
359+
unicodeEmoji: {'1f516': ['bookmark']},
360+
);
359361
final view = EmojiAutocompleteView.init(store: store,
360362
query: EmojiAutocompleteQuery('hap'));
361363
bool done = false;
@@ -375,7 +377,7 @@ void main() {
375377

376378
Future<Iterable<EmojiAutocompleteResult>> resultsOf(
377379
String query, {
378-
Map<String, String> realmEmoji = const {},
380+
Map<String, RealmEmojiItem> realmEmoji = const {},
379381
Map<String, List<String>>? unicodeEmoji,
380382
}) async {
381383
final store = prepare(realmEmoji: realmEmoji, unicodeEmoji: unicodeEmoji);

0 commit comments

Comments
 (0)