import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:household_keeper/core/theme/theme_provider.dart';

void main() {
  group('ThemeNotifier', () {
    setUp(() {
      SharedPreferences.setMockInitialValues({});
    });

    test('defaults to ThemeMode.system', () {
      final container = ProviderContainer();
      addTearDown(container.dispose);

      final themeMode = container.read(themeProvider);
      expect(themeMode, equals(ThemeMode.system));
    });

    test('setThemeMode(dark) updates state to dark', () async {
      final container = ProviderContainer();
      addTearDown(container.dispose);

      await container.read(themeProvider.notifier).setThemeMode(
        ThemeMode.dark,
      );
      expect(container.read(themeProvider), equals(ThemeMode.dark));
    });

    test('setThemeMode(light) updates state to light', () async {
      final container = ProviderContainer();
      addTearDown(container.dispose);

      await container.read(themeProvider.notifier).setThemeMode(
        ThemeMode.light,
      );
      expect(container.read(themeProvider), equals(ThemeMode.light));
    });
  });
}
