import 'package:block_seasons/data/save_repository.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';

void main() {
  TestWidgetsFlutterBinding.ensureInitialized();

  Future<SaveRepository> fresh() async {
    SharedPreferences.setMockInitialValues({});
    return SaveRepository(await SharedPreferences.getInstance());
  }

  test('daily claim fields start empty', () async {
    final repo = await fresh();
    expect(repo.dailyLastClaimedYmd, isNull);
    expect(repo.dailyCalendarDay, 0);
  });

  test('recordDailyClaim persists day and ymd across reload', () async {
    final repo = await fresh();
    await repo.recordDailyClaim('2026-06-18', 3);
    expect(repo.dailyLastClaimedYmd, '2026-06-18');
    expect(repo.dailyCalendarDay, 3);

    final reloaded = SaveRepository(await SharedPreferences.getInstance());
    expect(reloaded.dailyLastClaimedYmd, '2026-06-18');
    expect(reloaded.dailyCalendarDay, 3);
  });
}
