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

void main() {
  setUp(() => SharedPreferences.setMockInitialValues({}));

  test('adsRemoved defaults to false and persists across reopen', () async {
    final repo = await SaveRepository.open();
    expect(repo.adsRemoved, isFalse);
    await repo.setAdsRemoved(true);
    expect(repo.adsRemoved, isTrue);

    final reopened = await SaveRepository.open();
    expect(reopened.adsRemoved, isTrue);
  });

  test('legacy save without the ads flag reads as false', () async {
    SharedPreferences.setMockInitialValues({
      'save_v1': '{"saveVersion":1,"progress":{},"flags":{"tutorialDone":true}}',
    });
    final repo = await SaveRepository.open();
    expect(repo.adsRemoved, isFalse);
    expect(repo.tutorialDone, isTrue);
  });
}
