Comparison

spec/util_http_spec.lua @ 9505:5203b6fd34d4

util.http: Add tests for normalize_path
author Kim Alvefur <zash@zash.se>
date Sun, 14 Oct 2018 14:32:02 +0200
parent 8236:4878e4159e12
child 9785:ff88b03c343f
comparison
equal deleted inserted replaced
9504:cfbea3064aa9 9505:5203b6fd34d4
59 ["one two"] = "1"; 59 ["one two"] = "1";
60 ["two one&"] = "2"; 60 ["two one&"] = "2";
61 }); 61 });
62 end); 62 end);
63 end); 63 end);
64
65 describe("normalize_path", function ()
66 it("root path is always '/'", function ()
67 assert.equal("/", http.normalize_path("/"));
68 assert.equal("/", http.normalize_path(""));
69 assert.equal("/", http.normalize_path("/", true));
70 assert.equal("/", http.normalize_path("", true));
71 end);
72
73 it("works", function ()
74 assert.equal("/foo", http.normalize_path("foo"));
75 assert.equal("/foo", http.normalize_path("/foo"));
76 assert.equal("/foo", http.normalize_path("foo/"));
77 assert.equal("/foo", http.normalize_path("/foo/"));
78 end);
79
80 it("is_dir works", function ()
81 assert.equal("/foo/", http.normalize_path("foo", true));
82 assert.equal("/foo/", http.normalize_path("/foo", true));
83 assert.equal("/foo/", http.normalize_path("foo/", true));
84 assert.equal("/foo/", http.normalize_path("/foo/", true));
85 end);
86 end);
64 end); 87 end);