util.http: Add tests for normalize_path
authorKim Alvefur <zash@zash.se>
Sun, 14 Oct 2018 14:32:02 +0200
changeset 9508 5203b6fd34d4
parent 9507 cfbea3064aa9
child 9509 ae6636052be9
util.http: Add tests for normalize_path
spec/util_http_spec.lua
--- a/spec/util_http_spec.lua	Sun Oct 14 14:31:59 2018 +0200
+++ b/spec/util_http_spec.lua	Sun Oct 14 14:32:02 2018 +0200
@@ -61,4 +61,27 @@
 			});
 		end);
 	end);
+
+	describe("normalize_path", function ()
+		it("root path is always '/'", function ()
+			assert.equal("/", http.normalize_path("/"));
+			assert.equal("/", http.normalize_path(""));
+			assert.equal("/", http.normalize_path("/", true));
+			assert.equal("/", http.normalize_path("", true));
+		end);
+
+		it("works", function ()
+			assert.equal("/foo", http.normalize_path("foo"));
+			assert.equal("/foo", http.normalize_path("/foo"));
+			assert.equal("/foo", http.normalize_path("foo/"));
+			assert.equal("/foo", http.normalize_path("/foo/"));
+		end);
+
+		it("is_dir works", function ()
+			assert.equal("/foo/", http.normalize_path("foo", true));
+			assert.equal("/foo/", http.normalize_path("/foo", true));
+			assert.equal("/foo/", http.normalize_path("foo/", true));
+			assert.equal("/foo/", http.normalize_path("/foo/", true));
+		end);
+	end);
 end);