Add tests for the home handler
This commit is contained in:
parent
e98324e3fe
commit
8863b87c4e
|
@ -21,3 +21,23 @@ fn index(lists: State<ListStore>) -> Template {
|
|||
let context = IndexTemplateContext { lists: list_kvs };
|
||||
Template::render("index", &context)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use rocket;
|
||||
use rocket::http::{Accept, Status};
|
||||
use rocket::local::Client;
|
||||
|
||||
#[test]
|
||||
fn index() {
|
||||
let client = Client::new(rocket(Some("test"))).unwrap();
|
||||
|
||||
// Try to get the index and verify the body
|
||||
let mut res = client.get("/").header(Accept::HTML).dispatch();
|
||||
assert_eq!(res.status(), Status::Ok);
|
||||
|
||||
let body = res.body_string().unwrap();
|
||||
println!("body: {}", body);
|
||||
assert!(body.contains("<span id=\"list-name\">Test</span>"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue