@@ -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,25 @@ 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));
129
+
130
+ if (addServerDataForPopular || unicodeEmoji != null ) {
131
+ final extraEmojiData = ServerEmojiData (codeToNames: unicodeEmoji ?? {});
132
+ final emojiData = addServerDataForPopular
133
+ ? eg.serverEmojiDataPopularPlus (extraEmojiData)
134
+ : extraEmojiData;
135
+ store.setServerEmojiData (emojiData);
127
136
}
128
137
return store;
129
138
}
130
139
131
140
test ('popular emoji appear even when no server emoji data' , () {
132
- final store = prepare (unicodeEmoji: null );
141
+ final store = prepare (unicodeEmoji: null , addServerDataForPopular: false );
142
+ check (store.debugServerEmojiData).isNull ();
133
143
check (store.allEmojiCandidates ()).deepEquals ([
134
144
...arePopularCandidates,
135
145
isZulipCandidate (),
@@ -139,7 +149,8 @@ void main() {
139
149
test ('popular emoji appear in their canonical order' , () {
140
150
// In the server's emoji data, have the popular emoji in a permuted order,
141
151
// and interspersed with other emoji.
142
- final store = prepare (unicodeEmoji: {
152
+ assert (popularCandidates.length == 6 );
153
+ final store = prepare (addServerDataForPopular: false , unicodeEmoji: {
143
154
'1f603' : ['smiley' ],
144
155
for (final candidate in popularCandidates.skip (3 ))
145
156
candidate.emojiCode: [candidate.emojiName, ...candidate.aliases],
@@ -246,15 +257,17 @@ void main() {
246
257
});
247
258
248
259
test ('updates on setServerEmojiData' , () {
249
- final store = prepare ();
260
+ final store = prepare (unicodeEmoji: null , addServerDataForPopular: false );
261
+ check (store.debugServerEmojiData).isNull ();
250
262
check (store.allEmojiCandidates ()).deepEquals ([
251
263
...arePopularCandidates,
252
264
isZulipCandidate (),
253
265
]);
254
266
255
- store.setServerEmojiData (ServerEmojiData (codeToNames: {
256
- '1f516' : ['bookmark' ],
257
- }));
267
+ store.setServerEmojiData (eg.serverEmojiDataPopularPlus (
268
+ ServerEmojiData (codeToNames: {
269
+ '1f516' : ['bookmark' ],
270
+ })));
258
271
check (store.allEmojiCandidates ()).deepEquals ([
259
272
...arePopularCandidates,
260
273
isUnicodeCandidate ('1f516' , ['bookmark' ]),
@@ -318,9 +331,9 @@ void main() {
318
331
for (final MapEntry (: key, : value) in realmEmoji.entries)
319
332
key: eg.realmEmojiItem (emojiCode: key, emojiName: value),
320
333
}));
321
- if (unicodeEmoji != null ) {
322
- store. setServerEmojiData ( ServerEmojiData (codeToNames : unicodeEmoji) );
323
- }
334
+ final extraEmojiData = ServerEmojiData (codeToNames : unicodeEmoji ?? {});
335
+ ServerEmojiData emojiData = eg. serverEmojiDataPopularPlus (extraEmojiData );
336
+ store. setServerEmojiData (emojiData);
324
337
return store;
325
338
}
326
339
0 commit comments