memEx/test/support/fixtures/notes_fixtures.ex

28 lines
636 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-26 14:51:18 -05:00
import Memex.Fixtures
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",
2022-12-15 22:33:10 -05:00
tags: ["example-tag"],
2022-11-26 14:51:18 -05:00
slug: random_slug(),
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