Skip to content

Commit

Permalink
More dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
rrousselGit committed Mar 14, 2024
1 parent b3298f1 commit fa99b20
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 649 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,55 +138,6 @@ void main() {

expect(notifier.mounted, isFalse);
});

// test(
// 'overrideWithValue listens to the notifier, support notifier change, and does not dispose of the notifier',
// () async {
// final provider = ChangeNotifierProvider.autoDispose((_) => TestNotifier());
// final notifier = TestNotifier();
// final notifier2 = TestNotifier();
// final container = ProviderContainer(overrides: [
// provider.overrideWithValue(notifier),
// ]);
// addTearDown(container.dispose);

// var callCount = 0;
// final sub = container.listen(provider, (_, __) => callCount++);
// final notifierSub = container.listen(provider.notifier, (_, __) {});

// expect(sub.read(), notifier);
// expect(callCount, 0);
// expect(notifierSub.read(), notifier);
// expect(notifier.hasListeners, true);

// notifier.count++;

// await container.pump();
// expect(callCount, 1);

// container.updateOverrides([
// provider.overrideWithValue(notifier2),
// ]);

// await container.pump();
// expect(callCount, 2);
// expect(notifier.hasListeners, false);
// expect(notifier2.hasListeners, true);
// expect(notifier.mounted, true);
// expect(notifierSub.read(), notifier2);

// notifier2.count++;

// await container.pump();
// expect(callCount, 3);

// container.dispose();

// expect(callCount, 3);
// expect(notifier2.hasListeners, false);
// expect(notifier2.mounted, true);
// expect(notifier.mounted, true);
// });
}

class OnDisposeMock extends Mock {
Expand Down
86 changes: 0 additions & 86 deletions packages/flutter_riverpod/test/consumer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -490,92 +490,6 @@ void main() {
expect(buildCount, 2);
});

// testWidgets('remove listener when changing container', (tester) async {
// final notifier = TestNotifier();
// final provider = StateNotifierProvider<TestNotifier, int>((_) {
// return notifier;
// }, name: 'provider');
// final notifier2 = TestNotifier(42);
// const firstOwnerKey = Key('first');
// const secondOwnerKey = Key('second');
// final key = GlobalKey();

// final consumer = Consumer(
// builder: (context, ref, _) {
// final value = ref.watch(provider);
// return Text('$value', textDirection: TextDirection.ltr);
// },
// key: key);

// await tester.pumpWidget(
// Column(
// children: [
// ProviderScope(
// key: firstOwnerKey,
// child: consumer,
// ),
// ProviderScope(
// key: secondOwnerKey,
// overrides: [
// provider.overrideWithValue(notifier2),
// ],
// child: Container(),
// ),
// ],
// ),
// );

// final owner1 = tester //
// .firstState<ProviderScopeState>(find.byKey(firstOwnerKey))
// .container;

// final state1 = owner1
// .getAllProviderElements()
// .firstWhere((s) => s.provider == provider);

// expect(state1.hasListeners, true);
// expect(find.text('0'), findsOneWidget);

// await tester.pumpWidget(
// Column(
// children: [
// ProviderScope(
// key: firstOwnerKey,
// child: Container(),
// ),
// ProviderScope(
// key: secondOwnerKey,
// overrides: [
// provider.overrideWithValue(notifier2),
// ],
// child: consumer,
// ),
// ],
// ),
// );

// final container2 = tester //
// .firstState<ProviderScopeState>(find.byKey(secondOwnerKey))
// .container;

// final state2 = container2
// .getAllProviderElements()
// .firstWhere((s) => s.provider is StateNotifierProvider);

// expect(find.text('0'), findsNothing);
// expect(find.text('42'), findsOneWidget);
// expect(state1.hasListeners, false);
// expect(state2.hasListeners, true);

// notifier2.increment();
// await tester.pump();

// expect(find.text('0'), findsNothing);
// expect(find.text('43'), findsOneWidget);
// expect(state1.hasListeners, false);
// expect(state2.hasListeners, true);
// });

