make new tests

This commit is contained in:
Lili (Tlapka) 2021-09-21 18:11:13 +02:00
parent d62b1c8380
commit fa4ef7ddd0
2 changed files with 21 additions and 1 deletions

View File

@ -17,7 +17,6 @@ defmodule PokemonCoutureWeb.ClothesController do
clothes_map =
clothes
|> Enum.reduce(%{}, &create_shop_map/2)
# IO.inspect(clothes_map)
render(conn, "index.html", clothes: clothes, clothes_map: clothes_map)
end

View File

@ -3,6 +3,7 @@ defmodule PokemonCouture.ShopsTest do
alias PokemonCouture.Shops
import PokemonCouture.AccountsFixtures
describe "clothes" do
alias PokemonCouture.Shops.Clothes
@ -23,6 +24,11 @@ defmodule PokemonCouture.ShopsTest do
assert length(Shops.list_clothes()) > 0
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
clothes = clothes_fixture()
assert Shops.get_clothes!(clothes.id) == clothes
@ -63,5 +69,20 @@ defmodule PokemonCouture.ShopsTest do
clothes = clothes_fixture()
assert %Ecto.Changeset{} = Shops.change_clothes(clothes)
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