Spaces:
Running
Running
neon_arch
commited on
Commit
·
47905f1
1
Parent(s):
ca1c72c
✅ test: update the integration with the new changes (#302)
Browse files- tests/index.rs +2 -16
tests/index.rs
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
use std::net::TcpListener;
|
2 |
|
3 |
-
use
|
4 |
-
use websurfx::{config::parser::Config, run};
|
5 |
|
6 |
// Starts a new instance of the HTTP server, bound to a random available port
|
7 |
fn spawn_app() -> String {
|
@@ -21,18 +20,6 @@ fn spawn_app() -> String {
|
|
21 |
format!("http://127.0.0.1:{}/", port)
|
22 |
}
|
23 |
|
24 |
-
// Creates a new instance of Handlebars and registers the templates directory.
|
25 |
-
// This is used to compare the rendered template with the response body.
|
26 |
-
fn handlebars() -> Handlebars<'static> {
|
27 |
-
let mut handlebars = Handlebars::new();
|
28 |
-
|
29 |
-
handlebars
|
30 |
-
.register_templates_directory(".html", "./public/templates")
|
31 |
-
.unwrap();
|
32 |
-
|
33 |
-
handlebars
|
34 |
-
}
|
35 |
-
|
36 |
#[tokio::test]
|
37 |
async fn test_index() {
|
38 |
let address = spawn_app();
|
@@ -41,9 +28,8 @@ async fn test_index() {
|
|
41 |
let res = client.get(address).send().await.unwrap();
|
42 |
assert_eq!(res.status(), 200);
|
43 |
|
44 |
-
let handlebars = handlebars();
|
45 |
let config = Config::parse(true).unwrap();
|
46 |
-
let template =
|
47 |
assert_eq!(res.text().await.unwrap(), template);
|
48 |
}
|
49 |
|
|
|
1 |
use std::net::TcpListener;
|
2 |
|
3 |
+
use websurfx::{config::parser::Config, run, templates::views};
|
|
|
4 |
|
5 |
// Starts a new instance of the HTTP server, bound to a random available port
|
6 |
fn spawn_app() -> String {
|
|
|
20 |
format!("http://127.0.0.1:{}/", port)
|
21 |
}
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
#[tokio::test]
|
24 |
async fn test_index() {
|
25 |
let address = spawn_app();
|
|
|
28 |
let res = client.get(address).send().await.unwrap();
|
29 |
assert_eq!(res.status(), 200);
|
30 |
|
|
|
31 |
let config = Config::parse(true).unwrap();
|
32 |
+
let template = views::index::index(&config.style.colorscheme, &config.style.theme).0;
|
33 |
assert_eq!(res.text().await.unwrap(), template);
|
34 |
}
|
35 |
|