Skip to content

Commit

Permalink
test(css_remove): ensure multiple inside each other work
Browse files Browse the repository at this point in the history
  • Loading branch information
EdJoPaTo committed Feb 1, 2022
1 parent 76951f1 commit 3cd98c7
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions src/editor/css_remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ const EXAMPLE_HTML: &str =

#[test]
fn removes_tag() {
let remover = CssRemover("p".to_string());
let html = remover.apply(EXAMPLE_HTML).unwrap();
let html = CssRemover("p".to_string()).apply(EXAMPLE_HTML).unwrap();
assert_eq!(
html,
r#"<html><head></head><body><div class="a"></div><div class="b">B</div></body></html>"#
Expand All @@ -70,9 +69,30 @@ fn removes_tag() {

#[test]
fn remove_not_found() {
let remover = CssRemover("p".to_string());
let html = remover
.apply(r#"<html><head></head><body>test</body></html>"#)
.unwrap();
assert_eq!(html, r#"<html><head></head><body>test</body></html>"#);
let html = CssRemover("span".to_string()).apply(EXAMPLE_HTML).unwrap();
assert_eq!(html, EXAMPLE_HTML);
}

#[test]
fn multiple_selectors_work() {
let html = CssRemover(".b, p".to_string()).apply(EXAMPLE_HTML).unwrap();
assert_eq!(
html,
r#"<html><head></head><body><div class="a"></div></body></html>"#
);
}

#[test]
fn multiple_selectors_inside_each_other_work() {
let html = CssRemover("p, .a".to_string()).apply(EXAMPLE_HTML).unwrap();
assert_eq!(
html,
r#"<html><head></head><body><div class="b">B</div></body></html>"#
);

let html = CssRemover(".a, p".to_string()).apply(EXAMPLE_HTML).unwrap();
assert_eq!(
html,
r#"<html><head></head><body><div class="b">B</div></body></html>"#
);
}

0 comments on commit 3cd98c7

Please sign in to comment.