From 6c8ca004bac9d71d2bb11babbe4a5a91af7c0fb7 Mon Sep 17 00:00:00 2001 From: Patrick Stewart Date: Sat, 5 Oct 2024 23:46:28 -0700 Subject: [PATCH] Remove: deleting old test helper files --- core/queue/test/helpers/app_event.dart | 17 ---- core/queue/test/helpers/dummy_event_bus.dart | 97 -------------------- core/queue/test/helpers/history_entry.dart | 8 -- core/queue/test/helpers/subscription.dart | 20 ---- 4 files changed, 142 deletions(-) delete mode 100644 core/queue/test/helpers/app_event.dart delete mode 100644 core/queue/test/helpers/dummy_event_bus.dart delete mode 100644 core/queue/test/helpers/history_entry.dart delete mode 100644 core/queue/test/helpers/subscription.dart diff --git a/core/queue/test/helpers/app_event.dart b/core/queue/test/helpers/app_event.dart deleted file mode 100644 index a6146e69..00000000 --- a/core/queue/test/helpers/app_event.dart +++ /dev/null @@ -1,17 +0,0 @@ -abstract class AppEvent { - String get timestamp; -} - -class EmptyEvent extends AppEvent { - @override - String get timestamp => DateTime.now().toIso8601String(); -} - -class EventCompletionEvent extends AppEvent { - final AppEvent completedEvent; - - EventCompletionEvent(this.completedEvent); - - @override - String get timestamp => DateTime.now().toIso8601String(); -} diff --git a/core/queue/test/helpers/dummy_event_bus.dart b/core/queue/test/helpers/dummy_event_bus.dart deleted file mode 100644 index e146b3f3..00000000 --- a/core/queue/test/helpers/dummy_event_bus.dart +++ /dev/null @@ -1,97 +0,0 @@ -import 'dart:async'; -import 'package:angel3_event_bus/event_bus.dart'; -import 'package:angel3_reactivex/subjects.dart'; -import 'package:logger/logger.dart'; -import 'app_event.dart' hide AppEvent, EmptyEvent; -import 'history_entry.dart' hide EventBusHistoryEntry; -import 'subscription.dart' hide Subscription, Responder; - -class DummyEventBus implements IEventBus { - final _logger = Logger(); - final _lastEventSubject = BehaviorSubject(); - final _inProgress = BehaviorSubject>.seeded([]); - final List _history = []; - - @override - bool get isBusy => false; - - @override - Stream get isBusy$ => Stream.value(false); - - @override - AppEvent? get last => null; - - @override - Stream get last$ => _lastEventSubject.distinct(); - - @override - Stream> get inProgress$ => _inProgress.stream; - - @override - List get history => List.unmodifiable(_history); - - @override - void fire(AppEvent event) { - _lastEventSubject.add(event); - _logger.d(' ⚡️ [${event.timestamp}] $event'); - } - - @override - void watch(AppEvent event) { - fire(event); - _inProgress.add([..._inProgress.value, event]); - } - - @override - void complete(AppEvent event, {AppEvent? nextEvent}) { - final newArr = _inProgress.value.toList()..removeWhere((e) => e == event); - _inProgress.add(newArr); - if (nextEvent != null) { - fire(nextEvent); - } - } - - @override - bool isInProgress() { - return _inProgress.value.whereType().isNotEmpty; - } - - @override - Stream on() { - if (T == dynamic) { - return _lastEventSubject.stream as Stream; - } else { - return _lastEventSubject.stream.where((event) => event is T).cast(); - } - } - - @override - Subscription respond(Responder responder) { - return Subscription(_lastEventSubject).respond(responder); - } - - @override - Stream whileInProgress() { - return _inProgress.map((events) { - return events.whereType().isNotEmpty; - }); - } - - @override - void clearHistory() { - _history.clear(); - } - - @override - void reset() { - clearHistory(); - _inProgress.add([]); - _lastEventSubject.add(EmptyEvent()); - } - - @override - void dispose() { - _inProgress.close(); - _lastEventSubject.close(); - } -} diff --git a/core/queue/test/helpers/history_entry.dart b/core/queue/test/helpers/history_entry.dart deleted file mode 100644 index 001c3f19..00000000 --- a/core/queue/test/helpers/history_entry.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'app_event.dart'; - -class EventBusHistoryEntry { - final AppEvent event; - final String timestamp; - - EventBusHistoryEntry(this.event, this.timestamp); -} diff --git a/core/queue/test/helpers/subscription.dart b/core/queue/test/helpers/subscription.dart deleted file mode 100644 index bdd89e40..00000000 --- a/core/queue/test/helpers/subscription.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:angel3_reactivex/subjects.dart'; -import 'app_event.dart'; - -typedef Responder = void Function(T event); - -class Subscription { - final BehaviorSubject _subject; - - Subscription(this._subject); - - void respond(Responder responder) { - _subject.stream.where((event) => event is T).listen((event) { - responder(event as T); - }); - } - - void dispose() { - // Implement disposal logic if needed - } -}