Reputation: 6157
This is my test:
MockBloc bloc = MockBloc();
when (bloc.state).thenAnswer((_) => State)
I want to give a specific state, but, if I try to simply write MyState()
there, the IDE will just say
isn't a Stream< blocState >
How can I pass the State
?
Upvotes: 0
Views: 515
Reputation: 2711
You have to make your mock return a stream of states, not state object.
final controller = StreamController<BlocState>();
when(bloc.state).thenAnswer((_) => controller.stream);
Then you can add new states to controller
controller.add(MyState());
Upvotes: 1