mirror of
https://github.com/ClaperCo/Claper.git
synced 2026-02-24 12:09:59 +01:00
commit 1ccd9e6be4da1b0f539e4c76b39d097de1b8798a Author: Alex <dev@alexandrelion.com> Date: Sun Feb 26 22:27:08 2023 +0100 Fix unit tests for forms commit b10d66be25b31028fb76c004852059bc1e2eb13a Author: Alex <dev@alexandrelion.com> Date: Sun Feb 26 15:35:55 2023 +0100 Finish form integration commit fce276497ddaba92f367ee9994b8ae11dabdb7ab Author: Alex <dev@alexandrelion.com> Date: Mon Feb 20 21:09:14 2023 +0100 Add form
48 lines
1.1 KiB
Elixir
48 lines
1.1 KiB
Elixir
defmodule Claper.FormsFixtures do
|
|
@moduledoc """
|
|
This module defines test helpers for creating
|
|
entities via the `Claper.Forms` context.
|
|
"""
|
|
|
|
import Claper.{AccountsFixtures, PresentationsFixtures}
|
|
|
|
require Claper.UtilFixture
|
|
|
|
@doc """
|
|
Generate a form.
|
|
"""
|
|
def form_fixture(attrs \\ %{}, preload \\ []) do
|
|
{:ok, form} =
|
|
attrs
|
|
|> Enum.into(%{
|
|
title: "some title",
|
|
position: 0,
|
|
enabled: true,
|
|
fields: [%{name: "Name", type: "text"}]
|
|
})
|
|
|> Claper.Forms.create_form()
|
|
|
|
Claper.UtilFixture.merge_preload(form, preload, %{})
|
|
end
|
|
|
|
@doc """
|
|
Generate a form submit.
|
|
"""
|
|
def form_submit_fixture(attrs \\ %{}) do
|
|
presentation_file = presentation_file_fixture()
|
|
form = form_fixture(%{presentation_file_id: presentation_file.id})
|
|
assoc = %{form: form}
|
|
|
|
{:ok, form_submit} =
|
|
attrs
|
|
|> Enum.into(%{
|
|
form_id: assoc.form.id,
|
|
user_id: user_fixture().id,
|
|
response: %{"Test" => "some option 1", "Test2" => "some option 2"}
|
|
})
|
|
|> Claper.Forms.create_form_submit()
|
|
|
|
form_submit
|
|
end
|
|
end
|