Skip to content

Commit

Permalink
tests/pseudo-classes.rs: add test to cover unsupported pseudo-classes
Browse files Browse the repository at this point in the history
  • Loading branch information
niklak committed Nov 1, 2024
1 parent 02b715e commit 78c8e84
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/pseudo-classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,32 @@ fn test_only_of_type() {
let sel = doc.select("ul li:only-of-type");
assert_eq!(sel.text(), "4".into());
}

#[cfg_attr(not(target_arch = "wasm32"), test)]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
#[should_panic]
fn test_unsupported_pseudo_class() {
let doc: Document = SIMPLE_LIST_CONTENT.into();

doc.select("*:required");
}

#[cfg_attr(not(target_arch = "wasm32"), test)]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn test_try_unsupported_pseudo_class() {
let doc: Document = SIMPLE_LIST_CONTENT.into();

let sel = doc.try_select("*:required");

assert!(sel.is_none());
}


#[cfg_attr(not(target_arch = "wasm32"), test)]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
#[should_panic]
fn test_unsupported_functional_pseudo_class() {
let doc: Document = SIMPLE_LIST_CONTENT.into();

doc.select(":lang(en-US)");
}

0 comments on commit 78c8e84

Please sign in to comment.