Skip to content

Commit

Permalink
covered test all cases 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Satyam Jha committed Dec 24, 2024
1 parent de418ce commit 659e8ac
Showing 1 changed file with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectivityResult> results) {
expect(results, [ConnectivityResult.mobile]);
}),
final testResults = [ConnectivityResult.wifi];

// First verify the mock works
expect(
mockConnectivity.onConnectivityChanged,
isA<Stream<List<ConnectivityResult>>>(),
);

// Then verify the service stream
expect(
actualService.connectionStream,
isA<Stream<List<ConnectivityResult>>>(),
);

// Listen to both streams
mockConnectivity.onConnectivityChanged.listen(
expectAsync1(
(List<ConnectivityResult> results) {
expect(results, isA<List<ConnectivityResult>>());
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 {
Expand Down

0 comments on commit 659e8ac

Please sign in to comment.