Skip to content

Commit 2b767dc

Browse files
GuillaumeGomezsyphar
authored andcommitted
Add regression test for crate sizes display
1 parent 0307dde commit 2b767dc

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/web/crate_details.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,4 +2165,35 @@ mod tests {
21652165
Ok(())
21662166
})
21672167
}
2168+
2169+
#[test]
2170+
fn test_sizes_display() {
2171+
wrapper(|env| {
2172+
env.fake_release()
2173+
.name("dummy")
2174+
.version("0.4.0")
2175+
.rustdoc_file("dummy/index.html")
2176+
.create()?;
2177+
2178+
let response = env.frontend().get("/crate/dummy/0.4.0").send()?;
2179+
assert!(response.status().is_success());
2180+
2181+
let mut has_source_code_size = false;
2182+
let mut has_doc_size = false;
2183+
for span in kuchikiki::parse_html()
2184+
.one(response.text()?)
2185+
.select(r#".pure-menu-item span.documented-info"#)
2186+
.expect("invalid selector")
2187+
{
2188+
if span.text_contents().starts_with("Source code size:") {
2189+
has_source_code_size = true;
2190+
} else if span.text_contents().starts_with("Documentation size:") {
2191+
has_doc_size = true;
2192+
}
2193+
}
2194+
assert!(has_source_code_size);
2195+
assert!(has_doc_size);
2196+
Ok(())
2197+
});
2198+
}
21682199
}

0 commit comments

Comments
 (0)