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 ownership and updates on grant', () async {
    SharedPreferences.setMockInitialValues({});
    final repo = await SaveRepository.open();
    final container = ProviderContainer(
      overrides: [saveRepositoryProvider.overrideWithValue(repo)],
    );
    addTearDown(container.dispose);

    expect(container.read(adsRemovedProvider), isFalse);
    await container.read(adsRemovedProvider.notifier).grant();
    expect(container.read(adsRemovedProvider), isTrue);
    expect(repo.adsRemoved, isTrue);
  });
}
