Skip to content

Commit 83690fa

Browse files
committed
test: add tests for GH-693
Signed-off-by: Dmitry Dygalo <dmitry@dygalo.dev>
1 parent 052d475 commit 83690fa

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

css-inline/tests/test_inlining.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,3 +2106,16 @@ fn inline_fragment_surrounding_whitespace(input: &str, expected: &str) {
21062106
let inlined = css_inline::inline_fragment(input, "h1 { color: blue; }").unwrap();
21072107
assert_eq!(inlined, expected);
21082108
}
2109+
2110+
// Fragments containing structural HTML tags (<html>, <head>, <body>, <style>) should be handled
2111+
// correctly: structural tags are stripped and content is inlined as expected.
2112+
// See GH-693
2113+
#[test_case("<body><h1>Hello</h1></body>", "", "<h1>Hello</h1>"; "body-tag")]
2114+
#[test_case("<body><style>h1 { color: red; }</style><h1>Hello</h1></body>", "", "<h1 style=\"color: red;\">Hello</h1>"; "body-with-style")]
2115+
#[test_case("<head></head><body><h1>Hello</h1></body>", "h1 { color: red; }", "<h1 style=\"color: red;\">Hello</h1>"; "head-and-body")]
2116+
#[test_case("<style>h1 { color: red; }</style><h1>Hello</h1>", "", "<h1 style=\"color: red;\">Hello</h1>"; "style-tag-and-content")]
2117+
#[test_case("<html><head><style>h1 { color: red; }</style></head><body><h1>Hello</h1></body></html>", "", "<h1 style=\"color: red;\">Hello</h1>"; "full-html-page")]
2118+
fn inline_fragment_structural_tags(input: &str, css: &str, expected: &str) {
2119+
let inlined = css_inline::inline_fragment(input, css).unwrap();
2120+
assert_eq!(inlined, expected);
2121+
}

0 commit comments

Comments
 (0)