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

void main() {
  test('reads persisted sound flag and toggles + persists', () async {
    SharedPreferences.setMockInitialValues({});
    final repo = await SaveRepository.open();
    final c = ProviderContainer(
      overrides: [saveRepositoryProvider.overrideWithValue(repo)],
    );
    addTearDown(c.dispose);

    expect(c.read(soundEnabledProvider), isTrue);
    await c.read(soundEnabledProvider.notifier).toggle();
    expect(c.read(soundEnabledProvider), isFalse);
    expect(repo.soundEnabled, isFalse);
  });
}
