From 659e8acb6c29c1b5fcd0719d9518160d366db6fe Mon Sep 17 00:00:00 2001 From: Satyam Jha Date: Wed, 25 Dec 2024 04:07:37 +0530 Subject: [PATCH] covered test all cases 2 --- .../connectivity_service_test.dart | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/test/service_tests/third_party_service_test.dart/connectivity_service_test.dart b/test/service_tests/third_party_service_test.dart/connectivity_service_test.dart index f51251a2d..207f99fd2 100644 --- a/test/service_tests/third_party_service_test.dart/connectivity_service_test.dart +++ b/test/service_tests/third_party_service_test.dart/connectivity_service_test.dart @@ -136,15 +136,33 @@ void main() { }); test('enableSubscription with actual service', () async { - // Test that the stream receives the connectivity change - actualService.connectionStream.listen( - expectAsync1((List results) { - expect(results, [ConnectivityResult.mobile]); - }), + final testResults = [ConnectivityResult.wifi]; + + // First verify the mock works + expect( + mockConnectivity.onConnectivityChanged, + isA>>(), + ); + + // Then verify the service stream + expect( + actualService.connectionStream, + isA>>(), + ); + + // Listen to both streams + mockConnectivity.onConnectivityChanged.listen( + expectAsync1( + (List results) { + expect(results, isA>()); + expect(results, equals(testResults)); + }, + count: 1, + ), ); - // Trigger the connectivity change - actualService.connectionStatusController.add([ConnectivityResult.mobile]); + // Emit and wait + mockConnectivity.emitConnectivityChange(testResults); }); test('hasConnection - with connection', () async {