use crate::*;
#[test]
fn padding_fixed_all() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px; padding: 20px;" expect_width="240" expect_height="140">
<div style="width: 50px; height: 50px;" expect_top="20" expect_left="20"></div>
</div>
"#
)
}
#[test]
fn padding_asymmetric() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px; padding: 10px 20px 30px 40px;" expect_width="260" expect_height="140">
<div style="width: 50px; height: 50px;" expect_top="10" expect_left="40"></div>
</div>
"#
)
}
#[test]
fn padding_percentage() {
assert_xml!(
r#"
<div style="width: 200px; height: 200px; padding: 10%;" expect_width="275" expect_height="275">
<div style="width: 50px; height: 50px;" expect_top="37" expect_left="37"></div>
</div>
"#
)
}
#[test]
fn padding_top() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px; padding-top: 20px;" expect_width="200" expect_height="120">
<div style="width: 50px; height: 50px;" expect_top="20" expect_left="0"></div>
</div>
"#
)
}
#[test]
fn padding_right() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px; padding-right: 20px;" expect_width="220" expect_height="100">
<div style="width: 50px; height: 50px;" expect_top="0" expect_left="0"></div>
</div>
"#
)
}
#[test]
fn padding_bottom() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px; padding-bottom: 20px;" expect_width="200" expect_height="120">
<div style="width: 50px; height: 50px;" expect_top="0" expect_left="0"></div>
</div>
"#
)
}
#[test]
fn padding_left() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px; padding-left: 20px;" expect_width="220" expect_height="100">
<div style="width: 50px; height: 50px;" expect_top="0" expect_left="20"></div>
</div>
"#
)
}
#[test]
fn padding_zero() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px; padding: 0;" expect_width="200" expect_height="100">
<div style="width: 50px; height: 50px;" expect_top="0" expect_left="0"></div>
</div>
"#
)
}
#[test]
fn padding_with_border_box() {
assert_xml!(
r#"
<div style="box-sizing: border-box; width: 200px; height: 100px; padding: 20px;" expect_width="200" expect_height="100">
<div style="width: 50px; height: 50px;" expect_top="20" expect_left="20"></div>
</div>
"#
)
}
#[test]
fn padding_with_border() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px; padding: 20px; border: 10px solid;" expect_width="260" expect_height="160">
<div style="width: 50px; height: 50px;" expect_top="30" expect_left="30"></div>
</div>
"#
)
}
#[test]
fn padding_percentage_border_box() {
assert_xml!(
r#"
<div style="box-sizing: border-box; width: 200px; height: 200px; padding: 10%;" expect_width="200" expect_height="200">
<div style="width: 50px; height: 50px;" expect_top="37" expect_left="37"></div>
</div>
"#
)
}
#[test]
fn padding_nested() {
assert_xml!(
r#"
<div style="width: 200px; height: 200px; padding: 20px;" expect_width="240" expect_height="240">
<div style="width: 100px; height: 100px; padding: 10px;" expect_width="120" expect_height="120" expect_top="20" expect_left="20">
<div style="width: 50px; height: 50px;" expect_top="10" expect_left="10"></div>
</div>
</div>
"#
)
}
#[test]
fn padding_in_flex_container() {
assert_xml!(
r#"
<div style="display: flex; width: 300px; height: 100px;">
<div style="padding: 20px; height: 50px;" expect_width="60" expect_left="0">
<div style="width: 20px; height: 10px;" expect_top="20" expect_left="20"></div>
</div>
</div>
"#
)
}
#[test]
fn padding_with_min_width() {
assert_xml!(
r#"
<div style="width: 200px; height: 100px;">
<div style="min-width: 150px; padding: 20px;" expect_width="200">
<div style="width: 50px; height: 50px;" expect_top="20" expect_left="20"></div>
</div>
</div>
"#
)
}
#[test]
fn padding_with_max_width() {
assert_xml!(
r#"
<div style="width: 300px; height: 100px;">
<div style="max-width: 150px; padding: 20px;" expect_width="190">
<div style="width: 50px; height: 50px;" expect_top="20" expect_left="20"></div>
</div>
</div>
"#
)
}