./test/dolt/view/tree_test.rb in dolt-0.4.3 vs ./test/dolt/view/tree_test.rb in dolt-0.5.0
- old
+ new
@@ -118,22 +118,27 @@
it "chunks up leading path" do
parts = partition_path("lib/dolt/very/deep", 3)
assert_equal [["", "lib", "dolt"], ["very"], ["deep"]], parts
end
+
+ it "partitions short path with maxdepth" do
+ parts = partition_path("lib", 3)
+ assert_equal [["", "lib"]], parts
+ end
end
describe "#accumulate_path" do
it "accumulates partitioned path" do
parts = accumulate_path(partition_path("lib/dolt/very/deep", 3))
assert_equal [["", "lib", "lib/dolt"], ["lib/dolt/very"], ["lib/dolt/very/deep"]], parts
end
end
describe "#tree_context" do
- def context(path)
- tree_context("gitorious", "master", path)
+ def context(path, maxdepth = nil)
+ tree_context("gitorious", "master", accumulate_path(partition_path(path, maxdepth)))
end
it "renders root as empty string" do
assert_equal "", context("")
assert_equal "", context("/")
@@ -170,8 +175,25 @@
it "renders two path items with colspan in first row" do
assert_match /colspan="6"/, select(context("lib/dolt"), "tr").first
assert_match /colspan="5"/, select(context("lib/dolt"), "tr")[1]
tr = select(context("lib/dolt"), "tr")[1]
assert_equal 2, select(tr, "td").length
+ end
+
+ it "renders condensed first entry with slashes" do
+ links = select(context("src/phorkie/Database/Adapter", 3), "a")
+
+ assert_equal "<a href=\"/tree/master:\"><i class=\"icon icon-folder-open\"></i> /</a>", links.first
+ assert_equal "<a href=\"/tree/master:src\"> src</a>", links[1]
+ assert_equal "<a href=\"/tree/master:src/phorkie\">/ phorkie</a>", links[2]
+ end
+
+ it "renders long condensed first entry with slashes" do
+ links = select(context("src/phorkie/Database/Adapter/Elasticsearch", 3), "a")
+
+ assert_equal "<a href=\"/tree/master:\"><i class=\"icon icon-folder-open\"></i> /</a>", links.first
+ assert_equal "<a href=\"/tree/master:src\"> src</a>", links[1]
+ assert_equal "<a href=\"/tree/master:src/phorkie\">/ phorkie</a>", links[2]
+ assert_equal "<a href=\"/tree/master:src/phorkie/Database\">/ Database</a>", links[3]
end
end
end