use bevy::{prelude::*, state::app::StatesPlugin};
use bevy_assert::AppTest;

#[derive(States, Debug, Clone, PartialEq, Eq, Hash, Default)]
enum MyState {
    #[default]
    Off,
    On,
}

#[test]
fn test_state_not_found() {
    let t = AppTest::new();
    assert_eq!(
        &t.assert_state_r(&MyState::On).err().unwrap(),
        "State not found"
    );
}

#[test]
fn test_state_not_equal() {
    let mut t = AppTest::new();
    t.add_plugins(StatesPlugin);
    t.init_state::<MyState>();
    assert_eq!(
        &t.assert_state_r(&MyState::On).err().unwrap(),
        "State was not equal: Off != On"
    );
}

#[test]
fn test_state_equal() {
    let mut t = AppTest::new();
    t.add_plugins(StatesPlugin);
    t.init_state::<MyState>();
    t.assert_state_r(&MyState::Off).unwrap();
    t.assert_state(&MyState::Off);
}
