zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

type.test.exs (2115B)


      1 # Zenflows is designed to implement the Valueflows vocabulary,
      2 # written and maintained by srfsh <info@dyne.org>.
      3 # Copyright (C) 2021-2023 Dyne.org foundation <foundation@dyne.org>.
      4 #
      5 # This program is free software: you can redistribute it and/or modify
      6 # it under the terms of the GNU Affero General Public License as published by
      7 # the Free Software Foundation, either version 3 of the License, or
      8 # (at your option) any later version.
      9 #
     10 # This program is distributed in the hope that it will be useful,
     11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 # GNU Affero General Public License for more details.
     14 #
     15 # You should have received a copy of the GNU Affero General Public License
     16 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
     17 
     18 defmodule ZenflowsTest.VF.ProposedIntent.Type do
     19 use ZenflowsTest.Help.AbsinCase, async: true
     20 
     21 setup do
     22 	%{
     23 		params: %{
     24 			"reciprocal" => Factory.bool(),
     25 			"publishedIn" => Factory.insert!(:proposal).id,
     26 			"publishes" => Factory.insert!(:intent).id
     27 		},
     28 		inserted: Factory.insert!(:proposed_intent),
     29 	}
     30 end
     31 
     32 describe "Mutation" do
     33 	test "proposeIntent", %{params: params} do
     34 		assert %{data: %{"proposeIntent" => %{"proposedIntent" => data}}} =
     35 			run!("""
     36 				mutation (
     37 					$reciprocal: Boolean!
     38 					$publishedIn: ID!
     39 					$publishes: ID!
     40 				) {
     41 					proposeIntent(
     42 						reciprocal: $reciprocal
     43 						publishedIn: $publishedIn
     44 						publishes: $publishes
     45 					) {
     46 						proposedIntent {
     47 							id
     48 							reciprocal
     49 							publishedIn {id}
     50 							publishes {id}
     51 						}
     52 					}
     53 				}
     54 			""", vars: params)
     55 
     56 		assert {:ok, _} = Zenflows.DB.ID.cast(data["id"])
     57 		assert data["reciprocal"] == params["reciprocal"]
     58 		assert data["publishedIn"]["id"] == params["publishedIn"]
     59 		assert data["publishes"]["id"] == params["publishes"]
     60 	end
     61 
     62 	test "deleteProposedIntent", %{inserted: %{id: id}} do
     63 		assert %{data: %{"deleteProposedIntent" => true}} =
     64 			run!("""
     65 				mutation ($id: ID!) {
     66 					deleteProposedIntent(id: $id)
     67 				}
     68 			""", vars: %{"id" => id})
     69 	end
     70 end
     71 end