use crate::*;
#[test]
fn border_width_fixed() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px; border-top-width: 10px; border-right-width: 10px; border-bottom-width: 10px; border-left-width: 10px;" expect_width="220" expect_height="120">
<div style="width: 50px; height: 50px;" expect_top="10" expect_left="10"></div>
</div>
"#
)
}
#[test]
fn border_width_asymmetric() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px; border-top-width: 10px; border-right-width: 20px; border-bottom-width: 30px; border-left-width: 40px;" expect_width="260" expect_height="140">
<div style="width: 50px; height: 50px;" expect_top="10" expect_left="40"></div>
</div>
"#
)
}
#[test]
fn border_width_thin() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px; border-top-width: thin; border-right-width: thin; border-bottom-width: thin; border-left-width: thin;" expect_width="202" expect_height="102">
<div style="width: 50px; height: 50px;" expect_top="1" expect_left="1"></div>
</div>
"#
)
}
#[test]
fn border_width_medium() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px; border-top-width: medium; border-right-width: medium; border-bottom-width: medium; border-left-width: medium;" expect_width="206" expect_height="106">
<div style="width: 50px; height: 50px;" expect_top="3" expect_left="3"></div>
</div>
"#
)
}
#[test]
fn border_width_thick() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px; border-top-width: thick; border-right-width: thick; border-bottom-width: thick; border-left-width: thick;" expect_width="210" expect_height="110">
<div style="width: 50px; height: 50px;" expect_top="5" expect_left="5"></div>
</div>
"#
)
}
#[test]
fn border_width_zero() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px; border-top-width: 0; border-right-width: 0; border-bottom-width: 0; border-left-width: 0;" expect_width="200" expect_height="100">
<div style="width: 50px; height: 50px;" expect_top="0" expect_left="0"></div>
</div>
"#
)
}
#[test]
fn border_width_percentage() {
assert_xml!(
r#"
<div style="width: 200px; height: 200px;">
<div style="width: 100px; height: 100px; border-top-width: 10%; border-right-width: 10%; border-bottom-width: 10%; border-left-width: 10%;" expect_width="140" expect_height="140">
<div style="width: 50px; height: 50px;" expect_top="20" expect_left="20"></div>
</div>
</div>
"#
)
}
#[test]
fn border_width_with_border_box() {
assert_xml!(
r#"
<div style="box-sizing: border-box; width: 200px; height: 100px; border-top-width: 10px; border-right-width: 10px; border-bottom-width: 10px; border-left-width: 10px;" expect_width="200" expect_height="100">
<div style="width: 50px; height: 50px;" expect_top="10" expect_left="10"></div>
</div>
"#
)
}
#[test]
fn border_width_with_border_box_and_padding() {
assert_xml!(
r#"
<div style="box-sizing: border-box; width: 200px; height: 100px; padding: 20px; border-top-width: 10px; border-right-width: 10px; border-bottom-width: 10px; border-left-width: 10px;" expect_width="200" expect_height="100">
<div style="width: 50px; height: 50px;" expect_top="30" expect_left="30"></div>
</div>
"#
)
}
#[test]
fn border_width_with_border_box_percentage() {
assert_xml!(
r#"
<div style="width: 300px; height: 200px;">
<div style="box-sizing: border-box; width: 50%; height: 100px; border-top-width: 10px; border-right-width: 10px; border-bottom-width: 10px; border-left-width: 10px;" expect_width="150" expect_height="100">
<div style="width: 50px; height: 50px;" expect_top="10" expect_left="10"></div>
</div>
</div>
"#
)
}
#[test]
fn border_width_with_padding() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px; padding: 20px; border-top-width: 10px; border-right-width: 10px; border-bottom-width: 10px; border-left-width: 10px;" expect_width="260" expect_height="160">
<div style="width: 50px; height: 50px;" expect_top="30" expect_left="30"></div>
</div>
"#
)
}
#[test]
fn border_width_individual() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px; border-top-width: 5px; border-right-width: 10px; border-bottom-width: 15px; border-left-width: 20px;" expect_width="230" expect_height="120">
<div style="width: 50px; height: 50px;" expect_top="5" expect_left="20"></div>
</div>
"#
)
}
#[test]
fn border_width_with_min_width() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px;">
<div style="min-width: 150px; border-top-width: 10px; border-right-width: 10px; border-bottom-width: 10px; border-left-width: 10px;" expect_width="200" expect_height="70">
<div style="width: 50px; height: 50px;" expect_top="10" expect_left="10"></div>
</div>
</div>
"#
)
}
#[test]
fn border_width_with_min_width_border_box() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px;">
<div style="box-sizing: border-box; min-width: 150px; width: 100px; border-top-width: 10px; border-right-width: 10px; border-bottom-width: 10px; border-left-width: 10px;" expect_width="150" expect_height="70">
<div style="width: 50px; height: 50px;" expect_top="10" expect_left="10"></div>
</div>
</div>
"#
)
}
#[test]
fn border_width_with_max_width() {
assert_xml!(
r#"
<div style="width: 300px; height: 100px;">
<div style="max-width: 150px; border-top-width: 10px; border-right-width: 10px; border-bottom-width: 10px; border-left-width: 10px;" expect_width="170">
<div style="width: 50px; height: 50px;" expect_top="10" expect_left="10"></div>
</div>
</div>
"#
)
}
#[test]
fn border_width_with_max_width_border_box() {
assert_xml!(
r#"
<div style="width: 300px; height: 100px;">
<div style="box-sizing: border-box; max-width: 150px; width: 200px; border-top-width: 10px; border-right-width: 10px; border-bottom-width: 10px; border-left-width: 10px;" expect_width="150">
<div style="width: 50px; height: 50px;" expect_top="10" expect_left="10"></div>
</div>
</div>
"#
)
}
#[test]
fn border_width_in_flex_container() {
assert_xml!(
r#"
<div style="display: flex; width: 300px; height: 100px;">
<div style="border-top-width: 10px; border-right-width: 10px; border-bottom-width: 10px; border-left-width: 10px; height: 50px;" expect_width="60" expect_left="0">
<div style="width: 40px; height: 30px;" expect_top="10" expect_left="10"></div>
</div>
</div>
"#
)
}
#[test]
fn border_width_in_flex_container_border_box() {
assert_xml!(
r#"
<div style="display: flex; width: 300px; height: 100px;">
<div style="box-sizing: border-box; flex-grow: 1; border-top-width: 10px; border-right-width: 10px; border-bottom-width: 10px; border-left-width: 10px; height: 50px;" expect_width="300">
<div style="width: 50px; height: 30px;" expect_top="10" expect_left="10"></div>
</div>
</div>
"#
)
}
#[test]
fn border_width_nested() {
assert_xml!(
r#"
<div style="width: 200px; height: 200px; border-top-width: 10px; border-right-width: 10px; border-bottom-width: 10px; border-left-width: 10px;" expect_width="220" expect_height="220">
<div style="width: 100px; height: 100px; border-top-width: 5px; border-right-width: 5px; border-bottom-width: 5px; border-left-width: 5px;" expect_width="110" expect_height="110" expect_top="10" expect_left="10">
<div style="width: 50px; height: 50px;" expect_top="5" expect_left="5"></div>
</div>
</div>
"#
)
}