import 'package:client_main/src/presentation/blocs/client_main_cubit.dart';
import 'package:client_main/src/presentation/blocs/client_main_state.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';

class MockIModularNavigator extends Mock implements IModularNavigator {}

void main() {
  group('ClientMainCubit', () {
    late MockIModularNavigator navigator;

    setUp(() {
      navigator = MockIModularNavigator();
      when(() => navigator.path).thenReturn('/home');
      when(() => navigator.addListener(any())).thenReturn(null);
      // Stub addListener to avoid errors when Cubit adds listener
      // Note: addListener might be on Modular directly or via some other mechanic,
      // but for this unit test we just want to suppress errors if possible or let the Cubit work.
      // Actually Modular.to.addListener calls Modular.navigatorDelegate.addListener if it exists?
      // Modular.to.addListener uses the internal RouterDelegate.
      // Mocking Modular internals is hard.

      // Let's rely on the fact that we mocked navigatorDelegate.
      Modular.navigatorDelegate = navigator;
    });

    test('initial state is correct', () {
      final ClientMainCubit cubit = ClientMainCubit();
      expect(cubit.state, const ClientMainState(currentIndex: 2));
      cubit.close();
    });

    // Note: Testing actual route changes requires more complex Modular mocking
    // or integration tests, but the structure allows it.
  });
}
