initial commit
This commit is contained in:
12
test/app/view/app_test.dart
Normal file
12
test/app/view/app_test.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
// import 'package:flutter_test/flutter_test.dart';
|
||||
// import 'package:xiao_pet_tracker/app/app.dart';
|
||||
// import 'package:xiao_pet_tracker/counter/counter.dart';
|
||||
|
||||
// void main() {
|
||||
// group('App', () {
|
||||
// testWidgets('renders CounterPage', (tester) async {
|
||||
// await tester.pumpWidget(const App());
|
||||
// expect(find.byType(CounterPage), findsOneWidget);
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
26
test/counter/cubit/counter_cubit_test.dart
Normal file
26
test/counter/cubit/counter_cubit_test.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
// import 'package:bloc_test/bloc_test.dart';
|
||||
// import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
// import 'package:xiao_pet_tracker/counter/counter.dart';
|
||||
|
||||
// void main() {
|
||||
// group('CounterCubit', () {
|
||||
// test('initial state is 0', () {
|
||||
// expect(CounterCubit().state, equals(0));
|
||||
// });
|
||||
|
||||
// blocTest<CounterCubit, int>(
|
||||
// 'emits [1] when increment is called',
|
||||
// build: CounterCubit.new,
|
||||
// act: (cubit) => cubit.increment(),
|
||||
// expect: () => [equals(1)],
|
||||
// );
|
||||
|
||||
// blocTest<CounterCubit, int>(
|
||||
// 'emits [-1] when decrement is called',
|
||||
// build: CounterCubit.new,
|
||||
// act: (cubit) => cubit.decrement(),
|
||||
// expect: () => [equals(-1)],
|
||||
// );
|
||||
// });
|
||||
// }
|
||||
68
test/counter/view/counter_page_test.dart
Normal file
68
test/counter/view/counter_page_test.dart
Normal file
@@ -0,0 +1,68 @@
|
||||
// import 'package:bloc_test/bloc_test.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
// import 'package:flutter_test/flutter_test.dart';
|
||||
// import 'package:mocktail/mocktail.dart';
|
||||
|
||||
// import 'package:xiao_pet_tracker/counter/counter.dart';
|
||||
|
||||
// import '../../helpers/helpers.dart';
|
||||
|
||||
// class MockCounterCubit extends MockCubit<int> implements CounterCubit {}
|
||||
|
||||
// void main() {
|
||||
// group('CounterPage', () {
|
||||
// testWidgets('renders CounterView', (tester) async {
|
||||
// await tester.pumpApp(const CounterPage());
|
||||
// expect(find.byType(CounterView), findsOneWidget);
|
||||
// });
|
||||
// });
|
||||
|
||||
// group('CounterView', () {
|
||||
// late CounterCubit counterCubit;
|
||||
|
||||
// setUp(() {
|
||||
// counterCubit = MockCounterCubit();
|
||||
// });
|
||||
|
||||
// testWidgets('renders current count', (tester) async {
|
||||
// const state = 42;
|
||||
// when(() => counterCubit.state).thenReturn(state);
|
||||
// await tester.pumpApp(
|
||||
// BlocProvider.value(
|
||||
// value: counterCubit,
|
||||
// child: const CounterView(),
|
||||
// ),
|
||||
// );
|
||||
// expect(find.text('$state'), findsOneWidget);
|
||||
// });
|
||||
|
||||
// testWidgets('calls increment when increment button is tapped',
|
||||
// (tester) async {
|
||||
// when(() => counterCubit.state).thenReturn(0);
|
||||
// when(() => counterCubit.increment()).thenReturn(null);
|
||||
// await tester.pumpApp(
|
||||
// BlocProvider.value(
|
||||
// value: counterCubit,
|
||||
// child: const CounterView(),
|
||||
// ),
|
||||
// );
|
||||
// await tester.tap(find.byIcon(Icons.add));
|
||||
// verify(() => counterCubit.increment()).called(1);
|
||||
// });
|
||||
|
||||
// testWidgets('calls decrement when decrement button is tapped',
|
||||
// (tester) async {
|
||||
// when(() => counterCubit.state).thenReturn(0);
|
||||
// when(() => counterCubit.decrement()).thenReturn(null);
|
||||
// await tester.pumpApp(
|
||||
// BlocProvider.value(
|
||||
// value: counterCubit,
|
||||
// child: const CounterView(),
|
||||
// ),
|
||||
// );
|
||||
// await tester.tap(find.byIcon(Icons.remove));
|
||||
// verify(() => counterCubit.decrement()).called(1);
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
1
test/helpers/helpers.dart
Normal file
1
test/helpers/helpers.dart
Normal file
@@ -0,0 +1 @@
|
||||
// export 'pump_app.dart';
|
||||
15
test/helpers/pump_app.dart
Normal file
15
test/helpers/pump_app.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_test/flutter_test.dart';
|
||||
// import 'package:xiao_pet_tracker/l10n/l10n.dart';
|
||||
|
||||
// extension PumpApp on WidgetTester {
|
||||
// Future<void> pumpApp(Widget widget) {
|
||||
// return pumpWidget(
|
||||
// MaterialApp(
|
||||
// localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
// supportedLocales: AppLocalizations.supportedLocales,
|
||||
// home: widget,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user