Add tests
This commit is contained in:
parent
3746edc05a
commit
b491e210c7
18
src/index.rs
18
src/index.rs
|
@ -46,3 +46,21 @@ fn truncate(value: &Value, args: &HashMap<String, Value>) -> Result<Value, tera:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::index::*;
|
||||||
|
#[test]
|
||||||
|
fn truncate_shortens() {
|
||||||
|
let mut args: HashMap<String, Value> = HashMap::new();
|
||||||
|
args.insert("len".to_string(), Value::String("4".to_string()));
|
||||||
|
let truncated_string = truncate(&Value::String("Meow Nya".to_string()), &args).unwrap();
|
||||||
|
assert_eq!(truncated_string.as_str().unwrap(),"Meow");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn unformat_html() {
|
||||||
|
let html_src = "<p>Meow nyaaa<em> UwU</em></p>".to_string();
|
||||||
|
let unformatted_text = get_unformatted_text(html_src);
|
||||||
|
assert_eq!(unformatted_text,"Meow nyaaa UwU");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue