Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add test for two subsequent state changes to flame_multi_bloc_provider_test.dart #2381

Merged
merged 4 commits into from
Mar 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/flame_bloc/test/src/flame_multi_bloc_provider_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,34 @@ void main() {
expect(player.lastState, equals(PlayerState.sad));
expect(inventory.lastState, equals(InventoryState.bow));
});

testWithFlameGame(
'can listen to multiple subsequent state changes',
(game) async {
final playerCubit = PlayerCubit();
late PlayerListener player;

final provider = FlameMultiBlocProvider(
providers: [
FlameBlocProvider<PlayerCubit, PlayerState>.value(
value: playerCubit,
),
],
children: [
player = PlayerListener(),
],
);
await game.ensureAdd(provider);

playerCubit.kill();
await Future<void>.microtask(() {});
expect(player.lastState, equals(PlayerState.dead));

playerCubit.riseFromTheDead();
await Future<void>.microtask(() {});
expect(player.lastState, equals(PlayerState.alive));
},
);
});
});
}