@@ -78,7 +78,10 @@ void main() {
78
78
});
79
79
});
80
80
81
- final popularCandidates = eg.store ().popularEmojiCandidates ();
81
+ final popularCandidates = (
82
+ eg.store ()..setServerEmojiData (eg.serverEmojiDataPopular)
83
+ ).popularEmojiCandidates ();
84
+ assert (popularCandidates.length == 6 );
82
85
83
86
Condition <Object ?> isUnicodeCandidate (String ? emojiCode, List <String >? names) {
84
87
return (it_) {
@@ -118,18 +121,22 @@ void main() {
118
121
119
122
PerAccountStore prepare ({
120
123
Map <String , RealmEmojiItem > realmEmoji = const {},
124
+ bool addServerDataForPopular = true ,
121
125
Map <String , List <String >>? unicodeEmoji,
122
126
}) {
123
127
final store = eg.store (
124
128
initialSnapshot: eg.initialSnapshot (realmEmoji: realmEmoji));
125
- if (unicodeEmoji != null ) {
126
- store.setServerEmojiData (ServerEmojiData (codeToNames: unicodeEmoji));
127
- }
129
+
130
+ final extraEmojiData = ServerEmojiData (codeToNames: unicodeEmoji ?? {});
131
+ final emojiData = addServerDataForPopular
132
+ ? eg.serverEmojiDataPopularPlus (extraEmojiData)
133
+ : extraEmojiData;
134
+ store.setServerEmojiData (emojiData);
128
135
return store;
129
136
}
130
137
131
138
test ('popular emoji appear even when no server emoji data' , () {
132
- final store = prepare (unicodeEmoji: null );
139
+ final store = prepare (unicodeEmoji: null , addServerDataForPopular : false );
133
140
check (store.allEmojiCandidates ()).deepEquals ([
134
141
...arePopularCandidates,
135
142
isZulipCandidate (),
@@ -139,7 +146,8 @@ void main() {
139
146
test ('popular emoji appear in their canonical order' , () {
140
147
// In the server's emoji data, have the popular emoji in a permuted order,
141
148
// and interspersed with other emoji.
142
- final store = prepare (unicodeEmoji: {
149
+ assert (popularCandidates.length == 6 );
150
+ final store = prepare (addServerDataForPopular: false , unicodeEmoji: {
143
151
'1f603' : ['smiley' ],
144
152
for (final candidate in popularCandidates.skip (3 ))
145
153
candidate.emojiCode: [candidate.emojiName, ...candidate.aliases],
@@ -252,9 +260,10 @@ void main() {
252
260
isZulipCandidate (),
253
261
]);
254
262
255
- store.setServerEmojiData (ServerEmojiData (codeToNames: {
256
- '1f516' : ['bookmark' ],
257
- }));
263
+ store.setServerEmojiData (eg.serverEmojiDataPopularPlus (
264
+ ServerEmojiData (codeToNames: {
265
+ '1f516' : ['bookmark' ],
266
+ })));
258
267
check (store.allEmojiCandidates ()).deepEquals ([
259
268
...arePopularCandidates,
260
269
isUnicodeCandidate ('1f516' , ['bookmark' ]),
@@ -318,9 +327,9 @@ void main() {
318
327
for (final MapEntry (: key, : value) in realmEmoji.entries)
319
328
key: eg.realmEmojiItem (emojiCode: key, emojiName: value),
320
329
}));
321
- if (unicodeEmoji != null ) {
322
- store. setServerEmojiData ( ServerEmojiData (codeToNames : unicodeEmoji) );
323
- }
330
+ final extraEmojiData = ServerEmojiData (codeToNames : unicodeEmoji ?? {});
331
+ ServerEmojiData emojiData = eg. serverEmojiDataPopularPlus (extraEmojiData );
332
+ store. setServerEmojiData (emojiData);
324
333
return store;
325
334
}
326
335
0 commit comments