From e410bf2dc33e462eebb6524418da3a4c7349dbca Mon Sep 17 00:00:00 2001 From: Ali MJ Al-Nasrawy Date: Thu, 10 Jun 2021 00:48:57 +0300 Subject: [PATCH] test --- actix-files/src/lib.rs | 16 ++++++++++++++++ actix-files/tests/test.js | 1 + 2 files changed, 17 insertions(+) create mode 100644 actix-files/tests/test.js diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs index aa5960b5b..48d3c49f4 100644 --- a/actix-files/src/lib.rs +++ b/actix-files/src/lib.rs @@ -279,6 +279,22 @@ mod tests { ); } + #[actix_rt::test] + async fn test_named_file_javascript() { + let file = NamedFile::open("tests/test.js").unwrap(); + + let req = TestRequest::default().to_http_request(); + let resp = file.respond_to(&req).await.unwrap(); + assert_eq!( + resp.headers().get(header::CONTENT_TYPE).unwrap(), + "application/javascript" + ); + assert_eq!( + resp.headers().get(header::CONTENT_DISPOSITION).unwrap(), + "inline; filename=\"test.js\"" + ); + } + #[actix_rt::test] async fn test_named_file_image_attachment() { let cd = ContentDisposition { diff --git a/actix-files/tests/test.js b/actix-files/tests/test.js new file mode 100644 index 000000000..2ee135561 --- /dev/null +++ b/actix-files/tests/test.js @@ -0,0 +1 @@ +// this file is empty.