extern crate builderx_core as builderx;

use gpui::{div, prelude::*, px, rgb};
use builderx_gpui::GpuiAdapter;
use builderx_macros::bx;

#[test]
fn builds_element_with_modifiers_and_children() {
    let mut element = bx! {
        GpuiAdapter =>
        div[flex, gap_2, bg(rgb(0x111111))]{
            "hello",
            bx! { GpuiAdapter => div[border_1, border_color(rgb(0xffffff))]{} }
        }
    };

    assert_eq!(element.style().display, Some(gpui::Display::Flex));
    assert!(element.style().gap.width.is_some());
    let _any = element.into_any_element();
}

#[test]
fn supports_spread_children_iterators() {
    let element = bx! {
        GpuiAdapter =>
        div[flex_row]{
            ..(0..3).map(|i| bx! { GpuiAdapter => div[text_sm]{ format!("{i}") } })
        }
    };

    let _any = element.into_any_element();
}

#[test]
fn test_view_macro_nested() {
    let _el = bx! {
        GpuiAdapter =>
        div[flex, flex_col] {
            div[w(px(20.))] { "Child 1" },
            bx! { GpuiAdapter => div { "Child 2 (Old Syntax)" } },
            "Child 3"
        }
    };
}

#[test]
fn test_view_macro_mixed() {
    let items = vec!["A", "B", "C"];
    let _el = bx! {
        GpuiAdapter =>
        div {
            "Header",
            ..items.into_iter().map(|i| bx! { GpuiAdapter => div { i } }),
            div { "Footer" }
        }
    };
}

#[test]
fn test_view_macro_modifiers() {
    let _el = bx! {
        GpuiAdapter =>
        div[
            bg(rgb(0x000000)),
            size(px(100.))
        ]
    };
}
