mirror of
https://github.com/getzola/zola
synced 2024-12-13 22:02:29 +00:00
commit
fec33c8e8b
1 changed files with 9 additions and 2 deletions
|
@ -9,7 +9,7 @@ pub fn get_reading_analytics(content: &str) -> (usize, usize) {
|
||||||
|
|
||||||
// https://help.medium.com/hc/en-us/articles/214991667-Read-time
|
// https://help.medium.com/hc/en-us/articles/214991667-Read-time
|
||||||
// 275 seems a bit too high though
|
// 275 seems a bit too high though
|
||||||
(word_count, (word_count / 200))
|
(word_count, ((word_count + 199) / 200))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
|
@ -86,11 +86,18 @@ mod tests {
|
||||||
assert!(res.is_err());
|
assert!(res.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn reading_analytics_empty_text() {
|
||||||
|
let (word_count, reading_time) = get_reading_analytics(" ");
|
||||||
|
assert_eq!(word_count, 0);
|
||||||
|
assert_eq!(reading_time, 0);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reading_analytics_short_text() {
|
fn reading_analytics_short_text() {
|
||||||
let (word_count, reading_time) = get_reading_analytics("Hello World");
|
let (word_count, reading_time) = get_reading_analytics("Hello World");
|
||||||
assert_eq!(word_count, 2);
|
assert_eq!(word_count, 2);
|
||||||
assert_eq!(reading_time, 0);
|
assert_eq!(reading_time, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue