Apply Testing LiveView course patterns (live/2, has_element?, render_click, form/3). Add tests for MobileQRLive, WeathermapLive, StatusPageLive, controllers, plugs, and pure function modules. Expand proto decode coverage to 85.24%.
31 lines
799 B
Elixir
31 lines
799 B
Elixir
defmodule ToweropsWeb.Plugs.UpdateSessionActivityTest do
|
|
use ToweropsWeb.ConnCase, async: true
|
|
|
|
alias ToweropsWeb.Plugs.UpdateSessionActivity
|
|
|
|
describe "init/1" do
|
|
test "passes through opts unchanged" do
|
|
assert UpdateSessionActivity.init(:some_opts) == :some_opts
|
|
end
|
|
end
|
|
|
|
describe "call/2" do
|
|
test "passes through when no user_token in session", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> init_test_session(%{})
|
|
|> UpdateSessionActivity.call(%{})
|
|
|
|
assert conn.state == :unset
|
|
end
|
|
|
|
test "starts background task when user_token present", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> init_test_session(%{user_token: "existing-token"})
|
|
|> UpdateSessionActivity.call(%{})
|
|
|
|
assert conn.state == :unset
|
|
end
|
|
end
|
|
end
|