testWidgets('remove listener when destroying the consumer', (tester) async {
final notifier = TestNotifier();
final provider = StateNotifierProvider<TestNotifier, int>((_) => notifier);
Expand Down
23 changes: 0 additions & 23 deletions packages/flutter_riverpod/test/framework_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -433,29 +433,6 @@ void main() {
expect(ref.refresh(provider), null);
});

// testWidgets('ProviderScope allows specifying a ProviderContainer',
// (tester) async {
// final provider = FutureProvider((ref) async => 42);
// late WidgetRef ref;
// final container = ProviderContainer.test(overrides: [
// provider.overrideWithValue(const AsyncValue.data(42)),
// ]);

// await tester.pumpWidget(
// UncontrolledProviderScope(
// container: container,
// child: Consumer(
// builder: (context, r, _) {
// ref = r;
// return Container();
// },
// ),
// ),
// );

// expect(ref.read(provider), const AsyncValue.data(42));
// });

testWidgets('AlwaysAliveProviderBase.read(context) inside initState',
(tester) async {
final provider = Provider((_) => 42);
Expand Down
212 changes: 0 additions & 212 deletions packages/flutter_riverpod/test/future_provider_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,218 +126,6 @@ void main() {
await Future<void>.value();
});

group('overrideWithValue', () {
// var callCount = 0;
// final futureProvider = FutureProvider((s) async {
// callCount++;
// return 42;
// });

// Future<int>? future;
// var completed = false;
// final proxy = Provider<String>(
// (ref) {
// final first = ref.watch(futureProvider.future);
// future = first
// ..then(
// (value) => completed = true,
// onError: (dynamic _) => completed = true,
// );
// return '';
// },
// );

// setUp(() {
// callCount = 0;
// completed = false;
// future = null;
// });

// final child = Directionality(
// textDirection: TextDirection.ltr,
// child: Consumer(builder: (c, ref, _) {
// ref.watch(proxy);
// return ref.watch(futureProvider).when(
// data: (data) => Text(data.toString()),
// loading: () => const Text('loading'),
// error: (err, stack) {
// return const Text('error');
// },
// );
// }),
// );

// testWidgets('no-op if completed and rebuild with same value',
// (tester) async {
// await tester.pumpWidget(
// ProviderScope(
// overrides: [
// futureProvider.overrideWithValue(const AsyncValue.data(42)),
// ],
// child: child,
// ),
// );

// expect(completed, true);
// await expectLater(future, completion(42));

// await tester.pumpWidget(
// ProviderScope(
// overrides: [
// futureProvider.overrideWithValue(const AsyncValue.data(42)),
// ],
// child: child,
// ),
// );
// });

// testWidgets(
// 'FutureProviderDependency.future completes on rebuild with data',
// (tester) async {
// await tester.pumpWidget(
// ProviderScope(
// overrides: [
// futureProvider.overrideWithValue(const AsyncValue.loading()),
// ],
// child: child,
// ),
// );

// // make sure the future doesn't just complete in one frame
// await Future<void>.value();

// expect(completed, false);
// expect(future, isNotNull);

// await tester.pumpWidget(
// ProviderScope(
// overrides: [
// futureProvider.overrideWithValue(const AsyncValue.data(42)),
// ],
// child: child,
// ),
// );

// expect(completed, true);
// await expectLater(future, completion(42));
// });

// testWidgets(
// 'FutureProviderDependency.future completes on rebuild with error',
// (tester) async {
// await tester.pumpWidget(
// ProviderScope(
// overrides: [
// futureProvider.overrideWithValue(const AsyncValue.loading()),
// ],
// child: child,
// ),
// );

// // make sure the future doesn't just complete in one frame
// await Future<void>.value();

// expect(completed, false);
// expect(future, isNotNull);

// final error = Error();
// await tester.pumpWidget(
// ProviderScope(
// overrides: [
// futureProvider.overrideWithValue(AsyncValue.error(error)),
// ],
// child: child,
// ),
// );

// expect(completed, true);
// await expectLater(future, throwsA(error));
// });

// testWidgets('FutureProviderDependency.future loading to loading is no-op',
// (tester) async {
// await tester.pumpWidget(
// ProviderScope(
// overrides: [
// futureProvider.overrideWithValue(const AsyncValue.loading()),
// ],
// child: child,
// ),
// );

// expect(completed, false);
// expect(future, isNotNull);

// await tester.pumpWidget(
// ProviderScope(
// overrides: [
// futureProvider.overrideWithValue(const AsyncValue.loading()),
// ],
// child: child,
// ),
// );

// // make sure the future doesn't just complete in one frame
// await Future<void>.value();

// expect(completed, false);
// expect(future, isNotNull);
// });

// testWidgets('Initial build as loading', (tester) async {
// await tester.pumpWidget(
// ProviderScope(
// overrides: [
// futureProvider.overrideWithValue(const AsyncValue.loading()),
// ],
// child: child,
// ),
// );

// expect(callCount, 0);
// expect(find.text('loading'), findsOneWidget);

// expect(completed, false);
// expect(future, isNotNull);
// });

// testWidgets('Initial build as value', (tester) async {
// await tester.pumpWidget(
// ProviderScope(
// overrides: [
// futureProvider.overrideWithValue(const AsyncValue.data(42)),
// ],
// child: child,
// ),
// );

// expect(callCount, 0);
// expect(find.text('42'), findsOneWidget);

// expect(completed, true);
// await expectLater(future, completion(42));
// });

// testWidgets('Initial build as error', (tester) async {
// final error = Error();

// await tester.pumpWidget(
// ProviderScope(
// overrides: [
// futureProvider.overrideWithValue(AsyncValue.error(error)),
// ],
// child: child,
// ),
// );

// expect(callCount, 0);
// expect(find.text('error'), findsOneWidget);

// expect(completed, true);
// await expectLater(future, throwsA(error));
// });
});

testWidgets('FutureProvider into FutureProviderFamily', (tester) async {
final futureProvider = FutureProvider((_) async => 42);

Expand Down
Loading

0 comments on commit fa99b20

Please sign in to comment.