Skip to content

Commit

Permalink
Add tests for convert_fontawesome
Browse files Browse the repository at this point in the history
  • Loading branch information
uncenter committed Nov 15, 2024
1 parent 39d7615 commit 2ca9f04
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/renderer/html_handlebars/hbs_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1322,4 +1322,29 @@ mod tests {
assert_eq!(json!(TextDirection::RightToLeft), json!("rtl"));
assert_eq!(json!(TextDirection::LeftToRight), json!("ltr"));
}

#[test]
fn convert_valid_fontawesome_class() {
assert!(convert_fontawesome("<i class=\"fa fab-github\"></i>").contains("class=\"fa-svg\""));
assert!(
convert_fontawesome("<i class=\"fa fab-github some-class\"></i>")
.contains("class=\"fa-svg some-class\"")
);
assert!(convert_fontawesome("<i class=\"fa fas-print\"></i>").contains("class=\"fa-svg\""));
assert!(convert_fontawesome("<i class=\"fa fa-eye\"></i>").contains("class=\"fa-svg\""));
}

#[test]
fn convert_invalid_fontawesome_class() {
let invalid_fontawesome_i_tag = "<i class=\"fa\"></i>";
assert_eq!(
convert_fontawesome(invalid_fontawesome_i_tag),
invalid_fontawesome_i_tag
);
let non_fontawesome_i_tag = "<i class=\"some-class\"></i>";
assert_eq!(
convert_fontawesome(non_fontawesome_i_tag),
non_fontawesome_i_tag
);
}
}

0 comments on commit 2ca9f04

Please sign in to comment.