How can I test a bloc event using flutter bloc test that has a droppable (or restartable) event?
Event example:
on<SomeEvent>(
_mapSomeEvent,
transformer: droppable(),
);
I tried calling events right after the droppable event inside a flutter bloc test with no success. I also tried using Isolates and stubbing a method inside the droppable event with Future.delayed
so it takes longer to process but still didn't get the results I wanted.
Basically, I want some test like this to work:
blocTest<SomeBloc, SomeState>(
'Description',
build: () => SomeBloc(),
act: (bloc) async {
bloc.add(DroppableEvent());
bloc.add(SomeEvent());
},
expect: () => [
StateFromDroppable(),
],
);
With only one state from the droppable event, since the other should be dropped. Instead I get two sates emitted, one from the DroppableEvent
and another from SomeEvent
.