import 'dart:async'; import 'package:angel3_reactivex/angel3_reactivex.dart'; import 'package:test/test.dart'; import '../utils.dart'; void main() { test('Rx.mapTo', () async { await expectLater(Rx.range(1, 4).mapTo(true), emitsInOrder([true, true, true, true, emitsDone])); }); test('Rx.mapTo.shouldThrow', () async { await expectLater( Rx.range(1, 4).concatWith([Stream.error(Error())]).mapTo(true), emitsInOrder([ true, true, true, true, emitsError(TypeMatcher()), emitsDone ])); }); test('Rx.mapTo.reusable', () async { final transformer = MapToStreamTransformer(true); final stream = Rx.range(1, 4).asBroadcastStream(); stream.transform(transformer).listen(null); stream.transform(transformer).listen(null); await expectLater(true, true); }); test('Rx.mapTo.pause.resume', () async { late StreamSubscription subscription; final stream = Stream.value(1).mapTo(true); subscription = stream.listen(expectAsync1((value) { expect(value, isTrue); subscription.cancel(); }, count: 1)); subscription.pause(); subscription.resume(); }); test('Rx.mapTo accidental broadcast', () async { final controller = StreamController(); final stream = controller.stream.mapTo(1); stream.listen(null); expect(() => stream.listen(null), throwsStateError); controller.add(1); }); test('Rx.mapTo.nullable', () { nullableTest( (s) => s.mapTo('String'), ); }); }