use super::*;

#[test]
fn built_in_registry_is_unique_and_reflectable() {
    let mut app = App::new();
    app.add_plugins(shared::SharedTypesPlugin)
        .init_resource::<EditorComponentRegistry>();

    app.world()
        .resource::<EditorComponentRegistry>()
        .validate(app.world())
        .unwrap();
}

#[test]
fn static_extensions_cannot_shadow_stable_ids_or_types() {
    let mut registry = EditorComponentRegistry::default();
    let mut duplicate = registry.descriptors[0].clone();
    duplicate.type_name = "game::editor_ext::StaticFixture";
    assert!(registry.register(duplicate).is_err());

    let mut duplicate = registry.descriptors[0].clone();
    duplicate.id = "game.static_fixture";
    assert!(registry.register(duplicate).is_err());
}

#[test]
fn every_visible_builtin_registers_one_inspector_callback() {
    let mut world = World::new();
    world.init_resource::<EditorComponentRegistry>();

    crate::ui::inspector::register_builtin_component_inspectors(&mut world);

    assert!(world
        .resource::<EditorComponentRegistry>()
        .visible_descriptors_have_inspectors());
}
