@@ -69,11 +69,11 @@ void main() {
69
69
final subscription = stream.listen (
70
70
expectAsync1 (
71
71
(v) => expect (v, changeNotifier),
72
- count: 1 ,
72
+ count: 4 ,
73
73
),
74
74
)..pause ();
75
75
76
- // no effect
76
+ // buffer
77
77
changeNotifier.notifyListeners ();
78
78
changeNotifier.notifyListeners ();
79
79
changeNotifier.notifyListeners ();
@@ -181,30 +181,32 @@ void main() {
181
181
test ('not replay' , () async {
182
182
final valueNotifier = ValueNotifier (0 );
183
183
final stream = valueNotifier.toValueStream ();
184
- final expected = 4 ;
184
+ final expected = [ 1 , 2 , 3 , 4 , 5 ] ;
185
185
186
+ var i = 0 ;
186
187
final subscription = stream.listen (
187
188
expectAsync1 (
188
- (v) => expect (v, expected),
189
- count: 1 ,
189
+ (v) => expect (v, expected[i ++ ] ),
190
+ count: expected.length ,
190
191
),
191
192
)..pause ();
192
193
193
- // no effect
194
+ // buffer
194
195
valueNotifier.value = 1 ;
195
196
valueNotifier.value = 2 ;
196
197
valueNotifier.value = 3 ;
197
198
198
199
await Future <void >.delayed (const Duration (milliseconds: 50 ));
199
200
subscription.resume ();
200
201
201
- valueNotifier.value = expected;
202
+ valueNotifier.value = 4 ;
203
+ valueNotifier.value = 5 ;
202
204
});
203
205
204
206
test ('replay + pause immediately' , () async {
205
207
final valueNotifier = ValueNotifier (0 );
206
208
final stream = valueNotifier.toValueStream (replayValue: true );
207
- final expected = [0 , 4 , 5 ];
209
+ final expected = [0 , 1 , 2 , 3 , 4 , 5 ];
208
210
209
211
var i = 0 ;
210
212
final subscription = stream.listen (
@@ -215,22 +217,21 @@ void main() {
215
217
),
216
218
)..pause ();
217
219
218
- // no effect
220
+ // buffer
219
221
valueNotifier.value = 1 ;
220
222
valueNotifier.value = 2 ;
221
223
valueNotifier.value = 3 ;
222
224
223
225
subscription.resume ();
224
226
225
- await pumpEventQueue ();
226
227
valueNotifier.value = 4 ;
227
228
valueNotifier.value = 5 ;
228
229
});
229
230
230
231
test ('replay + pause after events queue.' , () async {
231
232
final valueNotifier = ValueNotifier (0 );
232
233
final stream = valueNotifier.toValueStream (replayValue: true );
233
- final expected = [0 , 4 , 5 ];
234
+ final expected = [0 , 1 , 2 , 3 , 4 , 5 ];
234
235
235
236
var i = 0 ;
236
237
final subscription = stream.listen (
@@ -244,7 +245,7 @@ void main() {
244
245
await pumpEventQueue ();
245
246
subscription.pause ();
246
247
247
- // no effect
248
+ // buffer
248
249
valueNotifier.value = 1 ;
249
250
valueNotifier.value = 2 ;
250
251
valueNotifier.value = 3 ;
0 commit comments