-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ chore(chat): Add chat bloc test. Update dependencies in pubspec.ya…
…ml and pubspec.lock files. Signed-off-by: Dmytro Turskyi <dmytro.turskyi@gmail.com>
- Loading branch information
Showing
5 changed files
with
153 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import 'package:bloc_test/bloc_test.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:laozi_ai/application_services/blocs/chat_bloc.dart'; | ||
import 'package:laozi_ai/domain_services/chat_repository.dart'; | ||
import 'package:laozi_ai/domain_services/email_repository.dart'; | ||
import 'package:laozi_ai/domain_services/settings_repository.dart'; | ||
import 'package:laozi_ai/entities/enums/language.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
|
||
// Create mock classes for the repositories. | ||
class MockChatRepository extends Mock implements ChatRepository {} | ||
|
||
class MockSettingsRepository extends Mock implements SettingsRepository {} | ||
|
||
class MockEmailRepository extends Mock implements EmailRepository {} | ||
|
||
void main() { | ||
// Define the mock instances. | ||
late MockChatRepository mockChatRepository; | ||
late MockSettingsRepository mockSettingsRepository; | ||
late MockEmailRepository mockEmailRepository; | ||
|
||
// Initialize the mock instances before each test. | ||
setUp(() { | ||
mockChatRepository = MockChatRepository(); | ||
mockSettingsRepository = MockSettingsRepository(); | ||
mockEmailRepository = MockEmailRepository(); | ||
}); | ||
|
||
// Define the test for LoadHomeEvent. | ||
blocTest<ChatBloc, ChatState>( | ||
'emits [ChatInitial] when LoadHomeEvent is added', | ||
build: () { | ||
// Set up the mock method calls | ||
when(() => mockSettingsRepository.getLanguage()).thenReturn(Language.en); | ||
// Return the ChatBloc with the mocked dependencies | ||
return ChatBloc( | ||
mockChatRepository, | ||
mockSettingsRepository, | ||
mockEmailRepository, | ||
); | ||
}, | ||
act: (ChatBloc bloc) => bloc.add(const LoadHomeEvent()), | ||
expect: () => <TypeMatcher<ChatInitial>>[ | ||
isA<ChatInitial>().having( | ||
(ChatInitial state) => state.language, | ||
'language', | ||
Language.en, | ||
), | ||
], | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.