Skip to content

Commit

Permalink
Fix normalization of test payloads and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
doorgan committed Jul 1, 2024
1 parent b64a180 commit afb3aa4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/channel_spec/testing.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
[
Expand Down

0 comments on commit afb3aa4

Please sign in to comment.