implement not found for ui
This commit is contained in:
@ -42,13 +42,30 @@ async fn root_returns_spa() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn unkown_fallsback_to_spa() {
|
||||
async fn unkown_url_fallback_to_spa() {
|
||||
let (app, _) = nuchat::app();
|
||||
|
||||
let response = app
|
||||
.clone()
|
||||
.oneshot(
|
||||
Request::builder()
|
||||
.uri("/asdfasdfa") // unknown url
|
||||
.body(Body::empty())
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
|
||||
let body = response.into_body().collect().await.unwrap().to_bytes();
|
||||
let body = String::from_utf8(body.into_iter().collect()).unwrap();
|
||||
assert!(body.starts_with("<!DOCTYPE html>"));
|
||||
|
||||
let response = app
|
||||
.oneshot(
|
||||
Request::builder()
|
||||
.uri("/asdfasdfa") // unknown url
|
||||
.uri("/api/asdfasdfa") // unknown url
|
||||
.body(Body::empty())
|
||||
.unwrap(),
|
||||
)
|
||||
@ -59,5 +76,5 @@ async fn unkown_fallsback_to_spa() {
|
||||
|
||||
let body = response.into_body().collect().await.unwrap().to_bytes();
|
||||
let body = String::from_utf8(body.into_iter().collect()).unwrap();
|
||||
assert!(body.starts_with("<!DOCTYPE html>"));
|
||||
assert!(body.starts_with("Not Found"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user