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('soundEnabled defaults true and persists across reopen', () async {
    final repo = await SaveRepository.open();
    expect(repo.soundEnabled, isTrue);
    await repo.setSoundEnabled(false);
    expect(repo.soundEnabled, isFalse);
    final reopened = await SaveRepository.open();
    expect(reopened.soundEnabled, isFalse);
  });

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