cranpose 0.26.0

Build desktop, mobile and web apps with composable Rust functions
Documentation
use super::{MIRROR_ROOT_STYLES, canvas_inline_styles};

fn properties(fill_viewport: bool) -> Vec<&'static str> {
    canvas_inline_styles(fill_viewport)
        .iter()
        .map(|(property, _)| *property)
        .collect()
}

#[test]
fn page_laid_out_canvases_keep_the_box_their_container_gives_them() {
    assert_eq!(
        properties(false),
        vec![
            "touch-action",
            "user-select",
            "-webkit-user-select",
            "-webkit-touch-callout"
        ]
    );
}

#[test]
fn viewport_filling_canvases_take_the_whole_viewport() {
    assert_eq!(
        canvas_inline_styles(true),
        [
            ("width", "100vw"),
            ("height", "100vh"),
            ("height", "100dvh"),
            ("touch-action", "none"),
            ("user-select", "none"),
            ("-webkit-user-select", "none"),
            ("-webkit-touch-callout", "none"),
        ]
    );
}

#[test]
fn viewport_filling_heights_end_on_the_dynamic_unit() {
    let heights: Vec<&str> = canvas_inline_styles(true)
        .iter()
        .filter(|(property, _)| *property == "height")
        .map(|(_, value)| *value)
        .collect();
    assert_eq!(heights, vec!["100vh", "100dvh"]);
}

#[test]
fn every_mode_takes_pointer_gestures_from_the_browser() {
    for fill_viewport in [false, true] {
        assert!(canvas_inline_styles(fill_viewport).contains(&("touch-action", "none")));
    }
}

#[test]
fn every_mode_keeps_a_long_press_from_selecting_the_page() {
    for fill_viewport in [false, true] {
        let styles = canvas_inline_styles(fill_viewport);
        for property in [
            "user-select",
            "-webkit-user-select",
            "-webkit-touch-callout",
        ] {
            assert!(styles.contains(&(property, "none")), "{property}");
        }
    }
}

#[test]
fn the_accessibility_mirror_is_unselectable_and_takes_no_pointer() {
    for style in [
        ("pointer-events", "none"),
        ("user-select", "none"),
        ("-webkit-user-select", "none"),
    ] {
        assert!(MIRROR_ROOT_STYLES.contains(&style), "{style:?}");
    }
}