From 98706b29a86650b0cdb2f87dd13b65d2f3856316 Mon Sep 17 00:00:00 2001 From: EMaksy Date: Tue, 19 Mar 2024 11:05:09 +0100 Subject: [PATCH] Refactor test --- lib/wanda_web/schemas/v3/catalog/check.ex | 2 +- test/wanda_web/views/v1/catalog_view_test.exs | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/wanda_web/schemas/v3/catalog/check.ex b/lib/wanda_web/schemas/v3/catalog/check.ex index 45fe91c3c..a9f67f911 100644 --- a/lib/wanda_web/schemas/v3/catalog/check.ex +++ b/lib/wanda_web/schemas/v3/catalog/check.ex @@ -106,7 +106,7 @@ defmodule WandaWeb.Schemas.V3.Catalog.Check do "Message returned when the check return value is warning. Only available for `expect_enum` expectations" } }, - required: [:name, :type, :expression, :failure_message, :warning_message] + required: [:name, :type, :expression, :failure_message] } }, when: %Schema{ diff --git a/test/wanda_web/views/v1/catalog_view_test.exs b/test/wanda_web/views/v1/catalog_view_test.exs index 3f2e21b2a..cb8bb97fc 100644 --- a/test/wanda_web/views/v1/catalog_view_test.exs +++ b/test/wanda_web/views/v1/catalog_view_test.exs @@ -5,6 +5,7 @@ defmodule WandaWeb.V1.CatalogViewTest do import Wanda.Factory alias WandaWeb.V1.CatalogView + alias Wanda.Catalog.Check describe "CatalogView" do test "renders catalog.json" do @@ -36,16 +37,6 @@ defmodule WandaWeb.V1.CatalogViewTest do end end - test "renders catalog.json like expected in the v1 schema" do - checks = [ - build(:check, expectations: build_list(2, :catalog_expectation, type: :expect)), - build(:check, expectations: build_list(2, :catalog_expectation, type: :expect_same)) - ] - - rendered_catalog = render(CatalogView, "catalog.json", catalog: checks) - refute Access.get(rendered_catalog, :warning_message) - end - describe "adapt to V1 version" do test "should remove checks with expect_enum expectations" do checks = @@ -63,5 +54,16 @@ defmodule WandaWeb.V1.CatalogViewTest do ] } = render(CatalogView, "catalog.json", catalog: checks) end + + test "should remove warning_message in check expectations " do + checks = build_list(1, :check) + + %{ + items: [%Check{expectations: [expectation | _rest_expectations]}] + } = + render(CatalogView, "catalog.json", catalog: checks) + + refute Map.has_key?(expectation, :warning_message) + end end end