Skip to content

Commit

Permalink
feat(#668): add provider to drug page tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Nov 22, 2023
1 parent abcff68 commit fc29ce2
Showing 1 changed file with 48 additions and 38 deletions.
86 changes: 48 additions & 38 deletions app/integration_test/drugs_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:provider/provider.dart';

class MockDrugsCubit extends MockCubit<DrugState> implements DrugCubit {}

Expand Down Expand Up @@ -83,21 +84,24 @@ void main() {
late BuildContext context;

await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Builder(
builder: (context) {
return DrugPage(testDrug, cubit: mockDrugsCubit);
},
ChangeNotifierProvider(
create: (context) => ActiveDrugs(),
child: MaterialApp(
home: Scaffold(
body: Builder(
builder: (context) {
return DrugPage(testDrug, cubit: mockDrugsCubit);
},
),
),
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [Locale('en', '')],
),
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [Locale('en', '')],
),
);

Expand Down Expand Up @@ -151,24 +155,27 @@ void main() {
DrugState.loaded());

await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Builder(
builder: (context) {
return DrugPage(
testDrugWithoutGuidelines,
cubit: mockDrugsCubit,
);
},
ChangeNotifierProvider(
create: (context) => ActiveDrugs(),
child: MaterialApp(
home: Scaffold(
body: Builder(
builder: (context) {
return DrugPage(
testDrugWithoutGuidelines,
cubit: mockDrugsCubit,
);
},
),
),
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [Locale('en', '')],
),
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [Locale('en', '')],
),
);

Expand All @@ -180,15 +187,18 @@ void main() {
when(() => mockDrugsCubit.state).thenReturn(DrugState.loading());

await tester.pumpWidget(
MaterialApp(
home: DrugPage(testDrug, cubit: mockDrugsCubit),
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [Locale('en', '')],
ChangeNotifierProvider(
create: (context) => ActiveDrugs(),
child: MaterialApp(
home: DrugPage(testDrug, cubit: mockDrugsCubit),
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [Locale('en', '')],
),
),
);

Expand Down

0 comments on commit fc29ce2

Please sign in to comment.