Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
tanguymossion committed Aug 22, 2024
1 parent ff2a374 commit 5e1b2db
Showing 1 changed file with 0 additions and 44 deletions.
44 changes: 0 additions & 44 deletions test/src/refresh_when_network_available_extension_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,50 +76,6 @@ void main() {
});

group('ConnectivityStreamProvider tests', () {
test('provides connectivity stream with expected values', () async {
final mockConnectivity = MockConnectivity();

// Simulate the connectivity stream emitting the following values:
final connectivityStream = Stream<List<ConnectivityResult>>.fromIterable([
[ConnectivityResult.none],
[ConnectivityResult.mobile],
[ConnectivityResult.wifi],
]);

when(() => mockConnectivity.onConnectivityChanged)
.thenAnswer((_) => connectivityStream);

final container = ProviderContainer(
overrides: [
connectivityStreamProvider.overrideWith(
(StreamProviderRef<List<ConnectivityResult>> ref) =>
mockConnectivity.onConnectivityChanged.distinct(),
),
],
);

final emittedValues = <List<ConnectivityResult>>[];

// Listen to the connectivity stream provider
final listener = container.listen<AsyncValue<List<ConnectivityResult>>>(
connectivityStreamProvider, (previous, next) {
if (next.hasValue) {
emittedValues.add(next.value!);
}
});

// Wait for the stream to emit all values
await Future<void>.delayed(const Duration(milliseconds: 100));

listener.close();

expect(emittedValues, [
[ConnectivityResult.none],
[ConnectivityResult.mobile],
[ConnectivityResult.wifi],
]);
});

test('connectivityStreamProvider provides an AsyncValue', () {
final container = ProviderContainer();
final providerState = container.read(connectivityStreamProvider);
Expand Down

0 comments on commit 5e1b2db

Please sign in to comment.