make new tests
This commit is contained in:
parent
d62b1c8380
commit
fa4ef7ddd0
|
@ -17,7 +17,6 @@ defmodule PokemonCoutureWeb.ClothesController do
|
||||||
clothes_map =
|
clothes_map =
|
||||||
clothes
|
clothes
|
||||||
|> Enum.reduce(%{}, &create_shop_map/2)
|
|> Enum.reduce(%{}, &create_shop_map/2)
|
||||||
# IO.inspect(clothes_map)
|
|
||||||
render(conn, "index.html", clothes: clothes, clothes_map: clothes_map)
|
render(conn, "index.html", clothes: clothes, clothes_map: clothes_map)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ defmodule PokemonCouture.ShopsTest do
|
||||||
|
|
||||||
alias PokemonCouture.Shops
|
alias PokemonCouture.Shops
|
||||||
|
|
||||||
|
import PokemonCouture.AccountsFixtures
|
||||||
describe "clothes" do
|
describe "clothes" do
|
||||||
alias PokemonCouture.Shops.Clothes
|
alias PokemonCouture.Shops.Clothes
|
||||||
|
|
||||||
|
@ -23,6 +24,11 @@ defmodule PokemonCouture.ShopsTest do
|
||||||
assert length(Shops.list_clothes()) > 0
|
assert length(Shops.list_clothes()) > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "valid piece of clothing in list_clothes/0" do
|
||||||
|
clothes = Shops.get_clothes!(1)
|
||||||
|
assert clothes in Shops.list_clothes()
|
||||||
|
end
|
||||||
|
|
||||||
test "get_clothes!/1 returns the clothes with given id" do
|
test "get_clothes!/1 returns the clothes with given id" do
|
||||||
clothes = clothes_fixture()
|
clothes = clothes_fixture()
|
||||||
assert Shops.get_clothes!(clothes.id) == clothes
|
assert Shops.get_clothes!(clothes.id) == clothes
|
||||||
|
@ -63,5 +69,20 @@ defmodule PokemonCouture.ShopsTest do
|
||||||
clothes = clothes_fixture()
|
clothes = clothes_fixture()
|
||||||
assert %Ecto.Changeset{} = Shops.change_clothes(clothes)
|
assert %Ecto.Changeset{} = Shops.change_clothes(clothes)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "check if list clothes with owners has owners" do
|
||||||
|
clothes_with_owners = Shops.list_clothes_with_owners()
|
||||||
|
clothes_piece = hd(clothes_with_owners)
|
||||||
|
assert clothes_piece.users
|
||||||
|
end
|
||||||
|
|
||||||
|
test "clothes owner adding and removing test" do
|
||||||
|
clothes_piece = hd(Shops.list_clothes_with_owners())
|
||||||
|
user = user_fixture()
|
||||||
|
clothes_piece = Shops.add_owner(clothes_piece, user)
|
||||||
|
assert user in clothes_piece.users
|
||||||
|
clothes_piece = Shops.remove_owner(clothes_piece, user)
|
||||||
|
assert user not in clothes_piece.users
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue