From afb3aa400906276fb1fa89e29d7b0cb56536bf9c Mon Sep 17 00:00:00 2001 From: doorgan Date: Mon, 1 Jul 2024 18:02:49 -0300 Subject: [PATCH] Fix normalization of test payloads and bump version --- lib/channel_spec/testing.ex | 8 ++++++-- mix.exs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/channel_spec/testing.ex b/lib/channel_spec/testing.ex index d0ff956..b29ac98 100644 --- a/lib/channel_spec/testing.ex +++ b/lib/channel_spec/testing.ex @@ -173,10 +173,12 @@ defmodule ChannelSpec.Testing do topic = unquote(socket).assigns.__channel_topic__ event = unquote(event) + normalized_payload = payload |> Jason.encode!() |> Jason.decode!() + with true <- function_exported?(socket.handler, :__socket_schemas__, 0), %{} = schema <- socket_schema["channels"][topic]["subscriptions"][event] do - case Xema.validate(schema, payload) do + case Xema.validate(schema, normalized_payload) do :ok -> :ok @@ -225,10 +227,12 @@ defmodule ChannelSpec.Testing do topic = unquote(socket).assigns.__channel_topic__ event = unquote(event) + normalized_payload = payload |> Jason.encode!() |> Jason.decode!() + with true <- function_exported?(socket.handler, :__socket_schemas__, 0), %{} = schema <- socket_schema["channels"][topic]["subscriptions"][event] do - case Xema.validate(schema, payload) do + case Xema.validate(schema, normalized_payload) do :ok -> :ok diff --git a/mix.exs b/mix.exs index 9c03051..54d56a8 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule ChannelSpec.MixProject do use Mix.Project @repo_url "https://github.com/felt/channel_spec" - @version "0.1.7" + @version "0.1.8" def project do [