diff --git a/src/ui/mod.rs b/src/ui/mod.rs index f77092d..ba51e35 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -12,6 +12,8 @@ mod setup_test; #[cfg(test)] mod curriculum_test; pub mod systems; +#[cfg(test)] +mod systems_test; pub mod target; use bevy::prelude::*; diff --git a/src/ui/systems_test.rs b/src/ui/systems_test.rs new file mode 100644 index 0000000..54b1daa --- /dev/null +++ b/src/ui/systems_test.rs @@ -0,0 +1,35 @@ +use bevy::prelude::*; +use bevy::app::TaskPoolPlugin; +use crate::components::CurriculumGradeButton; +use crate::resources::CurriculumState; +use crate::ui::systems::curriculum_grade_system; + +#[test] +fn test_curriculum_grade_system() { + let mut app = App::new(); + app.add_plugins(TaskPoolPlugin::default()); + + // Setup initial state + let mut state = CurriculumState::default(); + state.selected_grade = Some("Niveau 1.1".to_string()); + state.selected_document = Some("Passage de Grade 1.1".to_string()); + app.insert_resource(state); + + // Spawn button with pressed interaction + app.world_mut().spawn(( + CurriculumGradeButton, + Interaction::Pressed, + )); + + app.add_systems(Update, curriculum_grade_system); + + // Run app to process the interaction + app.update(); + + let new_state = app.world().resource::(); + + // According to CURRICULUM_MANIFEST, the grades sorted are "Niveau 1.1" and "Niveau 1.2" + // So if current is "Niveau 1.1", next should be "Niveau 1.2" + assert_eq!(new_state.selected_grade, Some("Niveau 1.2".to_string())); + assert_eq!(new_state.selected_document, Some("Passage de grade 1.2".to_string())); +}