This repository has been archived by the owner on Nov 27, 2019. It is now read-only.
/
delegates_test.exs
50 lines (43 loc) · 1.82 KB
/
delegates_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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
defmodule ArkEcosystem.Client.API.Two.DelegatesTest do
use ExUnit.Case
import ArkEcosystem.Client.API.Two.Delegates
import Tesla.Mock
@client ArkEcosystem.Client.new(%{
host: "http://127.0.0.1:4003/api",
nethash: "578e820911f24e039733b45e4882b73e301f813a0d2c31330dafda84534ffa23",
version: "1.1.1"
})
setup do
mock fn
%{method: :get, url: "http://127.0.0.1:4003/api/delegates/dummyId"} ->
json(%{"success" => true, "data" => %{ id: "dummyId" }})
%{method: :get, url: "http://127.0.0.1:4003/api/delegates"} ->
json(%{"success" => true, "data" => [%{ id: "dummyId" }]})
%{method: :get, url: "http://127.0.0.1:4003/api/delegates/dummyId/blocks"} ->
json(%{"success" => true, "data" => [%{ id: "dummyBlockId" }]})
%{method: :get, url: "http://127.0.0.1:4003/api/delegates/dummyId/voters"} ->
json(%{"success" => true, "data" => [%{ id: "dummyVoter" }]})
end
:ok
end
test "call ArkEcosystem.Client.API.Two.Delegates.list" do
assert {:ok, response} = list(@client)
assert Enum.at(response["data"],0)["id"] == "dummyId"
assert response["success"] == true
end
test "call ArkEcosystem.Client.API.Two.Delegates.show" do
assert {:ok, response} = show(@client, "dummyId")
assert response["data"]["id"] == "dummyId"
assert response["success"] == true
end
test "call ArkEcosystem.Client.API.Two.Delegates.blocks" do
assert {:ok, response} = blocks(@client, "dummyId")
assert Enum.at(response["data"], 0)["id"] == "dummyBlockId"
assert response["success"] == true
end
test "call ArkEcosystem.Client.API.Two.Delegates.voters" do
assert {:ok, response} = voters(@client, "dummyId")
assert Enum.at(response["data"], 0)["id"] == "dummyVoter"
assert response["success"] == true
end
end