From aff42c360fd2e83d402ff21d088b2fd19aea5219 Mon Sep 17 00:00:00 2001 From: Craig P Jolicoeur Date: Wed, 17 May 2023 13:41:39 -0400 Subject: [PATCH] [tests] Add more tests to strip_unset_booleans/3 --- lib/torch/helpers.ex | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/torch/helpers.ex b/lib/torch/helpers.ex index 1a0892ee..9b8473bd 100644 --- a/lib/torch/helpers.ex +++ b/lib/torch/helpers.ex @@ -81,6 +81,9 @@ defmodule Torch.Helpers do iex> strip_unset_booleans(%{"post" => %{"title_contains" => "foo"}}, "post", []) %{"post" => %{"title_contains" => "foo"}} + iex> strip_unset_booleans(%{"post" => %{"title_contains" => "foo"}}, "post", [:title]) + %{"post" => %{"title_contains" => "foo"}} + iex> strip_unset_booleans(%{"post" => %{"title_equals" => "true"}}, "post", [:title]) %{"post" => %{"title_equals" => "true"}} @@ -90,6 +93,12 @@ defmodule Torch.Helpers do iex> strip_unset_booleans(%{"post" => %{"name_contains" => "foo", "title_equals" => "any"}}, "post", [:title]) %{"post" => %{"name_contains" => "foo"}} + iex> strip_unset_booleans(%{"post" => %{"name_equals" => "any", "title_equals" => "any"}}, "post", [:title, :name]) + %{"post" => %{}} + + iex> strip_unset_booleans(%{"post" => %{"name_equals" => "any", "title_equals" => "any", "surname_equals" => "bar"}}, "post", [:title, :name]) + %{"post" => %{"surname_equals" => "bar"}} + """ @spec strip_unset_booleans(params, binary, [atom]) :: params def strip_unset_booleans(params, _, []), do: params