mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-11 14:27:39 +01:00
Some checks failed
dependency freshness / dependencies on newest stable (push) Has been cancelled
file-length / file length <= 250 lines (push) Has been cancelled
md-naming / markdown naming convention (push) Has been cancelled
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Has been cancelled
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Has been cancelled
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint) (push) Has been cancelled
Tests / test (push) Has been cancelled
release-apk / release (APK) (push) Has been cancelled
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
37 lines
1.1 KiB
Dart
37 lines
1.1 KiB
Dart
import 'package:diet_guard_app/services/activity_kcal.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
final today = DateTime(2026, 9, 28);
|
|
const run = Session(
|
|
day: '2026-09-22',
|
|
kind: 'run',
|
|
minutes: 60,
|
|
km: 6,
|
|
label: 'Run',
|
|
source: 'runnerup',
|
|
);
|
|
|
|
group('extraShare', () {
|
|
test('is zero with no past data', () {
|
|
expect(extraShare(const [], today, const {'2026-09-28': 50}), 0);
|
|
});
|
|
|
|
test('uses the same window as dailyExercise, so it adds up', () {
|
|
const steps = {'2026-09-26': 60.0, '2026-09-01': 999.0};
|
|
// The 09-01 step day stretches the window to the full 14 days but is
|
|
// itself outside it; only 09-26 counts.
|
|
final share = extraShare(const [run], today, steps);
|
|
expect(share, closeTo(60 / 14, 1e-9));
|
|
final withSteps = dailyExercise(const [run], 80, today, steps);
|
|
final without = dailyExercise(
|
|
const [run],
|
|
80,
|
|
today,
|
|
{'2026-09-01': 0.0},
|
|
);
|
|
expect(withSteps['MET']! - without['MET']!, closeTo(share, 1e-9));
|
|
});
|
|
});
|
|
}
|