1pub use set_with_grab_macro::set_with_grab;
2
3#[cfg(test)]
4mod intergration_test {
5 use super::set_with_grab;
6 use bevy::prelude::*;
7 use rstest::*;
8
9 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
10 enum MockState {
11 Before,
12 After,
13 }
14
15 fn setter_with_grab(mut state: ResMut<State<MockState>>) {
16 set_with_grab!(state, MockState::After);
17 }
20
21 #[fixture]
22 fn app() -> App {
23 let mut app = App::new();
24 app.add_plugins(MinimalPlugins).add_state(MockState::Before);
25 app
26 }
27
28 #[rstest]
29 fn change_state_with_grab(mut app: App) {
30 app.add_system_set(
31 SystemSet::on_update(MockState::Before)
32 .with_system(setter_with_grab),
33 );
34 app.update();
35 let state = app.world.resource_mut::<State<MockState>>();
36 match state.current() {
37 MockState::After => {}
38 MockState::Before => {
39 panic!("the state is before, yet.");
40 }
41 }
42 }
43}