Skip to content

Commit

Permalink
color for case with 0 relevant lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Apelsinka223 committed Oct 22, 2018
1 parent 500b863 commit 645ff9b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
4 changes: 3 additions & 1 deletion lib/excoveralls/html/view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ defmodule ExCoveralls.Html.View do
Safe.html_escape(data)
end

def coverage_class(percent) do
def coverage_class(percent, sloc \\ nil)
def coverage_class(percent, 0), do: "none"
def coverage_class(percent, _) do
cond do
percent >= 75 -> "high"
percent >= 50 -> "medium"
Expand Down
3 changes: 3 additions & 0 deletions lib/templates/html/htmlcov/_style.html.eex

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/templates/html/htmlcov/coverage.html.eex

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions test/html/view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ defmodule ExCoveralls.Html.ViewTest do
end

test "#coverage_class" do
[h,m,l,t] = [View.coverage_class(75),
View.coverage_class(50),
View.coverage_class(25),
View.coverage_class(0)]
[h,m,l,t,n] = [View.coverage_class(75),
View.coverage_class(50),
View.coverage_class(25),
View.coverage_class(0),
View.coverage_class(0, 0)]

assert(h == "high")
assert(m == "medium")
assert(l == "low")
assert(t == "terrible")
assert(n == "none")
end
end
2 changes: 1 addition & 1 deletion test/html_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule ExCoveralls.HtmlTest do
alias ExCoveralls.Html

@file_name "excoveralls.html"
@file_size 20184
@file_size 20212
@test_output_dir "cover_test/"
@test_template_path "lib/templates/html/htmlcov/"

Expand Down

0 comments on commit 645ff9b

Please sign in to comment.