mirror of
https://github.com/wger-project/flutter.git
synced 2026-11-29 01:18:35 +01:00
Fix tests
This commit is contained in:
@@ -221,6 +221,15 @@ void main() {
|
||||
});
|
||||
|
||||
group('watchOfficialBodyWeightCategory', () {
|
||||
/// The entries with their dates back in UTC.
|
||||
///
|
||||
/// Drift hands them over in the local zone (UtcDateTimeConverter), and a
|
||||
/// DateTime only equals another one in the same zone, so comparing against
|
||||
/// the UTC fixtures passes in UTC and nowhere else.
|
||||
List<MeasurementEntry> inUtc(Iterable<MeasurementEntry> entries) => [
|
||||
for (final entry in entries) entry.copyWith(date: entry.date.toUtc()),
|
||||
];
|
||||
|
||||
Future<void> seedBodyWeight() async {
|
||||
await repo.addLocalDriftCategory(getBodyWeightCategory());
|
||||
for (final entry in [testWeightEntry1, testWeightEntry2]) {
|
||||
@@ -235,7 +244,7 @@ void main() {
|
||||
final emitted = await repo.watchOfficialBodyWeightCategory().first;
|
||||
|
||||
expect(emitted!.id, testBodyWeightCategoryId);
|
||||
expect(emitted.entries, [testWeightEntry2, testWeightEntry1]);
|
||||
expect(inUtc(emitted.entries), [testWeightEntry2, testWeightEntry1]);
|
||||
});
|
||||
|
||||
test('a category of the same type that is not official is ignored', () async {
|
||||
@@ -267,7 +276,7 @@ void main() {
|
||||
.watchOfficialBodyWeightCategory(entriesSince: DateTime.utc(2021, 01, 05))
|
||||
.first;
|
||||
|
||||
expect(emitted!.entries, [testWeightEntry2]);
|
||||
expect(inUtc(emitted!.entries), [testWeightEntry2]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -40,10 +40,16 @@ void main() {
|
||||
|
||||
setUp(() {
|
||||
mockMeasurementRepo = MockMeasurementRepository();
|
||||
when(mockMeasurementRepo.watchAll()).thenAnswer(
|
||||
(_) => Stream.value([
|
||||
// The chart reads the official category through bodyWeightCategoryProvider,
|
||||
// not the whole list
|
||||
when(
|
||||
mockMeasurementRepo.watchOfficialBodyWeightCategory(
|
||||
entriesSince: anyNamed('entriesSince'),
|
||||
),
|
||||
).thenAnswer(
|
||||
(_) => Stream.value(
|
||||
getBodyWeightCategory([testWeightEntry2, testWeightEntry1, testWeightEntryLb]),
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
||||
mockUserProfileRepo = MockUserProfileRepository();
|
||||
|
||||
Reference in New Issue
Block a user