Hey, so I've got a Cubit that initialized with an initial "event" (FeedCubit(...)..fetchFeed(...)) , a couple of the tests used to look something like this:
blocTest<FeedCubit, FeedState>(
'Increments Reaction count on React Event',
build: () **async** {
when(mockReactToPost(any)).thenAnswer(
(_) async => Right(tPostReact),
);
when(mockGetFeed(any)).thenAnswer((_) async => Right(tFeed));
when(mockGetFeedPosts(any)).thenAnswer((_) async => Right(feedPosts));
**await feedCubit.fetchFeed(...);**
return feedCubit;
},
act: (cubit) {
cubit.reactToPost(
feedId: tFeed.id,
postId: tPostId,
reactionId: tReactionId,
);
},
expect: [
FeedState.loaded(
feed: tFeed,
feedPosts: tFeedPostsIncremented,
currentFeedView: CurrentFeedView.postListView,
),
],
);
But now the build param doesn't take a Future. I've been trying a couple of different ways to get that initial "Event" to fire off but haven't been successful. Any help is appreciated 馃槃
Ok I read the docs 馃憤
Answer:
blocTest<FeedCubit, FeedState>(
'Increments Reaction count on React Event',
build: () {
when(mockReactToPost(any)).thenAnswer(
(_) async => Right(tPostReact),
);
return feedCubit
..emit(FeedLoaded(
feed: tFeed,
feedPosts: tFeedPosts,
currentFeedView: CurrentFeedView.postListView,
));
},
act: (cubit) {
cubit.reactToPost(
feedId: tFeed.id,
postId: tPostId,
reactionId: tReactionId,
);
},
expect: [
FeedState.loaded(
feed: tFeed,
feedPosts: tFeedPostsIncremented,
currentFeedView: CurrentFeedView.postListView,
),
],
);
Most helpful comment
Ok I read the docs 馃憤
Answer: