Skip to content

Commit

Permalink
Check for pushed "registration-challenge" event in RegistrationCompon…
Browse files Browse the repository at this point in the history
…entTest (#65)

* Check for pushed "registration-challenge" event in RegistrationComponentTest

* add basic `assert_push_event/3` call to `authentication_component_test.exs`

---------

Co-authored-by: Owen Bickford <owen@owencode.com>
  • Loading branch information
optikfluffel and type1fool authored Jun 8, 2024
1 parent c28e52e commit d7c6450
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 5 additions & 1 deletion test/webauthn_components/authentication_component_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ defmodule WebauthnComponents.AuthenticationComponentTest do
end

describe "handle_event/3 - authenticate" do
test "sends authentication challenge to client", %{element: element} do
test "sends authentication challenge to client", %{element: element, view: view} do
clicked_element = render_click(element)
assert clicked_element =~ "<button"
assert clicked_element =~ "phx-click=\"authenticate\""

assert_push_event(view, "authentication-challenge", %{
id: "authentication-component"
})
end
end

Expand Down
7 changes: 4 additions & 3 deletions test/webauthn_components/registration_component_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ defmodule WebauthnComponents.RegistrationComponentTest do
assert clicked_element =~ "<button"
assert clicked_element =~ "phx-click=\"register\""

# TODO 1/10/2023
# Assert event was pushed to client
# Not supported by Phoenix.LiveViewTest or LiveIsolatedComponent
assert_push_event(view, "registration-challenge", %{
id: "registration-component",
user: ^webauthn_user
})
end
end

Expand Down

0 comments on commit d7c6450

Please sign in to comment.