forked from eatvio/eatvio_app
feat(insights): added kbju fetching for analitics
This commit is contained in:
34
test/fixtures/doubles/insights_doubles.dart
vendored
34
test/fixtures/doubles/insights_doubles.dart
vendored
@@ -17,11 +17,20 @@ class FakeInsightsRepository extends Fake implements InsightsRepository {
|
||||
|
||||
InsightsPayloadModel payload;
|
||||
|
||||
/// Ответ [fetchIntra] по запрошенной дате (`YYYY-MM-DD`); для остальных дат
|
||||
/// берётся `payload.intra`.
|
||||
final Map<String, IntraChartModel> intraByDate = {};
|
||||
|
||||
/// Если задан — выбрасывается из [fetchIntra].
|
||||
Object? intraError;
|
||||
|
||||
/// Если задан — выбрасывается из [getInsights] (например, [InsightsForbidden]).
|
||||
Object? error;
|
||||
int? heightCm;
|
||||
|
||||
final List<({String? slug, BodyPeriod period})> insightsRequests = [];
|
||||
final List<({String? slug, BodyPeriod bodyPeriod, DailyPeriod dailyPeriod, String? intraDate})> serverRequests = [];
|
||||
final List<({String? slug, String? date})> intraRequests = [];
|
||||
final List<double> addedWeights = [];
|
||||
final List<({int chest, int waist, int hip})> addedCircumferences = [];
|
||||
|
||||
@@ -38,6 +47,31 @@ class FakeInsightsRepository extends Fake implements InsightsRepository {
|
||||
return payload;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<InsightsPayloadModel> fetchInsights({
|
||||
String? slug,
|
||||
required BodyPeriod bodyPeriod,
|
||||
required DailyPeriod dailyPeriod,
|
||||
String? intraDate,
|
||||
}) async {
|
||||
serverRequests.add((slug: slug, bodyPeriod: bodyPeriod, dailyPeriod: dailyPeriod, intraDate: intraDate));
|
||||
final failure = error;
|
||||
if (failure != null) {
|
||||
throw failure;
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<IntraChartModel> fetchIntra({String? slug, String? intraDate}) async {
|
||||
intraRequests.add((slug: slug, date: intraDate));
|
||||
final failure = intraError ?? error;
|
||||
if (failure != null) {
|
||||
throw failure;
|
||||
}
|
||||
return intraByDate[intraDate] ?? payload.intra!;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> addWeight({required double weight}) async {
|
||||
addedWeights.add(weight);
|
||||
|
||||
Reference in New Issue
Block a user