-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,60 @@ | ||
defmodule BasketWeb.OverviewTest do | ||
use BasketWeb.ConnCase | ||
|
||
require Phoenix.LiveViewTest | ||
|
||
import Mox | ||
|
||
test "mount/3" do | ||
Basket.Websocket.MockAlpaca |> expect(:start_link, fn state -> {:ok, 1} end) | ||
alias BasketWeb.Overview | ||
|
||
@assigns_map %{__changed__: %{__context__: true}} | ||
@socket %{ | ||
assigns: @assigns_map, | ||
__context__: %{}, | ||
flash: %{}, | ||
live_action: nil | ||
} | ||
|
||
describe "mount/3" do | ||
test "assigns empty lists to keys" do | ||
Basket.Websocket.MockAlpaca |> expect(:start_link, fn state -> {:ok, 1} end) | ||
|
||
assert({:ok, socket} = Overview.mount([], %{}, @assigns_map)) | ||
|
||
assert( | ||
socket == %{ | ||
__changed__: %{__context__: true, basket: true, tickers: true}, | ||
__context__: %{}, | ||
basket: [], | ||
tickers: [] | ||
} | ||
) | ||
end | ||
end | ||
|
||
describe "handle_event/3" do | ||
test "ticker search does nothing without search criteria" do | ||
assert {:noreply, socket} = | ||
Overview.handle_event( | ||
"ticker-search", | ||
%{"selected-ticker" => "ABC"}, | ||
Map.merge(@assigns_map, %{assigns: %{tickers: ["ABC", "XYZ"]}}) | ||
) | ||
end | ||
|
||
# test "ticker search updates the ticker list" do | ||
# assert {:reply, %{}, socket} = | ||
# Overview.handle_event( | ||
# "ticker-search", | ||
# %{"selected-ticker" => "XYZ"}, | ||
# Map.merge(@assigns_map, %{assigns: %{tickers: ["ABC", "XYZ"]}}) | ||
# ) | ||
|
||
Basket.Websocket.Alpaca.start_link("statee") |> IO.inspect(label: "RESULT") | ||
# assert socket == %{ | ||
# __changed__: %{__context__: true, tickers: true}, | ||
# __context__: %{}, | ||
# tickers: ["XYZ"] | ||
# } | ||
# end | ||
end | ||
end |