Skip to content

Commit

Permalink
Add regression test for crate sizes display
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 1, 2024
1 parent 567c5cb commit c98bd34
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/web/crate_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2165,4 +2165,35 @@ mod tests {
Ok(())
})
}

#[test]
fn test_sizes_display() {
wrapper(|env| {
env.fake_release()
.name("dummy")
.version("0.4.0")
.rustdoc_file("dummy/index.html")
.create()?;

let response = env.frontend().get("/crate/dummy/0.4.0").send()?;
assert!(response.status().is_success());

let mut has_source_code_size = false;
let mut has_doc_size = false;
for span in kuchikiki::parse_html()
.one(response.text()?)
.select(r#".pure-menu-item span.documented-info"#)
.expect("invalid selector")
{
if span.text_contents().starts_with("Source code size:") {
has_source_code_size = true;
} else if span.text_contents().starts_with("Documentation size:") {
has_doc_size = true;
}
}
assert!(has_source_code_size);
assert!(has_doc_size);
Ok(())
});
}
}

0 comments on commit c98bd34

Please sign in to comment.