use bevy_ecs::prelude::*;
use wintf::ecs::widget::shapes::Rectangle;
use wintf::ecs::widget::text::Label;
use wintf::ecs::Visual;
#[test]
fn test_label_auto_inserts_visual() {
let mut world = World::new();
let entity = world
.spawn(Label {
text: "Hello".to_string(),
..Default::default()
})
.id();
let visual = world.get::<Visual>(entity);
assert!(
visual.is_some(),
"Visual should be auto-added when Label is inserted"
);
}
#[test]
fn test_rectangle_auto_inserts_visual() {
let mut world = World::new();
let entity = world.spawn(Rectangle::new()).id();
let visual = world.get::<Visual>(entity);
assert!(
visual.is_some(),
"Visual should be auto-added when Rectangle is inserted"
);
}
#[test]
fn test_label_with_existing_visual() {
let mut world = World::new();
let entity = world
.spawn((
Visual {
opacity: 0.5,
..Default::default()
},
Label {
text: "Test".to_string(),
..Default::default()
},
))
.id();
let visual = world.get::<Visual>(entity).expect("Visual should exist");
assert!(visual.is_visible);
}
#[test]
fn test_multiple_widgets_get_visuals() {
let mut world = World::new();
let label_entity = world
.spawn(Label {
text: "Label".to_string(),
..Default::default()
})
.id();
let rect_entity = world.spawn(Rectangle::new()).id();
assert!(world.get::<Visual>(label_entity).is_some());
assert!(world.get::<Visual>(rect_entity).is_some());
}