Skip to content

Commit 03174f7

Browse files
committed
test: Add extra tests
1 parent 10e03b4 commit 03174f7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

css-inline/tests/test_inlining.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@ fn important() {
172172
)
173173
}
174174

175+
#[test]
176+
fn important_no_rule_exists() {
177+
// `!important` rules should override existing inline styles
178+
assert_inlined!(
179+
style = "h1 { color: blue !important; }",
180+
body = r#"<h1 style="margin:0">Big Text</h1>"#,
181+
expected = r#"<h1 style="margin: 0;color: blue">Big Text</h1>"#
182+
)
183+
}
184+
175185
#[test]
176186
fn font_family_quoted() {
177187
// When property value contains double quotes
@@ -581,3 +591,11 @@ fn use_builder() {
581591
.extra_css(Some("h1 {color: green}".into()))
582592
.build();
583593
}
594+
595+
#[test]
596+
fn inline_to() {
597+
let html = html!("h1 { color: blue }", r#"<h1>Big Text</h1>"#);
598+
let mut out = Vec::new();
599+
css_inline::inline_to(&html, &mut out).unwrap();
600+
assert_eq!(String::from_utf8_lossy(&out), "<html><head><title>Test</title><style>h1 { color: blue }</style></head><body><h1 style=\"color: blue ;\">Big Text</h1></body></html>")
601+
}

0 commit comments

Comments
 (0)