-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli_test.exs
30 lines (24 loc) · 944 Bytes
/
cli_test.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
defmodule CliTest do
use ExUnit.Case
doctest Issues
import Issues.CLI, only: [parse_args: 1, sort_into_descending_order: 1]
test ":help returned by option parsing with -h and --help options" do
assert parse_args(["-h", "anything"]) == :help
assert parse_args(["--help", "anything"]) == :help
end
test "three values returned if three given" do
assert parse_args(["user", "project", "99"]) == {"user", "project", 99}
end
test "count is defaulted to 4 if two values given" do
assert parse_args(["user", "project"]) == {"user", "project", 4}
end
test "sort descending orders correctly" do
result = sort_into_descending_order(fake_created_at_list(["c", "a", "b"]))
issues = for issue <- result, do: Map.get(issue, "created_at")
assert issues == ~w{c b a}
end
defp fake_created_at_list(values) do
for value <- values,
do: %{"created_at" => value, "other_data" => "xxx"}
end
end