defmodule MicrowavepropWeb.LiveStashGuardTest do use ExUnit.Case, async: true alias MicrowavepropWeb.LiveStashGuard alias Phoenix.LiveView.Socket describe "stash/1" do test "swallows ArgumentError when LiveStash hasn't been initialized" do # An uninitialized socket has no `private.live_stash_adapter`, so # `LiveStash.stash/1` raises ArgumentError. The guard catches it # and returns the socket unchanged. socket = %Socket{} assert ^socket = LiveStashGuard.stash(socket) end test "returns socket unchanged from a fresh struct (no adapter init)" do socket = %Socket{assigns: %{count: 1}} result = LiveStashGuard.stash(socket) # Same socket back — preserves all assigns the LV had set up. assert result == socket end end end