Skip to content

Commit b521026

Browse files
committed
tests: close when addListener throws
1 parent d5c872b commit b521026

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/listenable_stream_test.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ void main() {
8989

9090
changeNotifier.notifyListeners();
9191
});
92+
93+
test('Emits done when Listenable.addListener throws', () {
94+
final changeNotifier = ChangeNotifier()..dispose();
95+
expect(
96+
changeNotifier.toStream(),
97+
emitsDone,
98+
);
99+
});
92100
});
93101

94102
group('ValueListenableToStream', () {
@@ -269,5 +277,25 @@ void main() {
269277
valueNotifier.value = 5;
270278
});
271279
});
280+
281+
test(
282+
'Emits done when ValueNotifier.addListener throws and not replay value',
283+
() {
284+
final valueNotifier = ValueNotifier(0)..dispose();
285+
expect(
286+
valueNotifier.toValueStream(),
287+
emitsDone,
288+
);
289+
});
290+
291+
test(
292+
'Emits value and done when ValueNotifier.addListener throws and replay value',
293+
() {
294+
final valueNotifier = ValueNotifier(0)..dispose();
295+
expect(
296+
valueNotifier.toValueStream(replayValue: true),
297+
emitsInOrder([0, emitsDone]),
298+
);
299+
});
272300
});
273301
}

0 commit comments

Comments
 (0)