blob: f74b94359a90025ad5aca759167be40d57140256 (
plain)
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
|
defmodule SilmataivasWeb.LocationJSONTest do
use SilmataivasWeb.ConnCase, async: true
import Silmataivas.LocationsFixtures
import Silmataivas.UsersFixtures
alias SilmataivasWeb.LocationJSON
describe "location_json" do
test "index/1 renders a list of locations" do
user = user_fixture()
location1 = location_fixture(%{user_id: user.id, latitude: 10.0, longitude: 20.0})
location2 = location_fixture(%{user_id: user.id, latitude: 30.0, longitude: 40.0})
json = LocationJSON.index(%{locations: [location1, location2]})
assert json == %{
data: [
%{
id: location1.id,
latitude: location1.latitude,
longitude: location1.longitude
},
%{
id: location2.id,
latitude: location2.latitude,
longitude: location2.longitude
}
]
}
end
test "show/1 renders a single location with data wrapper" do
user = user_fixture()
location = location_fixture(%{user_id: user.id})
json = LocationJSON.show(%{location: location})
assert json == %{
data: %{
id: location.id,
latitude: location.latitude,
longitude: location.longitude
}
}
end
end
end
|