main
1import 'package:blood_pressure_app/data_util/full_entry_builder.dart';
2import 'package:blood_pressure_app/model/storage/interval_store.dart';
3import 'package:flutter/material.dart';
4import 'package:blood_pressure_app/l10n/app_localizations.dart';
5import 'package:flutter_test/flutter_test.dart';
6import 'package:health_data_store/health_data_store.dart';
7
8import '../features/measurement_list/measurement_list_entry_test.dart';
9import '../model/analyzer_test.dart';
10import '../util.dart';
11
12void main() {
13 testWidgets('loads expected data', (tester) async {
14 final records = [mockRecord(sys: 123)];
15 final notes = [Note(time: DateTime(2000), note: 'test1'), Note(time: DateTime(2001), note: 'test2')];
16 final intakes = [mockIntake(mockMedicine()), mockIntake(mockMedicine()), mockIntake(mockMedicine())];
17
18 final mainIntervalls = IntervalStorage();
19 mainIntervalls.changeStepSize(TimeStep.lifetime);
20
21 await tester.pumpWidget(await appBaseWithData(FullEntryBuilder(
22 rangeType: IntervalStoreManagerLocation.mainPage,
23 onData: (context, foundRecords, foundIntakes, foundNotes) {
24 expect(foundRecords, records);
25 expect(foundIntakes, intakes);
26 expect(foundNotes, notes);
27 return const Text('ok');
28 },
29 ), records: records, intakes: intakes, notes: notes, intervallStoreManager: IntervalStoreManager(mainIntervalls, IntervalStorage(), IntervalStorage())));
30
31 final localizations = await AppLocalizations.delegate.load(const Locale('en'));
32 expect(find.text(localizations.loading), findsOneWidget);
33 await tester.pumpAndSettle();
34 expect(find.text('ok'), findsOneWidget);
35 });
36 testWidgets('loads sorted entries', (tester) async {
37 final notes = [Note(time: DateTime(2003), note: 'test0'), Note(time: DateTime(2000), note: 'test1'), Note(time: DateTime(2001), note: 'test2')];
38
39 final exportPageIntervalls = IntervalStorage();
40 exportPageIntervalls.changeStepSize(TimeStep.lifetime);
41
42 await tester.pumpWidget(await appBaseWithData(FullEntryBuilder(
43 rangeType: IntervalStoreManagerLocation.exportPage,
44 onEntries: (context, entries) {
45 expect(entries, hasLength(3));
46 expect(entries[0].time.year, 2003);
47 expect(entries[1].time.year, 2001);
48 expect(entries[2].time.year, 2000);
49 return const Text('ok');
50 },
51 ), notes: notes, intervallStoreManager: IntervalStoreManager(exportPageIntervalls, IntervalStorage(), IntervalStorage())));
52
53 final localizations = await AppLocalizations.delegate.load(const Locale('en'));
54 expect(find.text(localizations.loading), findsOneWidget);
55 await tester.pumpAndSettle();
56 expect(find.text('ok'), findsOneWidget);
57 });
58}