From 68ba2bce835ca42eb09a6e2fc323fad30639daf2 Mon Sep 17 00:00:00 2001 From: Satyam Jha Date: Sun, 22 Dec 2024 14:57:27 +0530 Subject: [PATCH] covered all test cases --- .../connectivity_service_test.dart | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 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 26a0ea275..d936bdd19 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 @@ -131,33 +131,46 @@ void main() { }); test('successfully listens to connectivity changes', () async { - final expectedResults = [ConnectivityResult.wifi]; + final expectedResults = [ + ConnectivityResult.mobile, + ConnectivityResult.wifi, + ]; service.connectionStatusController.stream.listen( - expectAsync1( - (List results) { - expect(results, equals(expectedResults)); - }, - count: 1, - ), + (List results) { + expect(results, equals(expectedResults)); + }, ); // Trigger the event service.connectionStatusController.add(expectedResults); }); - test('check has connection', () async { + test('check has connection - no connection', () async { connectivityStatus = [ConnectivityResult.none]; expect(await service.hasConnection(), false); + }); + test('check has connection - with connection', () async { connectivityStatus = [ConnectivityResult.mobile]; expect(await service.hasConnection(), true); + }); - // empty list + test('check has connection - empty list', () async { connectivityStatus = []; expect(await service.hasConnection(), false); }); + test('check has connection - mixed results', () async { + connectivityStatus = [ConnectivityResult.none, ConnectivityResult.wifi]; + expect(await service.hasConnection(), true); + }); + + test('check has connection - all none', () async { + connectivityStatus = [ConnectivityResult.none, ConnectivityResult.none]; + expect(await service.hasConnection(), false); + }); + test('isReachable', () async { final reached = await service.isReachable( client: mockClient,