My space on the web https://inhji.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

62 lines
1.9 KiB

defmodule Mirage.LinksTest do
use Mirage.DataCase
import Mirage.LinkFixtures
import Mirage.NoteFixtures
alias Mirage.Links
alias Mirage.Links.Link
describe "notes_links" do
setup [:create_note]
@valid_attrs %{title: "some title", url: "some url"}
@update_attrs %{title: "some updated title", url: "some updated url"}
@invalid_attrs %{title: nil, url: nil}
test "list_notes_links/0 returns all notes_links" do
link = link_fixture()
assert Links.list_links() == [link]
end
test "get_link!/1 returns the link with given id" do
link = link_fixture()
assert Links.get_link!(link.id) == link
end
test "create_link/1 with valid data creates a link", %{note: note} do
assert {:ok, %Link{} = link} = Links.create_link(@valid_attrs |> with_note(note))
assert link.title == "some title"
assert link.url == "some url"
end
test "create_link/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = Links.create_link(@invalid_attrs)
end
test "update_link/2 with valid data updates the link" do
link = link_fixture()
assert {:ok, %Link{} = link} = Links.update_link(link, @update_attrs)
assert link.title == "some updated title"
assert link.url == "some updated url"
end
test "update_link/2 with invalid data returns error changeset" do
link = link_fixture()
assert {:error, %Ecto.Changeset{}} = Links.update_link(link, @invalid_attrs)
assert link == Links.get_link!(link.id)
end
test "delete_link/1 deletes the link" do
link = link_fixture()
assert {:ok, %Link{}} = Links.delete_link(link)
assert_raise Ecto.NoResultsError, fn -> Links.get_link!(link.id) end
end
test "change_link/1 returns a link changeset" do
link = link_fixture()
assert %Ecto.Changeset{} = Links.change_link(link)
end
end
end