Extracts modules for different sections of the UI
This commit is contained in:
24
test/display/failure_test.exs
Normal file
24
test/display/failure_test.exs
Normal 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
|
13
test/display/intro_test.exs
Normal file
13
test/display/intro_test.exs
Normal 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
|
9
test/display/notification_test.exs
Normal file
9
test/display/notification_test.exs
Normal 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
|
21
test/display/progress_bar_test.exs
Normal file
21
test/display/progress_bar_test.exs
Normal 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
|
Reference in New Issue
Block a user