memEx/test/support/fixtures/notes_fixtures.ex

27 lines
598 B
Elixir
Raw Normal View History

2022-07-25 20:08:40 -04:00
defmodule Memex.NotesFixtures do
@moduledoc """
This module defines test helpers for creating
entities via the `Memex.Notes` context.
"""
2022-11-17 22:38:52 -05:00
alias Memex.{Accounts.User, Notes, Notes.Note}
2022-07-25 20:08:40 -04:00
@doc """
Generate a note.
"""
2022-11-17 22:38:52 -05:00
@spec note_fixture(User.t()) :: Note.t()
@spec note_fixture(attrs :: map(), User.t()) :: Note.t()
def note_fixture(attrs \\ %{}, user) do
2022-07-25 20:08:40 -04:00
{:ok, note} =
attrs
|> Enum.into(%{
content: "some content",
tag: [],
title: "some title",
2022-11-17 22:38:52 -05:00
visibility: :private
2022-07-25 20:08:40 -04:00
})
2022-11-17 22:38:52 -05:00
|> Notes.create_note(user)
2022-07-25 20:08:40 -04:00
note
end
end