Skip to content

Commit

Permalink
Refactor test
Browse files Browse the repository at this point in the history
  • Loading branch information
EMaksy committed Mar 19, 2024
1 parent efabcf9 commit 98706b2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/wanda_web/schemas/v3/catalog/check.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
22 changes: 12 additions & 10 deletions test/wanda_web/views/v1/catalog_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 =
Expand All @@ -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

0 comments on commit 98706b2

Please sign in to comment.