mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-16 17:27:39 +00:00
81 lines
2.7 KiB
Dart
81 lines
2.7 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart';
|
|
import 'package:stackwallet/services/event_bus/events/global/refresh_percent_changed_event.dart';
|
|
import 'package:stackwallet/services/event_bus/events/global/updated_in_background_event.dart';
|
|
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
|
|
import 'package:stackwallet/services/event_bus/global_event_bus.dart';
|
|
import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin.dart';
|
|
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
|
|
|
void main() {
|
|
test("NodeConnectionStatusChangedEvent", () async {
|
|
final listener = GlobalEventBus.instance
|
|
.on<NodeConnectionStatusChangedEvent>()
|
|
.listen((event) {
|
|
expect(event.newStatus, NodeConnectionStatus.connected);
|
|
expect(event.walletId, "some wallet ID");
|
|
expect(event.coin, Bitcoin(CryptoCurrencyNetwork.main));
|
|
});
|
|
expect(
|
|
() => GlobalEventBus.instance.fire(
|
|
NodeConnectionStatusChangedEvent(
|
|
NodeConnectionStatus.connected,
|
|
"some wallet ID",
|
|
Bitcoin(CryptoCurrencyNetwork.main),
|
|
),
|
|
),
|
|
returnsNormally,
|
|
);
|
|
listener.cancel();
|
|
});
|
|
|
|
test("RefreshPercentChangedEvent", () async {
|
|
final listener = GlobalEventBus.instance
|
|
.on<RefreshPercentChangedEvent>()
|
|
.listen((event) {
|
|
expect(event.percent, 0.5);
|
|
expect(event.walletId, "some id");
|
|
});
|
|
expect(
|
|
() => GlobalEventBus.instance
|
|
.fire(RefreshPercentChangedEvent(0.5, "some id")),
|
|
returnsNormally,
|
|
);
|
|
listener.cancel();
|
|
});
|
|
|
|
test("UpdatedInBackgroundEvent", () async {
|
|
final listener =
|
|
GlobalEventBus.instance.on<UpdatedInBackgroundEvent>().listen((event) {
|
|
expect(event.message, "some message string");
|
|
expect(event.walletId, "wallet Id");
|
|
});
|
|
expect(
|
|
() => GlobalEventBus.instance
|
|
.fire(UpdatedInBackgroundEvent("some message string", "wallet Id")),
|
|
returnsNormally,
|
|
);
|
|
listener.cancel();
|
|
});
|
|
|
|
test("ActiveWalletNameChangedEvent", () async {
|
|
final listener = GlobalEventBus.instance
|
|
.on<WalletSyncStatusChangedEvent>()
|
|
.listen((event) {
|
|
expect(event.newStatus, WalletSyncStatus.syncing);
|
|
expect(event.walletId, "wallet Id");
|
|
expect(event.coin, Bitcoin(CryptoCurrencyNetwork.main));
|
|
});
|
|
expect(
|
|
() => GlobalEventBus.instance.fire(
|
|
WalletSyncStatusChangedEvent(
|
|
WalletSyncStatus.syncing,
|
|
"wallet Id",
|
|
Bitcoin(CryptoCurrencyNetwork.main),
|
|
),
|
|
),
|
|
returnsNormally,
|
|
);
|
|
listener.cancel();
|
|
});
|
|
}
|