diet-guard/app/test/models/day_status_test.dart
Krzysztof kuhy Rudnicki 957769ff0e
Some checks are pending
pre-commit / pre-commit (push) Waiting to run
Tests / test (3.10) (push) Waiting to run
Tests / test (3.11) (push) Waiting to run
Tests / test (3.12) (push) Waiting to run
Add budget-adherence calendar, streaks, and freely-editable synced budget
Both platforms gain a calendar tab/screen (green/yellow/red/not-logged
day coloring, logging/adherence streaks, year-to-date tally), and
tapping a day drills into that day's logged entries. This requires the
daily budget to become a normal, freely-editable value synced between
devices like the food log — replaces the previous chattr +i seal
(deliberately, per user decision) with plain last-edit-wins sync via a
new budget.json alongside food_log.json. The budget field defaults to
2200 kcal, starts read-only, and unlocks via an Edit/Save toggle on
both the PC gate's History tab and the phone app's Calendar screen.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dHac1iYQKTMZEtL7xDJvA
2026-07-13 21:31:45 +02:00

40 lines
1.3 KiB
Dart

import 'package:diet_guard_app/models/day_status.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('YtdTally', () {
test('equal tallies compare equal and share hashCode', () {
const a = YtdTally(loggedDays: 5, elapsedDays: 10, adherentDays: 3);
const b = YtdTally(loggedDays: 5, elapsedDays: 10, adherentDays: 3);
expect(a, equals(b));
expect(a.hashCode, equals(b.hashCode));
});
test('differing tallies compare unequal', () {
const a = YtdTally(loggedDays: 5, elapsedDays: 10, adherentDays: 3);
const b = YtdTally(loggedDays: 4, elapsedDays: 10, adherentDays: 3);
expect(a, isNot(equals(b)));
});
test('is not equal to an unrelated object', () {
const a = YtdTally(loggedDays: 5, elapsedDays: 10, adherentDays: 3);
const Object other = 'not a tally';
expect(a == other, isFalse);
});
test('toString is human-readable', () {
const a = YtdTally(loggedDays: 5, elapsedDays: 10, adherentDays: 3);
expect(a.toString(), 'YtdTally(logged: 5/10, adherent: 3)');
});
});
test('DayStatus has exactly the four expected values', () {
expect(DayStatus.values, [
DayStatus.notLogged,
DayStatus.red,
DayStatus.yellow,
DayStatus.green,
]);
});
}