# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1539520322 -7200
# Node ID 5203b6fd34d4346db00bb151e97e6a9cb8848331
# Parent  cfbea3064aa93dbc3168a677b84cc28f4e81b640
util.http: Add tests for normalize_path

diff -r cfbea3064aa9 -r 5203b6fd34d4 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);