Skip to content

Commit

Permalink
chore: test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillSergeevich committed Aug 1, 2023
1 parent 4fd011e commit ee9295e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
8 changes: 0 additions & 8 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.0.5"
rxdart:
dependency: transitive
description:
name: rxdart
sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb"
url: "https://pub.dev"
source: hosted
version: "0.27.7"
sky_engine:
dependency: transitive
description: flutter
Expand Down
3 changes: 2 additions & 1 deletion lib/src/data/repositories/suggestion_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class SuggestionRepositoryImpl implements SuggestionRepository {
SimpleBehaviorSubject<List<Suggestion>>([]);

@override
Stream<List<Suggestion>> get suggestionsStream => _suggestionsSubject.stream();
Stream<List<Suggestion>> get suggestionsStream =>
_suggestionsSubject.stream();

@override
List<Suggestion> get suggestions => _suggestionsSubject.value;
Expand Down
11 changes: 5 additions & 6 deletions test/presentation/cubits/suggestions_cubit_test.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:bloc_test/bloc_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:rxdart/rxdart.dart';
import 'package:suggest_a_feature/src/domain/entities/suggestion.dart';
import 'package:suggest_a_feature/src/domain/utils/simple_behavior_subject.dart';
import 'package:suggest_a_feature/src/presentation/di/injector.dart';
import 'package:suggest_a_feature/src/presentation/pages/suggestions/suggestions_cubit.dart';
import 'package:suggest_a_feature/src/presentation/pages/suggestions/suggestions_state.dart';
Expand Down Expand Up @@ -119,19 +119,18 @@ void main() {
blocTest<SuggestionsCubit, SuggestionsState>(
'vote requested suggestion',
build: () {
final dataStream = BehaviorSubject.seeded([
final dataStream = SimpleBehaviorSubject([
mockedRequestSuggestion,
mockedRequestSuggestion2,
]);

when(mockSuggestionRepository.suggestionsStream).thenAnswer(
(_) => dataStream,
(_) => dataStream.stream(),
);

when(mockSuggestionRepository.upvote(any)).thenAnswer(
(_) async => dataStream.add(
[mockedRequestSuggestion, upvotedSuggestion],
),
(_) async =>
dataStream.value = [mockedRequestSuggestion, upvotedSuggestion],
);

return SuggestionsCubit(
Expand Down

0 comments on commit ee9295e

Please sign in to comment.