Extracts modules for different sections of the UI

This commit is contained in:
Felipe Sere
2016-05-13 11:03:53 +01:00
parent 8a8a0be771
commit af543d1b62
8 changed files with 141 additions and 4 deletions

View File

@@ -0,0 +1,24 @@
defmodule FailureTests do
use ExUnit.Case
alias Display.Failure
test "assertion failure with proper expression" do
error = error(%ExUnit.AssertionError{expr: "hi"})
assert Failure.format_failure(error) == "\e[36mAssertion failed in some_file.ex:42\e[0m\n\e[31m\"hi\"\e[0m\n"
end
test "assertion failure with message" do
error = error(%ExUnit.AssertionError{expr: :ex_unit_no_meaningful_value, message: "hola"})
assert Failure.format_failure(error) == "\e[36mAssertion failed in some_file.ex:42\e[0m\n\e[31mhola\e[0m\n"
end
defp error(error) do
%{
error: error,
file: "some_file.ex",
line: 42
}
end
end

View File

@@ -0,0 +1,13 @@
defmodule IntroTest do
use ExUnit.Case
alias Display.Intro
test "module not visited yet" do
assert Intro.intro(SampleKoan, []) == "\e[32mThere is something\n\n\e[0m"
end
test "module has been visited" do
assert Intro.intro(SampleKoan, [SampleKoan]) == ""
end
end

View File

@@ -0,0 +1,9 @@
defmodule NotificationTest do
use ExUnit.Case
alias Display.Notifications
test "shows possible koans when a koan can not be found" do
message = Notifications.invalid_koan(SampleKoan, [PassingKoan])
assert message == "Did not find koan SampleKoan in \e[31mPassingKoan\e[0m"
end
end

View File

@@ -0,0 +1,21 @@
defmodule ProgressBarTest do
use ExUnit.Case
alias Display.ProgressBar
test "empty bar" do
bar = ProgressBar.progress_bar(%{total: 12, current: 0})
assert bar == "| | 0 of 12"
end
test "puts counter on the right until half the koans are complete" do
bar = ProgressBar.progress_bar(%{total: 12, current: 3})
assert bar == "|=======> | 3 of 12"
end
test "full bar" do
bar = ProgressBar.progress_bar(%{total: 12, current: 12})
assert bar == "|=============================>| 12 of 12"
end
end