aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 7d75c61..cbf61ac 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -43,17 +43,31 @@ fn main() {
#[cfg(test)]
mod test {
+ extern crate victoria_dom;
+
mod test_helpers;
+ use self::victoria_dom::DOM;
use super::build_rocket;
+ use super::models::Post;
+ use super::utils;
use rocket::local::Client;
- use rocket::http::Status;
+ use rocket::http::{Accept, Status};
#[test]
- fn get_landing_page() {
+ fn landing_page_shows_published_posts() {
let pool = test_helpers::init_test_db_pool();
+ let conn = utils::DbConn(pool.get().unwrap());
let client = Client::new(build_rocket(pool)).expect("Rocket not built!");
- let response = client.get("/").dispatch();
+ let mut response = client
+ .get("/")
+ .header(Accept::HTML)
+ .dispatch();
assert_eq!(response.status(), Status::Ok);
+
+ let dom = DOM::new(&response.body_string().unwrap());
+ let displayed_posts = dom.at("body").unwrap().childs(Some(".post-teaser")).iter().count();
+ let posts = Post::get_all(&conn);
+ assert_eq!(displayed_posts, posts.len());
}
}