mirror of
https://github.com/servo/servo.git
synced 2025-08-08 23:15:33 +01:00
Adds scroll-snap-type shorthand property, tests
This commit is contained in:
parent
75d35241db
commit
bdedcb9eb4
2 changed files with 83 additions and 0 deletions
|
@ -1006,4 +1006,53 @@ mod shorthand_serialization {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
mod scroll_snap_type {
|
||||
pub use super::*;
|
||||
use style::properties::longhands::scroll_snap_type_x::computed_value::T as ScrollSnapTypeXValue;
|
||||
|
||||
#[test]
|
||||
fn should_serialize_to_empty_string_if_sub_types_not_equal() {
|
||||
let declarations = vec![
|
||||
(PropertyDeclaration::ScrollSnapTypeX(DeclaredValue::Value(ScrollSnapTypeXValue::mandatory)),
|
||||
Importance::Normal),
|
||||
(PropertyDeclaration::ScrollSnapTypeY(DeclaredValue::Value(ScrollSnapTypeXValue::none)),
|
||||
Importance::Normal)
|
||||
];
|
||||
|
||||
let block = PropertyDeclarationBlock {
|
||||
declarations: declarations,
|
||||
important_count: 0
|
||||
};
|
||||
|
||||
let mut s = String::new();
|
||||
|
||||
let x = block.single_value_to_css("scroll-snap-type", &mut s);
|
||||
|
||||
assert_eq!(x.is_ok(), true);
|
||||
assert_eq!(s, "scroll-snap-type: ;");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_serialize_to_single_value_if_sub_types_are_equal() {
|
||||
let declarations = vec![
|
||||
(PropertyDeclaration::ScrollSnapTypeX(DeclaredValue::Value(ScrollSnapTypeXValue::mandatory)),
|
||||
Importance::Normal),
|
||||
(PropertyDeclaration::ScrollSnapTypeY(DeclaredValue::Value(ScrollSnapTypeXValue::mandatory)),
|
||||
Importance::Normal)
|
||||
];
|
||||
|
||||
let block = PropertyDeclarationBlock {
|
||||
declarations: declarations,
|
||||
important_count: 0
|
||||
};
|
||||
|
||||
let mut s = String::new();
|
||||
|
||||
let x = block.single_value_to_css("scroll-snap-type", &mut s);
|
||||
|
||||
assert_eq!(x.is_ok(), true);
|
||||
assert_eq!(s, "scroll-snap-type: mandatory;");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue