import 'package:flutter_test/flutter_test.dart'; import 'package:bookshelf_flutter/features/home/bloc/home_bloc.dart'; import 'package:bookshelf_flutter/features/home/bloc/home_event.dart'; import 'package:bookshelf_flutter/features/home/bloc/home_state.dart'; import 'package:bookshelf_flutter/models/models.dart'; void main() { group('HomeBloc', () { late HomeBloc homeBloc; setUp(() { homeBloc = HomeBloc(); }); tearDown(() { homeBloc.close(); }); test('initial state is HomeState.initial()', () { expect(homeBloc.state, isA()); expect(homeBloc.state.isLoading, true); }); group('LoadHomeData', () { test('loads home data with default screen', () async { homeBloc.add(const LoadHomeData()); await Future.delayed(Duration.zero); expect(homeBloc.state.currentScreen, AppScreen.library); expect(homeBloc.state.isLoading, false); }); }); group('NavigateToScreen', () { test('navigates to library screen', () async { homeBloc.add(const NavigateToScreen(AppScreen.library)); await Future.delayed(Duration.zero); expect(homeBloc.state.currentScreen, AppScreen.library); }); test('navigates to categories screen', () async { homeBloc.add(const NavigateToScreen(AppScreen.categories)); await Future.delayed(Duration.zero); expect(homeBloc.state.currentScreen, AppScreen.categories); }); test('navigates to wishlist screen', () async { homeBloc.add(const NavigateToScreen(AppScreen.wishlist)); await Future.delayed(Duration.zero); expect(homeBloc.state.currentScreen, AppScreen.wishlist); }); test('navigates to settings screen', () async { homeBloc.add(const NavigateToScreen(AppScreen.settings)); await Future.delayed(Duration.zero); expect(homeBloc.state.currentScreen, AppScreen.settings); }); test('navigates to details screen', () async { homeBloc.add(const NavigateToScreen(AppScreen.details)); await Future.delayed(Duration.zero); expect(homeBloc.state.currentScreen, AppScreen.details); }); test('navigates to add book screen', () async { homeBloc.add(const NavigateToScreen(AppScreen.addBook)); await Future.delayed(Duration.zero); expect(homeBloc.state.currentScreen, AppScreen.addBook); }); test('navigates to scanner screen', () async { homeBloc.add(const NavigateToScreen(AppScreen.scanner)); await Future.delayed(Duration.zero); expect(homeBloc.state.currentScreen, AppScreen.scanner); }); }); }); }